WordPress ecommerce Plugin integration
A free, powerful plugin that empowers you to sell anything.
This integration was successfully tested on WP ecommerce plugin v 3.8.13.3
You can track per product information with this integration method.
Edit template
In your wordpress installation, open and edit the file:
wp-content/plugins/wp-e-commerce/wpsc-theme/functions/wpsc-transaction_results_functions.php
Find function transaction_results. Right below the line with function definition, there are global variables listed. Add another one there:
$wpdb
Then find the last line of the function:
return $message_html;
Integration
Put the following integration code ABOVE the line:
/*Post Affiliate Pro integration code */
$purchase = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid`= %s LIMIT 1", $sessionid ) );
$message_html .= '<script id="pap_x2s6df8d" src="https://URL_TO_PostAffiliatePro/scripts/trackjs.js" type="text/javascript"></script>
<script type="text/javascript">'.
"PostAffTracker.setAccountId('Account_ID');var sale = PostAffTracker.createSale();
sale.setTotalCost('".$purchase->totalprice."');
sale.setOrderID('".$purchase->id."');
PostAffTracker.register();
</script>";
/* /Post Affiliate Pro integration code */
In case you want to use tax and shipping variables, here you are:
- $total_tax
- $total_shipping
Per product integration
If you want to track commissions per product, just use this code instead:
/*Post Affiliate Pro integration code */
$purchase = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid`= %s LIMIT 1", $sessionid ) );
$cart_items = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . WPSC_TABLE_CART_CONTENTS . " WHERE purchaseid = %d", $purchase->id ), ARRAY_A );
$message_html .= '<script id="pap_x2s6df8d" src="https://URL_TO_PostAffiliatePro/scripts/trackjs.js" type="text/javascript"></script>
<script type="text/javascript">'."PostAffTracker.setAccountId('Account_ID');";
$i = 1;
foreach ($cart_items as $item) {
$item = array_map('wp_specialchars_decode', $item);
$message_html .= "var sale$i = PostAffTracker.createSale();
sale$i.setTotalCost('".($item['price']*$item['quantity'])."');
sale$i.setOrderID('".$purchase->id."($i)');
sale$i.setProductID('".$item['prodid']."');
PostAffTracker.register();";
$i++;
}
$message_html .= "</script>";
/* /Post Affiliate Pro integration code */
If you want to use category name for the product ID, this is how to get it:
$category = wp_get_object_terms($item['prodid'],'wpsc_product_category',array( 'orderby' => 'count', 'order' => 'DESC', 'fields' => 'all_with_object_id'));
Then, the name is defined in:
$category[0]->name;
In case you want to use item name, use variable $item[‘name’] instead of $item[‘prodid’].
In case you want to use SKU, use this code first:
$item['sku'] = get_post_meta($item['prodid'], '_wpsc_sku', true);
Place it below the line with “arraymap” and then, simply replace $item[‘prodid’] with $item[‘sku’]_.
Do not forget to integrate your WordPress with the click tracking code. You can do it by placing the click tracking cade to your WP footer file, in Appearance > Edit menu of your WP.
WooCommerce (WordPress module)
Integrate WooCommerce with Post Affiliate Pro effortlessly using our comprehensive guide. Track orders, per-product commissions, and integrate with PayPal and Stripe seamlessly. Enhance your affiliate marketing strategy and maximize your e-commerce success with easy-to-follow instructions and expert support. Visit now to boost your affiliate management capabilities!