【问题标题】:How to recalculate order taxes and total programmatically in woocommerce如何在 woocommerce 中以编程方式重新计算订单税和总额
【发布时间】:2020-09-01 22:04:52
【问题描述】:

我仅从管理员使用 woocommerce,并仅从管理面板手动添加订单。

除了税收计算外,一切正常。 添加产品后,我必须单击重新计算才能应用相关税款。如果我忘记了,发票不包括税费。

我想知道是否有办法在订单更新期间应用重新计算按钮执行的所有步骤。我有自定义元框和许多订单元,我在订单更新时以编程方式保存。

如果问题不清楚,请告诉我,这是我在这里的第一篇文章。 感谢您的帮助。

【问题讨论】:

    标签: wordpress woocommerce


    【解决方案1】:

    这可能对某些方向有所帮助:

            $this->order = new WC_Order($order_id); 
    
            // Order back to pending
            $this->order->update_status('pending', '<%Your message%>', TRUE);
    
            // Recalculate the order
            $total = $this->order->calculate_totals();
    
            // Save it, although the calculate also does it. 
            $this->order->save();
    

    我不太确定,但它可能会让你继续前进(如果仍然需要)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-07-24
      • 2022-01-13
      • 1970-01-01
      • 2017-03-14
      • 2019-01-21
      • 2021-04-25
      • 2021-02-16
      相关资源
      最近更新 更多