I want to set up individual commission percentages for individual users.

I go to a users page and under the Commissions field I see this:

The commission percentage for this user (number only). Leave blank to use either product or global commissions.

This indicates to me that the number that I type in will result in a percentage commission that will be credited to the user.
This is not what happens though.

Setting the value here to "15" results in a commission of $0.15 not 15% of the product price.

This does override the commission set @ http://mysite.com/admin/store/affiliate/commissions which is good, but it does not calculate it as a percentage.

I checked the issues queue and it looks like no one has identified this as an issue before.
So it makes me think that I am missing something.
What am I doing wrong?

CommentFileSizeAuthor
#9 uc_affiliate2-898882.patch3.61 KBdarktygur-1
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

darktygur-1’s picture

The problem is with _uc_affiliate2_get_commission(). It used to return a "Commission percentate as a value between 0 and 1" (the documentation for that function needs to be updated). Since #715728: Fixed commissions (commit #342360), it now returns either just a number for fixed commissions, or a number with a percent sign for percentage commissions. It looks like nobody noticed the piece in the function that takes the user's commission amount into consideration:

  if ($account->commission && $level == 1) {
    return $account->commission / 100; // we have a commission percentage defined specially for this affilate
  }

I would've made a patch, but I ran out of time. If nobody does it in the meantime, I'll make one next week. I would fix it by updating the description for that user field to say that a fixed commission or a percentage with percent sign may be entered. Then _uc_affiliate2_get_commission() will be able to return the user's commission with no changes, if it finds a value (and that function's documention should be updated). I'd also add an update hook to the .install file to add percent signs to user commissions that may already be present.

I think that would take care of it.

dadderley’s picture

@darktygur
Thanks for your reply.
I will take a look at the code on Monday morning and see what I can do.

Dokuro’s picture

Did anyone ever get a patch for this?

dadderley’s picture

A patch would be nice.

Dokuro’s picture

I agree.... ;-)

Dokuro’s picture

So, a quick fix for this, sure this isn't the best solution, but it does what I want it to do.

Change : return $account->commission / 100;

To: return $account->commission. '%';

I am sure we will be putting more love into this module as soon as my CTO has his kid and things settle down for him.

Again, thanks for the great module!

dadderley’s picture

This worked perfectly on my test site.
Now my client will be happy.
Thanks

Dokuro’s picture

I wouldn't mark this as fixed though, as it seems like nothing is really working based on roles through all the settings.

darktygur-1’s picture

Status: Active » Needs review
FileSize
3.61 KB

What does this particular option have to do with roles?

In any case, my patch is attached. While I was at it, I added some code to validate the commission field.

univate’s picture

This patch looks good to me and makes sense, will test it properly though.

bojanz’s picture

Status: Needs review » Fixed

Committed. Can't be worse than the current code, and the change does make sense.

Thanks, darktygur.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.