Skip to content

Instantly share code, notes, and snippets.

@jdevalk
Created January 31, 2013 20:37
Show Gist options
  • Select an option

  • Save jdevalk/4686210 to your computer and use it in GitHub Desktop.

Select an option

Save jdevalk/4686210 to your computer and use it in GitHub Desktop.
<?php
function yst_shareasale_tracking( $content ) {
global $edd_options;
if ( is_page( $edd_options['success_page'] ) ) {
if ( isset( $_GET['cm'] ) ) {
$order_id = intval( $_GET['cm'] );
} else if ( function_exists( 'edd_get_purchase_id_by_key' ) ) {
$pd = edd_get_purchase_session();
$order_id = edd_get_purchase_id_by_key( $pd['purchase_key'] );
unset( $pd );
}
if ( !isset( $order_id ) )
return $content;
$merchant_id = '<enter merchant ID>';
$payment_data = edd_get_payment_meta( $order_id );
$cart_info = maybe_unserialize( $payment_data['cart_details'] );
$content = '<img src="https://shareasale.com/sale.cfm?amount='.number_format( $payment_data['amount'], 2 ) .'&tracking='.$order_id.'&transtype=sale&merchantID='.$merchant_id.'" width="1" height="1">' . $content;
}
return $content;
}
add_filter( 'the_content', 'yst_shareasale_tracking' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment