douzhe9927 2017-02-16 19:54
浏览 97

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

I'm using WooCommerce and the following plugin: https://codecanyon.net/item/woocommerce-point-of-sale-pos/7869665

The following code should print a URL on the payment field which should open an app on the computer. All of this is working fine, but the URL needs to contain the total order price (in cents, so multiplied by 100) and I can't manage to get this done. I already wrote the following code and the only thing I'm missing is $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>';

}

Orders aren't placed yet when this button is clicked, so I can't use the default way to get the price.

E.g: I select a product worth €10.00 in the POS system. So $order_price_cents needs to be 1000.

  • 写回答

2条回答 默认 最新

  • duan00529 2017-02-16 20:29
    关注

    Try this:

    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>';
    
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?