Guest Posted July 25, 2007 Share Posted July 25, 2007 I recently ran a promo for a new package that had an option for physical delivery. Up until this point, my business has been primarily digital products that never required shipping. Imagine my surprise and total SHOCK to find that my affiliates were getting commissions on SHIPPING charges?! Why would CubeCart be set up to do this? Affiliate commissons should be on the SUBTOTAL, without shipping nor taxes! Luckily, I think I was able to find and solve the problem. It seems to be working so far. For reference, the location where affiliate commissions are tracked is in /includes/content/confirmed.inc.php, around line 94, you'll see the following: include("modules/affiliate/".$affiliateModule[$i]['folder']."/tracker.inc.php"); // VARS AVAILABLE // Order Id Number $basket['cart_order_id'] // Order Total $order[0]['prod_total'] $confirmation->assign("AFFILIATE_IMG_TRACK",$affCode); The reminders there are showing what variables are available upon which to pull data that is normally used for affiliate program. Just to keep ourselves informed, we can add a line about the subtotal, which is: // Order SubTotal $basket['subTotal'] Something else I should include here for completeness is a section of code I added to give us the right data when a customer uses PayPal. This code pulls the order data from the database because otherwise it's lost. The following should be added after the $success = success(); line and before the $confirmation line, as: // 2. Include function which returns ture or false $success = success(); if($basket['gateway'] == "PayPal"){ $result = $db->select("SELECT cart_order_id, prod_total, subtotal FROM ".$glob['dbprefix']."CubeCart_order_sum WHERE sec_order_id = ".$db->mySQLSafe($_GET['tx']) ); $basket['cart_order_id'] = $result[0]['cart_order_id']; $order[0]['prod_total'] = $result[0]['prod_total']; $basket['subTotal'] = $result[0]['subtotal']; } $confirmation = new XTemplate ("skins/".$config['skinDir']."/styleTemplates/content/confirmed.tpl"); This insures that we have the data we need to process affiliate tracking when PayPal is used. Okay, now on to the affiliate tracking itself. This is done in each affiliate module, but the basic idea is to replace $order['prod_total'] with $basket['subTotal'] where needed. In my case, I use PostAffiliatePro, so I had to edit /modules/affiliate/PostAffiliatePro/tracker.inc.php, and the result looks like: $affCode .= "<img border='0' src='".$module['URL']."/scripts/sale.php?TotalCost=".sprintf("%.2f", $basket['subTotal'])."&OrderID=".$basket['cart_order_id']."' width='0' height='0' />\r\n"; Quote Link to comment Share on other sites More sharing options...
Guest Posted September 5, 2007 Share Posted September 5, 2007 I need to post an update to the above fix. I discovered that my fix did not account for the use of coupon codes with Goober's coupon/giftcard mod. What I've discovered is that I have to do a quick calculation that takes the final price and removes shipping and tax to arrive at the "final, after coupon" price. In /includes/content/confirmed.inc.php, I now have: // 2. Include function which returns true or false $success = success(); if($basket['gateway'] == "PayPal"){ $result = $db->select("SELECT cart_order_id, prod_total, subtotal, total_tax, total_ship FROM ".$glob['dbprefix']."CubeCart_order_sum WHERE sec_order_id = ".$db->mySQLSafe($_GET['tx']) ); $basket['cart_order_id'] = $result[0]['cart_order_id']; $order[0]['prod_total'] = $result[0]['prod_total']; $basket['subTotal'] = $result[0]['subtotal']; $basket['tax'] = $result[0]['total_tax']; $basket['shipCost'] = $result[0]['total_ship']; } $confirmation = new XTemplate ("skins/".$config['skinDir']."/styleTemplates/content/confirmed.tpl"); and if($affiliateModule[$i]['status']==1){ include("modules/affiliate/".$affiliateModule[$i]['folder']."/tracker.inc.php"); // VARS AVAILABLE // Order Id Number $basket['cart_order_id'] // Order Total $order[0]['prod_total'] // Order Subtotal $basket['subTotal'] // Order Shipping $basket['shipCost'] // Order Tax $basket['tax'] $confirmation->assign("AFFILIATE_IMG_TRACK",$affCode); $confirmation->parse("confirmation.session_true.order_success.aff_track"); And in my affiliate tracking module (modules/affiliate/PostAffiliatePro/tracker.inc.php): $affiliateTotal = $order[0]['prod_total'] - ($basket['shipCost'] + $basket['tax']); $affCode .= "<img border='0' src='".$module['URL']."/scripts/sale.php?TotalCost=".sprintf("%.2f", $affiliateTotal)."&OrderID=".$basket['cart_order_id']."' width='0' height='0' />\r\n"; Now, I'm getting correct numbers reported to my affiliate software every way I can see it. Quote Link to comment Share on other sites More sharing options...
Guest davidgjohnson Posted December 8, 2007 Share Posted December 8, 2007 AlanT, Thanks for posting this excellent information. Once again, this is evidence of why I love this community. I had a significant problem in this area, and although I use the JROX system instead of PostAffiliatePro, I found your solution was quite portable. Keep up the great work! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.