Hi!
Google has given me this Tracking code:
To integrate once a customer completes a purchase.
However.
I’d like to make it for a single product.
I found this guide:
Which says to use:
get_items() as $item ) {
$product = $order->get_product_from_item( $item );
if ( ! $product ) { continue; }
$sku = $product->get_sku();
if (preg_match(’/-tp$/’, $sku) === 1) {
return true;
}
}
return false;
}
function my_custom_tracking( $order_id ) {
$order = new WC_Order( $order_id );
if (order_items_include_tracking_pixel($order, $order_id)) {
$total = $order->get_order_total();
// INSERT TRACKING CODE or
// DO YOUR CUSTOM BEHAVIOR HERE
}
}
add_action( ‘woocommerce_thankyou’, ‘my_custom_tracking’ );
?>
And:
if (preg_match(’/-tp$/’, $sku) === 1) {
with the product SKU in the funcitons.php file.
But I’m not sure what exactly to put into the functions.php file for this.
This is the product that I’m trying to track.
https://www.dzdrones.com/product/limitless-frame-and-pod-promo/
Can you help?
Thanks!