Guest NetNeo Posted October 28, 2006 Share Posted October 28, 2006 There appears to be bugs in relation to how the built in affiliate modules work. I have seen multiple threads regarding the tracking so instead of me keep posting comments all over the place (and putting un-wanted pressure on the already busy forum) I thought I would start a new thread detailing what I have found and how I have corrected it. Firstly, there is an error in the affiliate tracking code when the Print Order gateway is used. Secondly, there is a coding error for JORX use. Thirdly, I think I see a better way of integrating all the modules in cubecart for tracking affiliate sales. Here are my solutions: I CANNOT LOG INTO JORX FROM CUBECART ADMIN SECTION When attempting to log into Affilate Manager from the JORX Affiliate module in cudecart you get a 404/not found error This is a simple fix! Open the file "admin/modules/affiliate/JROX/index.php" Find: affiliates/admin/ And replace it with: /admin/ Save the file. You can now log into the Affiliate Manager script from the cubecart Affiliate Module AFFILIATE SALES ARE NOT TRACKING FOR "PRINT ORDER" GATEWAY This error was found when putting test orders through using the Print Out Order payment gateway. The variables needed to log the order and ordervalue to send to Affiliate Manager are not being set correctly Firstly, the cart is emptied before the affiliate tracking URL is created. This stops the URL creation from picking up the number of the order! Find the section: // empty basket $basket = $cart->emptyCart(); // add affilate tracking code/module $affiliateModule = $db->select("SELECT folder, `default` FROM ".$glob['dbprefix']."CubeCart_Modules WHERE module='affiliate' AND status = 1"); if($affiliateModule == TRUE) { for($i=0; $i<count($affiliateModule); $i++){ include("../../../modules/affiliate/".$affiliateModule[$i]['folder']."/tracker.inc.php"); // VARS AVAILABLE // Order Id Number $basket['cart_order_id'] // Order Total $order[0]['prod_total'] //$basket['cart_order_id'] = $_POST['x_invoice_num']; $order[0]['prod_total'] = $result[0]['prod_total']; echo $affCode; } } You can see from the code that the basket is being emptied before the affiliate tracking script is called. You need to take the empty basket statement and move it to AFTER the affiliate tracking code so it looks as follows: // add affilate tracking code/module $affiliateModule = $db->select("SELECT folder, `default` FROM ".$glob['dbprefix']."CubeCart_Modules WHERE module='affiliate' AND status = 1"); if($affiliateModule == TRUE) { for($i=0; $i<count($affiliateModule); $i++){ include("../../../modules/affiliate/".$affiliateModule[$i]['folder']."/tracker.inc.php"); // VARS AVAILABLE // Order Id Number $basket['cart_order_id'] // Order Total $order[0]['prod_total'] //$basket['cart_order_id'] = $_POST['x_invoice_num']; $order[0]['prod_total'] = $result[0]['prod_total']; echo $affCode; } } // empty basket <--- These two lines have been moved $basket = $cart->emptyCart(); Thats that bit corrected. Now when the URL is created the ordernumber is being processed correctly. However, we now have the problem that when the URL is created the cart value is empty! Therefore if we are paying commission on sales value it wont work as every sale will be flagged as being 0 This again is due to code low being wrong. Find this section: if($affiliateModule == TRUE) { for($i=0; $i<count($affiliateModule); $i++){ include("../../../modules/affiliate/".$affiliateModule[$i]['folder']."/tracker.inc.php"); // VARS AVAILABLE // Order Id Number $basket['cart_order_id'] // Order Total $order[0]['prod_total'] //$basket['cart_order_id'] = $_POST['x_invoice_num']; $order[0]['prod_total'] = $result[0]['prod_total']; echo $affCode; } Here the include statment calls the affiliate module to create a URL. However, as the URL is created it needs the valiable $order[0]['prod_total'] to be set to the carts total value of sales. This variable isn't set untill five lines after the URL has already been created! That means that the URL will have a cart value of 0. Simply move the include staement to AFTER the line setting $order[0]['prod_total'] = $result[0]['prod_total']; so your code will now look like this: if($affiliateModule == TRUE) { for($i=0; $i<count($affiliateModule); $i++){ // VARS AVAILABLE // Order Id Number $basket['cart_order_id'] // Order Total $order[0]['prod_total'] //$basket['cart_order_id'] = $_POST['x_invoice_num']; $order[0]['prod_total'] = $result[0]['prod_total']; include("../../../modules/affiliate/".$affiliateModule[$i]['folder']."/tracker.inc.php"); echo $affCode; } You may now save this file. At this point, commissions are being tracked for all payments made by the Print Order gateway. AFFILIATE TRACKING IS NOT WORKING FROM OTHER GATEWAYS I would like to make a suggestion to the developers that affiliate tracking for all other inbuit methods could easily be integrated into the orderSuccess file. The same tracking script section could be added just before the empty cart call. i.e. track affiliate sales by adding the script: // add affilate tracking code/module $affiliateModule = $db->select("SELECT folder, `default` FROM ".$glob['dbprefix']."CubeCart_Modules WHERE module='affiliate' AND status = 1"); if($affiliateModule == TRUE) { for($i=0; $i<count($affiliateModule); $i++){ include("../../../modules/affiliate/".$affiliateModule[$i]['folder']."/tracker.inc.php"); echo $affCode; } into the orderSuccess file here: $send = $mail->send(array($order[0]['email']), $config['mailMethod']); } // ---START OF TRACKING // <-- INSERT AFFILIATE TRACKING HERE // ---END OF TRACKING // empty basket $emptyBasket['basket'] = "''"; If the order success is used, then every order that generates a confirmation email (except the Print Order Form gateway) would be tracked simply and quickly. Comments???? Quote Link to comment Share on other sites More sharing options...
Guest NetNeo Posted October 28, 2006 Share Posted October 28, 2006 An after thought! Placing the tracking in one place means: 1. Code changes and improvments only need to be completed in one place 2. Third party modules are easy to develop 3. Someone using a 'non' cubecart included module can replace the affiliate tracking section with thier own tracking code (i.e. from Yahoo, etc) Quote Link to comment Share on other sites More sharing options...
Guest Posted October 28, 2006 Share Posted October 28, 2006 This is great if it solves so many problems for so many people. Would it be possible for you to create a step-by-step instruction (like with mods) for us non-programmers to follow so everyone can fix their software? Daniel in Arizona. Quote Link to comment Share on other sites More sharing options...
Guest vp-ftv Posted February 13, 2007 Share Posted February 13, 2007 This is a definate fix for the PRINT ORDER FORM. Regarding other modules, take Manual Credit Card (MCC) it does not work. How do you suggest to fix orders that need manual processing? Will iDevAffiliate for example need to be updated manually as well? Or can the operation be automated - e.g. order changed to processing/shipped the comission can be approved? BTW awesome fix, and much better than the developers current stance to remove compatability. Maybe the developers will be returning the comissions earnt from the IDevAffiliates links still present in v3.0.15 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.