Affiliate v2

Contrib type: 
Module
Moderation: 
Not ready for moderation
Status: 
Uploaded for testing
Compatibility: 
Ubercart 1.x
Latest version: 
v2

This module was adapted by Bojan Živanović (email: bojanz@gmail.com) @ http://vividintent.com from the original Affiliate module by jhuckabee.

Originally multiple people wanted to pool together and sponsor this module. No one followed through unfortunately so if you'd like to support continuation of this module and add features, please email bojan and then continue this increasingly important module.

This new and improved affiliate module has the following features:

Granular tracking
-User based tracking
-Role based tracking

Ability to create affiliate links:
-both text and image
-Export to CSV or HTML
-Product level link generation (e.g. generate a link for the actual product vs just the website)

Cookie option
-have the ability to add cookies so that affiliates get credit for return visits even though they didn't go through original affiliate link
-Option to set amount of time (e.g. 3 months)

Dashboard
-Easy customer dashboard (with div's so they're themable)

and more!

Hope you enjoy.

Aaron Schiff
Ecopaper.com

VERSION 01
-Fixes bug that gives commission on whole sale as opposed to one product




Re: Affiliate v2

Thanks Aron, fantastic stuff! Will be checking it out soon!

Cheers,
G

ClipGlobe - World Travel

Just so everyone knows

this module is a tough time with very little documentation.

Re: Just so everyone knows

Easy as pie! Thanks Aron.

features

does this module have all the same features of the old one. specifically the sub-domain thing. other than the new features you added of course.

Reporting a typo?

Hey, folks. I was referred here by Ryan and am just checking out the module here for the first time. I'm really excited about it!

