0
votes

I have been requested by a Marketing company to place a Pixel Code in my WooCommerece checkout page to track conversions and generate reports.

Pixel Code:

<!-- Offer Goal Conversion: Cameras -->

It's required to replace AMOUNT with the sale amount of my cart and replace SUB_ID with the unique value (Like Order Number/id).

I tried replacing both values with several variables and values Like order_id, $order_id, $subtotal, subtotal but it doesn't seem to read and pass any data to the conversion report.

I need help to identify the correct WooCommerce variables for Cart Subtotal and Order Number that will read and pass data to the conversion report.

My Website is www.Trenddr.com

Thank You.

1

1 Answers

0
votes

for subtotal:

1) With global $woocommerce; variable:

global $woocommerce;  
$woocommerce->cart->subtotal;

// or

$woocommerce->cart->get_cart_subtotal()

2) Without global $woocommerce; variable:

WC()->cart->subtotal

// Or

WC()->cart->get_cart_subtotal()

for the order id:

global $woocommerce, $post;

$order = new WC_Order($post->ID);

//to escape # from order id 

$order_id = trim(str_replace('#', '', $order->get_order_number()));