订单减去折扣和运输woocommerce

时间:2016-11-01 16:33:32

标签: javascript php wordpress woocommerce hook-woocommerce

我需要一些关于此跟踪代码的帮助。

我试图让订单跟踪工作,所有工作都与$order_total

分开
    <!-- Image Pixel Tracking - Mandatory -->
   <img src="https://www.awin1.com/sread.img?tt=ns&tv=2&merchant=xxxx&amount=<?php echo $order_total ?>&cr=GBP&ref=<?php echo $order_id; ?>&parts=DEFAULT:<?php echo $order_total ?>&vc=<?php echo $order_coupon ?>&ch=AW&testmode=0" border="0" width="0" height="0">


   <!-- Javascript Tracking - Mandatory --> 
   <script type="text/javascript">
   //<![CDATA[ 

   /*** Do not change ***/
   var AWIN = {};
   AWIN.Tracking = {};
   AWIN.Tracking.Sale = {};

   /*** Set your transaction parameters ***/
   AWIN.Tracking.Sale.amount = '<?php echo $order_total; ?>';
   AWIN.Tracking.Sale.orderRef = '<?php echo $order_id; ?>';
   AWIN.Tracking.Sale.parts = 'DEFAULT:<?php echo $order_total; ?>';
   AWIN.Tracking.Sale.voucher = '<?php echo $order_coupon; ?>';
   AWIN.Tracking.Sale.currency = 'GBP';
    AWIN.Tracking.Sale.test = '0';
    AWIN.Tracking.Sale.channel = 'AW';
    //]]>
    </script>

我得到订单总数,但我需要它删除任何折扣和运输我试图这样做

     $order_total_without_discount = number_format($order->get_subtotal(), 2, ".", "");


    $cart_discount = $woocommerce->cart->discount_total;

    $cart_discount_decimal = number_format($cart_discount, 2, ".", "");  

   $order_total = $order_total_without_discount - $cart_discount_decimal;


    $order_total_with_shipping = number_format($order->get_total(), 2, ".", "");

希望有人可以提供帮助。

我已经回到跟踪公司,他们提供零支持。

1 个答案:

答案 0 :(得分:0)

通过更改

解决了这个问题
 $order_total_without_discount = number_format($order->get_subtotal(), 2, ".", "");

 $order_total_without_discount = number_format($order->get_total(), 2, ".", "");