I noticed a small typo -- user/%/affiliate has the text "Links to Ecopaper" when it should be something like "Links to this site". Sorry, I'd submit it as a patch, but don't know how to do that (or whether this is the best place to report it -- I didn't see an issues queue).

Cheers,

--Tom Geller

Is this compatible with Drupal 6.x

I am using Drupal 6.x and am really looking forward to using this. is this possible?

Re: features

We changed subdomain to having domain.com/affiliate, however the functionality is still there and can be done with some tweaking.

Really interested in module..

I'm curious what the "Moderation:
Failed code review" means?

issue with the math

i just upgraded to this version of the affiliate module. first i ran into an error when trying to run a test order through. it had to do with an extra debug line "dsm($product);" from what i understand that only has to do with debuging.

i also changed the language where it said "Links to Ecopaper" i changed it to "Links to Copy" i'm not sure what really should be there, thats just what i put.

now i ran into another problem...

i figured out that the commission is only paid for quantity 1 of each item. if someone buys 3 of an item. the affiliate only gets paid the commission on the price of 1. i don't really know php at all so i don't know how to fix the problem. could someone point me in the right direction?

also where it displays the commission info in user/%/affiliate/commissions it shows the total price after shipping. i think that the commission should be paid on the total before shipping, so it shouldn't show the final total b/c it makes it confusing to the affiliate.

If anyone could help me out on this it would be greatly appreciated.

Hi Zach, I'm looking into

Hi Zach,

I'm looking into the problem where commission is only paid for the first item.

As for the total price after shipping, that would cost money. If you guys want to help support this module, please feel free to donate via paypal and i can pass this off to my developer who can get this done asap.

https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=238...

Basing commission on # of products sold

We're looking at starting an affiliate program where X number of products sold gets a free product for the affiliate. At its simplest, we just need to have it so people can sign up and get an affiliate code, grab links/banners, and then be able to keep track of their sales so we can manually give them a discount coupon when they sell X products.

So it sounds like there would need to be some kind of feature added to have the affiliate program optionally based on # of products sold rather than amount of sale. If you're accepting bounties for features like this, can you let me know what kind of donation you'd be looking for?

Commission on all items

I had to edit uc_affiliate_order() in order to get it to work at all. For me, I didn't need the "Find all affiliates related to order" other than those that were upline as affiliates. I changed the function as follows, and is working for me:

<?php
function uc_affiliate_order($op, $order, $status) {
  global
$user;
  if (
$op == 'update' && $status == variable_get('affiliate_commission_order_status', 'completed')) {
   
$total = 0;
    foreach (
$order->products as $product) {
       
$product_total = $product->qty * $product->price;
        
$total = $total + $product_total;
    }
   
$affid = _uc_affiliate_get_user($user->uid);   
    if(
$affid != 0) {
       
// write commission records
       
$affs = _uc_affiliate_get_upline_ids($affid);

        for (
$i=0; $i<count($affs); $i++) {
           
$aff = $affs[$i];
           
$level = $i+1;
           
$comm_pct = _uc_affiliate_get_commission_percentage($level);           
            if (
$comm_pct>0) {
             
//TODO should this be rounded to nearest penny???
             
$comm = $total * $comm_pct;
             
$note = t('Level @level commission of @percent% recorded for affiliate @affiliate', array('@affiliate' => $aff, '@percent' => $comm_pct*100, '@level' => $level, '@commission' => uc_currency_format($comm), '@ordertotal' => uc_currency_format($total), '@firstname' => $order->billing_first_name, '@lastname' => $order->billing_last_name));
             
db_query("INSERT {uc_affiliate_commission} (order_id, aid, commission, commission_notes) VALUES (%d, %d, %f, '%s')", $order->order_id, $aff, $comm, $note);
             
uc_order_comment_save($order->order_id, $user->uid, $note);
             
uc_affiliate_add_count($aff, 0, 0, 1);
            }
        }
     }
  }
}
?>

Re: Commission on all items

new version should have this fixed.

Commission

The commission override inside the user profile page doesn't work. Probably a good thing though, as the user has the ability to edit their own commission level.

I've noticed several problems and have worked fixes for some of them. I'm under a deadline that doesn't allow me to code them in a way to be transferred here. I'm having to do it very specific to the installation I'm working on. After the deadline, I'll be more than happy to outline some of those and provide solutions. I'm kinda new to this site, is this post where I should put those? Or do I post them under a "support request"?

Hi jgross, Feel free to post

Hi jgross,
Feel free to post any suggestions/code changes you might have here, or email me at bojanz@gmail.com.
I have been a bit tight on time myself, but plan to devote more time to the module, and create a home for it at drupal.org

Stay tuned.

Re: Hi jgross, Feel free to post

Does anyone know where the admin can set the Commision rate?
And why an Affiliate Actor can set under my account:
"Affiliate Commission Settings
Commission:

The commission percentage for this user (number only)."

I am a little bit confused

MfG
Passer

Bug fixes, improvements, and new commission by product feature

I've attached some work I've done on the module this afternoon.

There was a bug that allowed users to adjust their own commission percentages (yikes!). I've added a new permission 'adjust user commissions' to disallow that.

I cleaned up some misspellings and text. If affiliate depth is set to 1, now affiliates do not see "downline" and "upline" in their affiliate center.

In addition I've added a feature that allows you to set commission for each product. If it's set, it'll override the store wide commissions for that product. It can be set under a local tab on the product edit page. I've added a table to my database to hold this data, but I didn't have time to muck about with the module's install file, so you'll have to execute this yourself on your test DB:

CREATE TABLE IF NOT EXISTS `uc_affiliate_product_commission` (
  `nid` mediumint(9) NOT NULL,
  `commission_structure` longtext NOT NULL,
  PRIMARY KEY  (`nid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

Hope some people can test these changes and let me know if there are any problems. I tested it in my use case (1 level of depth), but haven't tested every possible configuration.

AttachmentSize
uc_affiliate_02.zip37.38 KB

New version

I am attaching the new version of the module.
I've took davegan's version, added his extra table to the install code, fixed the uninstall code, and renamed the module to uc_affiliate2.
This will allow it to be submitted to drupal.org

You should uninstall the old module before you install this one, since it's technically a new module.
However, the tables haven't changed, so you can rename your old ones from uc_affiliate_* to uc_affiliate2_* or just reinsert the data, and nothing will be lost.

AttachmentSize
uc_affiliate2.zip22.02 KB

Drupal home

This module now has a home at:
http://drupal.org/project/uc_affiliate2

I am attaching the version listed as 1.0 there.
Compared to the previous archive, it has a bug fixed where the affiliate urls were wrong (affiliates/ instead of affiliate/)

AttachmentSize
uc_affiliate2.zip22.06 KB

1.1 released

Released v1.1 fixing an SQL Injection vulnerability.

Attaching it here.

AttachmentSize
uc_affiliate2.zip22.19 KB

a little help :)

Hi all!

I'm so sorry, but I'm so lost with this modul, could someone give me a bit of help? How can I add new affiliates, and give them link so they can send the new customers to the site?
I saw the affiliate center button under my personal data, but when i click on for example, "click here for product links" i get a blank page Smiling I also found the affiliate modul under moduls, but I haven't seen anything like these things there either.

I tryed to find the answer elsewhere, couldnt Smiling

Thank you for your help,
Regards,
fulee