在将订单放入payment_fields函数之前获取订单总计

时间:2017-02-16 19:54:11

标签: php wordpress woocommerce point-of-sale

我正在使用WooCommerce和以下插件: https://codecanyon.net/item/woocommerce-point-of-sale-pos/7869665

以下代码应在付款字段上打印一个URL,该字段应在计算机上打开应用程序。所有这一切都运行正常,但URL需要包含总订单价格(以美分为单位,因此乘以100),我无法完成这项工作。我已经编写了以下代码,我唯一缺少的是 $ order_price_cents

public function payment_fields()
{

    $smartpinurl = "smartpin://payment?price=" . $order_price_cents . "&vat=zero&reference=Bestelling%20bij%DE-IT%20";

    echo '<a class="x-btn x-btn-rounded x-btn-regular" href="' . $smartpinurl . '" target="_blank">Activeer Smartpin App</a>';

}

单击此按钮时尚未放置订单,因此我无法使用默认方式获取价格。

例如:我在POS系统中选择价值10.00欧元的产品。所以$ order_price_cents必须是1000。

2 个答案:

答案 0 :(得分:0)

试试这个:

public function payment_fields()
{

    global $woocommerce;  
    $order_price_cents = $woocommerce->cart->total * 100;

    $smartpinurl = "smartpin://payment?price=" . $order_price_cents . "&vat=zero&reference=Bestelling%20bij%DE-IT%20";

    echo '<a class="x-btn x-btn-rounded x-btn-regular" href="' . $smartpinurl . '" target="_blank">Activeer Smartpin App</a>';

}

答案 1 :(得分:0)

试试这个

public function payment_fields()
{    
    global $woocommerce;  
    $order_price_cents = $woocommerce->cart->total * 100;

    $smartpinurl = "smartpin://payment?price=" . $order_price_cents . "&vat=zero&reference=Bestelling%20bij%DE-IT%20";

    echo '<a class="x-btn x-btn-rounded x-btn-regular" href="' . $smartpinurl . '" target="_blank">Activeer Smartpin App</a>';

}

如果它无法正常工作,那么您可以在WooCommerce POS查看正确的替换内容。这是WooCommerce销售点的最佳流程。

相关问题