• Integrating Sales Analytics/Affiliates Tools

    On the "checkout_success" page, there are several pieces of data available:

    • $order_summary['order_number'] = The current order number
    • $order_summary['order_subtotal'] = The subtotal of the price of all products in the cart, before shipping etc
    • $order_summary['credits_applied'] = A sum of all discounts/credits applied to the order (ie: handled by "credit" ot modules such as coupons and gift certificates and customer-group-discounts etc)
    • $order_summary['commissionable_order'] = The amount of the purchase that is commissionable, ie: subtotal minus discounts
    • $order_summary['commissionable_order_formatted'] = Formatted according to the current currency
    • $order_summary['coupon_code'] = The coupon code used in this order, if any
    • $order_summary['currency_code'] = The currency used when making this sale
    • $order_summary['currency_value'] = The exchange rate applied while using this currency
    • $order_summary['payment_module_code'] = The payment module used to facilitate payment
    • $order_summary['shipping_method'] = The shipping method selected by the customer
    • $order_summary['orders_status'] = The status number denoting the order's status in the system
    • $order_summary['tax'] = The amount of tax on the order
    • $order_summary['shipping'] = The shipping cost
    • $order_summary['order_total'] = The final/net total of the order, the amount for payment




    An analytics or affiliate-tracking system can use these variables as part of their tracking-pixel or other callback notification by simply referencing these variables in their callback/tracking code.

    Examples:

    iDevAffiliate
    No need to edit any core Zen Cart files.
    Simply create a new file: /includes/modules/pages/checkout_success/jscript_idevaffiliate.php ... be sure to set the correct URL for your iDevAffiliate system, and appropriate profile number:
    Code:
    <?php
      $idev_saleamt = number_format($order_summary['commissionable_order'], 2);
      echo '<script language="javascript" type="text/javascript" src="http://www.yourdomain.com/idevaffiliate/sale.php?profile=1&idev_saleamt=' . $idev_saleamt . '&idev_ordernum=' . $order_summary['order_number'] . '"></script>';
    JROX JAM
    No need to edit any core Zen Cart files.
    Simply create a new file: /includes/modules/pages/checkout_success/jscript_jam.php ... be sure to set the correct URL for your JAM system:
    Code:
    <?php
       echo '<script language="javascript" type="text/javascript"  src="http://www.yourdomain.com/affiliates/sale.php?amount=' . $order_summary['commissionable_order'] . '&trans_id=' . $order_summary['order_number'] . '"></script>';


    Advanced Use
    Advanced programmers might choose programmatic hooks instead of javascript callbacks, by invoking the notifier system. This involves hooking NOTIFY_CHECKOUT_PROCESS_HANDLE_AFFILIATES and referencing the $_SESSION['order_summary'] array in place of the non-global $order_summary array.
    This could allow a bespoke tracking service to be invoked without needing to force extra activities down to the customer's browser.


    Related article: http://www.zen-cart.com/content.php?...els-to-my-site