Forum Replies Created
-
AuthorPosts
-
metius
ParticipantHi, it works but if someone for any reasons update thank you page or pay with paypal and close page before redirect on thank you page it distorts data sent to the pixel.
So I’d like trying something like adding action for new order that should check if meta key (“_wpam_id”) for new order exist.
but i don’t know how to get it…
metius
Participanti changed it so:
if (isset($_COOKIE[‘wpam_id’])) {
$aff_id = $_COOKIE[‘wpam_id’];
if($aff_id == ’67’)
add_action( ‘woocommerce_thankyou’, ‘my_custom_tracking’ );
function my_custom_tracking( $order_id ) {
// Lets grab the order
$order = wc_get_order( $order_id );/**
* Put your tracking code here
*/?>
<!– Facebook Pixel Code –>
<script>
!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version=’2.0′;
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)}(window, document,’script’,
‘https://connect.facebook.net/en_US/fbevents.js’);
fbq(‘init’, ‘myfacebookpixel’);
fbq(‘trackSingle’, ‘myfacebookpixel’, ‘Purchase’, {value: <?php echo ($order->get_subtotal() – $order->get_total_discount()) * 0.15; ?>,
currency: ‘EUR’,
});
</script><!– End Facebook Pixel Code –>
<?php
// This is the order total
$order->get_total();
$order->get_subtotal();
$order->get_total_discount();}
} -
AuthorPosts