【问题标题】:How can i get order_total without taxes and shipping cost ? On woocommerce我怎样才能在没有税和运费的情况下获得 order_total?关于woocommerce
【发布时间】:2015-11-20 14:10:48
【问题描述】:

我想放置一个像素来跟踪我的附属订单。

我必须在折扣后获得我的总订单,因此不含税和运费。

我做了类似的东西,但它显示为 0。

<?php echo $woocommerce->cart->get_total_ex_tax(); ?>

这可能是因为它显示货币符号。

【问题讨论】:

  • 为什么0 不是可接受的返回值?听起来订单总额实际上是0,折扣后,运费和税前。
  • 您好,感谢您的回复,因为这对我的订单数量很重要,我的返回值始终为 0。所以这是一个错误。

标签: php wordpress woocommerce affiliate


【解决方案1】:

这是不含税和运费的购物车总数。

$cart_value = number_format( (float) $order->get_total() - $order->get_total_tax() - $order->get_total_shipping() - $order->get_shipping_tax(), wc_get_price_decimals(), '.', '' );

【讨论】:

  • 为我工作!谢谢
【解决方案2】:

Vdadmax 的答案几乎是正确的。如果对运费征税,那么在他的情况下会扣除两次(扣除总运费(含税),然后再扣除运费销售税),最终总金额太低。

这将为您提供扣除所有销售税和运费的正确总数:

$cart_value = number_format( (float) $order->get_total() - $order->get_total_tax() - $order->get_total_shipping(), wc_get_price_decimals(), '.', '' );

我还不能发表评论,因此我将其添加为答案。

【讨论】:

    【解决方案3】:

    你试过了吗?

    $cart_value = $order->get_total_tax() - $order->get_total();
    

    【讨论】:

      【解决方案4】:

      这有助于我得到不含税的总金额。

      WC()->cart->subtotal_ex_tax
      

      【讨论】:

        【解决方案5】:
        get_woocommerce_totals()['cart_subtotal']['value']
        

        【讨论】:

          猜你喜欢
          • 2015-10-30
          • 1970-01-01
          • 2022-12-20
          • 2023-01-02
          • 1970-01-01
          • 2023-03-21
          • 2021-02-28
          • 2023-01-24
          • 2011-06-04
          相关资源
          最近更新 更多