Hi there,
As Zanox is switching over to Awin in the Netherlands, we need to change our tracking code to the new code of Awin. We use WooCommerce (3.0). They have an extensive documentation with examples: http://wiki.awin.com/index.php/Merchant_Tracking_Guide
We need to track it on a per product base, with the items of the cart & the categoryID of that product added (so that we can set different types of commissions in the backend).
The current code that we use is:
function zx_tracking_script( $order_id ) {
$zanox_partner_code = '[xxxx]';
$order = wc_get_order( $order_id );
$order_number = $order->get_order_number();
$order_total = number_format($order->get_total(), 2, ",", "");
$order_email_hash = md5($order->billing_email);
$order_currency = $order->get_order_currency();
$categoryid = get_post_meta( get_the_ID(), 'CategoryID', true );
// getting all products items for each order
$items = $order->get_items();
$XML = '<z><o>';
foreach ($items as $item)
{
$product_id = $item['product_id']; // product id
$product = get_post_meta($product_id);
$name = $item['name'];
$price = $item['line_subtotal'];
$price = number_format($price, 2, ",", "");
$categoryid = get_post_meta($product_id, 'CategoryID', true );
$XML .= '<so cid=”'.$categoryid.'” pn=”'.$name.'” pnr=”'.$product_id.'” up=”'.$price.'” qty=”1” ulp=”'.$product_id.'”/>';
}
$XML .= '</o></z>';
$XML = urlencode($XML);
echo ('<script type="text/javascript" src="https://ad.zanox.com/pps/?'.$zanox_partner_code.'&mode=[[1]]&CID=[[BASKET]]&CustomerID=[['.$order_email_hash.']]&OrderID=[['.$order_number.']]&CurrencySymbol=[['.$order_currency.']]&TotalPrice=[['.$order_total.']]&PartnerID=[[XXX]]&XML=[['.$XML.']]">
</script>
<noscript>
<img src="https://ad.zanox.com/pps/?'.$zanox_partner_code.'&mode=[[2]&CID=[[BASKET]]]&CustomerID=[['.$order_email_hash.']]&OrderID=[['.$order_number.']]&CurrencySymbol=[['.$order_currency.']]&TotalPrice=[['.$order_total.']]&PartnerID=[[XXX]]&XML=[['.$XML.']]" width="1" height="1" />
</noscript>');
}
add_action( 'woocommerce_thankyou', 'zx_tracking_script' );