在Woocommerce Order中获取小计购物车

时间:2014-12-05 05:55:32

标签: php wordpress woocommerce

我需要在Woocommerce订单中获取小计购物车(不含运费)以便在此转换代码中注册

add_action( 'woocommerce_thankyou', 'pixelsoicos' );
function pixelsoicos( $order_id ) {
    // Lets grab the order
    $order = new WC_Order( $order_id );
     $items = $order->get_items();
    foreach ( $items as $item );
?>
<script type="text/javascript" src="http://ad.soicos.com/soicosjs.php?s=.js"></script>
<script type="text/javascript">
(function() {
    soicos.registerConversion({
        pid : 3507,
        data : "",
        trans : {
        orderID : "<?php echo $order_id;?>",
        store_name : "brudys",
        total : "",
        tax : "",
        shipping : "<?php echo $order->get_total_shipping();?>",
        city : "",
        province : "",
        country : "",
        currency : '<?php echo get_woocommerce_currency();?>'});})();
</script>
<?php
}

1 个答案:

答案 0 :(得分:-1)

WC()->cart->subtotal

或者

WC()->cart->get_cart_subtotal()