Jump to content

HOWTO: redirect affiliate links to cart instead of homepage


Recommended Posts

The default behavior of * is to set a cookie with the affiliate id, and then send the user to the homepage. This prevents being able to link to a specific product or product group, and may be a bit confusing. Below, I have an * which, in addition to aff, also accepts gid or pid in the URL, and redirects to the appropriate group or product, respectively. gid takes precedence over pid.

 

*:

<?php

define("CLIENTAREA",true);

include("dbconnect.php");
include("includes/functions.php");

if (isset($aff)) {
       update_query("tblaffiliates",array("visitors"=>"+1"),array("id"=>$aff));
       setcookie("WHMCSAffiliateID", $aff, time()+90*24*60*60);
}

$params = '';
// redirect to product group
if (isset($_GET['gid'])) {
       $gid = (int)$_GET['gid'];
       if ($gid > 0) {
               $params = '?gid=' . $gid;
       }
}
// redirect to product
elseif (isset($_GET['pid'])) {
       $pid = (int)$_GET['pid'];
       if ($pid > 0) {
               $params = '?a=add&pid=' . $pid;
       }
}

header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $CONFIG['SystemURL'] . '/cart.php' . $params);

?>

Link to comment
Share on other sites

  • 3 weeks later...

I know its been 3 weeks since this was posted (and thank you very much freedombi for sharing it) but....

 

Has anyone had any success in using this? and to what extent?

 

Reason im asking is that i now have the need for something like this, ideally a direct group link which would contain the group id, affiliate id and promotion code, basically something like:

 

http://www.mydomain.com/cart.php?aff=001&promocode=coupon&gid=0000000003

 

Any suggestions are welcome, cheers.

Link to comment
Share on other sites

  • 1 year later...

Can you provide an example of how you used this, please?

 

 

 

 

The default behavior of * is to set a cookie with the affiliate id, and then send the user to the homepage. This prevents being able to link to a specific product or product group, and may be a bit confusing. Below, I have an * which, in addition to aff, also accepts gid or pid in the URL, and redirects to the appropriate group or product, respectively. gid takes precedence over pid.

 

*:

<?php

define("CLIENTAREA",true);

include("dbconnect.php");
include("includes/functions.php");

if (isset($aff)) {
       update_query("tblaffiliates",array("visitors"=>"+1"),array("id"=>$aff));
       setcookie("WHMCSAffiliateID", $aff, time()+90*24*60*60);
}

$params = '';
// redirect to product group
if (isset($_GET['gid'])) {
       $gid = (int)$_GET['gid'];
       if ($gid > 0) {
               $params = '?gid=' . $gid;
       }
}
// redirect to product
elseif (isset($_GET['pid'])) {
       $pid = (int)$_GET['pid'];
       if ($pid > 0) {
               $params = '?a=add&pid=' . $pid;
       }
}

header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $CONFIG['SystemURL'] . '/cart.php' . $params);

?>

Link to comment
Share on other sites

<?php

define("CLIENTAREA",true);

include("dbconnect.php");
include("includes/functions.php");

if (isset($aff)) {
       update_query("tblaffiliates",array("visitors"=>"+1"),array("id"=>$aff));
       setcookie("WHMCSAffiliateID", $aff, time()+90*24*60*60);
}

$params = '';
// redirect to product group
if (isset($_GET['gid'])) {
       $gid = (int)$_GET['gid'];
       if ($gid > 0) {
               $params = '?gid=' . $gid;
       }

header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $CONFIG['SystemURL'] . '/cart.php' . $params);

}
// redirect to product
elseif (isset($_GET['pid'])) {
       $pid = (int)$_GET['pid'];
       if ($pid > 0) {
               $params = '?a=add&pid=' . $pid;
       }

header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $CONFIG['SystemURL'] . '/cart.php' . $params);
}

// redirect domain
else
{
header("HTTP/1.1 301 Moved Permanently");
header("Location: ".$CONFIG["Domain"]);
}
?> 

Link to comment
Share on other sites

I haven't really done much with coupons or promo codes, myself. The question is how does it register that you have a coupon? I'm guessing it's not passed in the URL. If it's stored as a cookie, then you would just set the cookie from within the script. If it's just submitted as part of a form on one page, then I don't know if it's possible.

Link to comment
Share on other sites

What would really be spiffy is some smarty logic that helps them build custom links. Much like CRE Loaded Cart Affiliate Manager build custom links. In that cart, the store admin can BUILD links, let the affiliate search for a product and display the custom affiliate link or show a list of available banners OR what I would like to see from idevaffiliate is a way whmcs admins could create text box banners like google.

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 years later...
  • 2 months later...

How can I make an Affiliate Banner contain a Promo Code? When my affiliates copy our banners html and paste in on theirt website, it does not include any discount for the end customer... We want the affiliate banners to contain discount promo codes so the affiliate earns commission and the customer gets a discount..

 

I tried this but it does not add the discount code to the cart....

 

<a href="http://atmohost.com/[AffiliateLinkCode]/cart.php?promocode=migone"><img src="http://www.atmohost.com/templates/BlueHost/html/images/affbanners/atmo-affiliate1.jpg" width="200" height="300" border="0"></a><br>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated