Ubercart Affiliate Links Directly to Checkout with Product Already Added to Cart

I ran into a problem today that turned out to be really easy to fix.  I thought I would post it so I didnt forget :).

I want to link to a website, add a product to the cart, go to the checkout page, AND let this link be an affiliate link... all in one fail-swoop.

What you will need

I'm using Ubercart and Affiliate2 modules with Drupal 6.  I'm not going to go over setting up ubercart or affilate modules so you'll have to figure that out on your own.

Be sure to enable "cart_links" module included with ubercart.  This will allow you to create a link that auto-adds a product to the users cart.

My Setup

I have a product with node-id 84.  I also have a user who will be my affiliate with user-id of 3.

Affiliate links

A simple affiliate link looks something like this: www.yoursite.com/affiliate/[user-id]/[landingpage] .  If I wanted to end up on the product page after I linked to the site, I would fill in the [user-id] with the number 3 and [landingpage] with the url of "node/84".

The affiliate url would look like so: www.yoursite.com/affiliate/3/node/84 .  This DOES NOT add the product to the cart though, it just makes it so the affiliate (user 3) gets paid if the browsing user buys something.

Cart Links

Cart links are pretty simple also.  Go to www.yoursite.com/admin/store/help/cart_links to read the help on them.

In my case, a cart link to add my product to the cart and then go to the checkout page would be: yoursite.com/cart/add/e-p84_q1-imarketing_training?destination=cart/checkout . 

  • The "e" empties anything that user may have had in the cart
  • The p84 means add product with node-id of 87 to the cart
  • the q1 means I only a quantity of 1 added to the cart.
  • the imarketing_training means I want the "cart link" tracked with the name "marketing_training"
  • The destination= just lets me tell it where to go after it adds that crap the cart... in the is case it goes to www.yoursite.com/cart/checkout

Both Together

So lets put both of them together:

www.yoursite.com/cart/add/e-p84_q1-imarketing_training?destination=affiliate/3/cart/checkout

TA-DA!!!  An affiliate link that adds product 84 to the cart and the user ends up at checkout....

Isn't ubercart uber-wonderful!

Post new comment