【问题标题】:Get Order Total before order is placed in payment_fields function在将订单下达至 payment_fields 函数之前获取订单总额
【发布时间】:2017-02-16 19:54:10
【问题描述】:

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

以下代码应在支付字段上打印一个 URL,该 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。

【问题讨论】:

  • @LoicTheAztec 很抱歉,但我认为我没有说清楚,我将以下插件用于销售点系统:codecanyon.net/item/woocommerce-point-of-sale-pos/7869665 选择项目时,它没有存储在默认的 WC 购物车中,而是存储在插件的系统中。
  • 这是一个商业插件,我们无法测试……对不起

标签: php wordpress woocommerce point-of-sale


【解决方案1】:

试试这个:

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>';

}

【讨论】:

  • 感谢您的回复,但是很遗憾您在POS插件中添加的项目没有存储在WC购物车中,而是存储在其他地方(我不知道在哪里并且该插件的响应速度很慢)门票)
【解决方案2】:

试试这个

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 销售点的最佳流程。

【讨论】:

    猜你喜欢
    • 2016-02-18
    • 1970-01-01
    • 2021-11-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-17
    相关资源
    最近更新 更多