Jump to content

How to capture affiliate sales


shopkeeper

Recommended Posts

I am using Prestashop 1.4 and I want to give my affiliates a unique URL they can pass on to customers and allow me to capture their sales and calculate commissions. I want the URL to look like this www..com/1234 as I think this is the most unobtrusive way for a customer to identify the affiliate who sent them to the site. This URL would attribute the sale to affiliate 1234.

I understand that the following method will not allow updates as it changes the core code in Prestashop but I do not know any other way to do this.

I have created a line in my .htaccess file to modify the URL:

RewriteRule ^([0-9]+)$ index.php?referer=$1 [NC]



This changes the URL to look like this www..com/?referer=1234

Then I inserted the following code into index.php between the two lines already there:


if(isset($_REQUEST['referer'])) {
   $referer = $_REQUEST['referer'];
} else {
   $referer = "1000"   // default if no referer
}
$smarty->assign('sale_referer',$referer);[/b]



I then have added code to the module blockuserinfo so the purchaser can see that they are purchasing from the correct affiliate.
This has been added to the blockuserinfo.tpl file (after the p tags that tell you who is logged in):


{l s='Refered By : ' mod='blockuserinfo'}{$sale_referer}



This adds a line in the header that reads Refered By : 1234 and is underneath the logged in customers name.

I intend to add this code to each sale in the database to calculate where the sales are coming from and add the sales per affiliate to calculate their commission each month.

My problem is the code shows up on the front page of my shop as I expected but whenever I navigate to another page away from the front page the referers number disappears and only Refered By : shows. This means that it is still using the same module because that is the only place I have Refered By :. It appears to me that this $smarty variable goes out of scope on every other page except the front page.

Any ideas on how I fix this or is there a better way to capture this number from the URL?

Link to comment
Share on other sites

Hi.

thanks for this info, which affiliates program (software) are you using with prestashop?
iv been playing with the Affiliates For All Module v1.0.0 module for the backend and the affiliates 1.2.1 for the frontend. but i just cant seem to get it working in the prestashop 1.4. i get errors in the backend aswell.

thanks

Link to comment
Share on other sites

  • 3 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...