Affiliate fee not registered

  • Posts: 44
  • Thank you received: 0
12 years 4 months ago #55635

I created an affiliate account a1 and set a custom fee and then created another account a2 and bought a product form a2 with the first account a1 as the partner. I then manually changed the order to confirmed. The order shows that a1 is the partner however the partner fee is 0. what am I doing wrong and how to fix it?

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
12 years 4 months ago #55741

Can you do a screenshot of the user edition page for the partner and of the Affiliate tab of the configuration so that we can see how you configured all that ?

Please Log in or Create an account to join the conversation.

  • Posts: 44
  • Thank you received: 0
12 years 4 months ago #55877

Here are the screenshots

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
12 years 4 months ago #55947

Hi,

Thank you. We were able to reproduce the problem.
Please download and install that new version of the affiliate plugin and it should work with your settings.

We'll add the modifications for next release.

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 44
  • Thank you received: 0
12 years 4 months ago #56009

ok thanks. while we are on the topic I have a question. if I create a hook for the before order create event and change the partner fees in the order object that is passed a s the parameter it would automatically change the partner fees or do I have to do something extra. also will that work for any of the other 3 hooks that accept an order reference as a parameter?

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
12 years 4 months ago #56050

You can use the onBeforeOrderCreate event yes. You should also do it for the onBeforeOrderUpdate event.
And make sure that the ordering of your plugin is bigger than the one of the affiliate plugin so that the affiliate plugin does not overwrite your value with the one it calculates.

Please Log in or Create an account to join the conversation.

  • Posts: 44
  • Thank you received: 0
12 years 4 months ago #56186

I diffed the new and old plugin and noticed "<?php defined('_JEXEC') or die('Restricted access'); ?>" is missing and a few other things. so is this normal or was it forgotten in the haste


Also how exactly do you change the partner fees in the order?

Last edit: 12 years 4 months ago by mohamed.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
12 years 4 months ago #56222

That's because it's the file from our internal SVN. The JEXEC code is added during the packaging process when we do a release.

Having it or not doesn't change anything for the plugin.

You can do the same as in our code...

$order->order_partner_price = $fees;

Please Log in or Create an account to join the conversation.

  • Posts: 44
  • Thank you received: 0
12 years 3 months ago #60298

apparently the problem still persists. I wrote:

$order->order_partner_price = SomeMethodWhichReturnsANumber();

I checked and the method does return the correct number and that this line is in fact executed.

My plugin has ordering 1 and your default plugin has ordering 0 which I assume means that my plugin works after yours so it should be ok.

Should I use the order class to save the order or what exactly

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
12 years 3 months ago #60365

That code should work.
Make sure that you also defined the onBeforeOrderUpdate event as I said and that you have the & before the $order in the function parameters, otherwise, the modification might not be taken into account.

Please Log in or Create an account to join the conversation.

  • Posts: 44
  • Thank you received: 0
12 years 3 months ago #60368

function onAfterOrderCreate(&$order,&$send_email){

//some checks here

$userClass = hikashop_get('class.user');
$user = $userClass->get($order->order_partner_id);

if(!empty($user->user_partner_activated)) {
$this->report(print_r($this->get_partner_fee($order->order_partner_id, $group, $order->order_id),true)); //this method runs and gives me visible output
$order->order_partner_price = $this->get_partner_fee($order->order_partner_id, $group, $order->order_id);

}
return true;
}

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
12 years 3 months ago #60421

One possibility is that the order is updated after your function leading to the affiliate plugin resetting the fees with the onBeforeOrderUpdate function.
That's why I told you to also implement it.

You should check on that.

Please Log in or Create an account to join the conversation.

  • Posts: 44
  • Thank you received: 0
12 years 3 months ago #60436

I noticed that you are not saving the order after dispatching the onAfterOrderUpdate or the onAfterOrderCreate in the order.php file. The only call to $orderclass->save() is after the onBefore... methods. I do the actual changes in the onAfter order methods so as to be the final changer. is that what I do wrong. should I do the change in partner fees in the onBefore methods

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
12 years 3 months ago #60443

I'm sorry I didn't see that you were mentioning the onAfterOrderUpdate in your previous post.

Of course, the order is saved between the onBeforeOrderUpdate and the onAfterOrderUpdate triggers.
So if you change the $order variable in the onAfterOrderUpdate trigger, it won't do anything. That's normal.
I had actually told you in a previous post to use onBeforeOrderUpdate, that's why I got confused as I thought that you would be using it.

Please Log in or Create an account to join the conversation.

  • Posts: 44
  • Thank you received: 0
12 years 3 months ago #60456

I fixed it now and it works. I just wanted to be the last person to edit the fee so I thought if it I put the code in the onBefore something could override it in the onAfter giving me the idea to put the code in the onAfter methods.

Thanks for your help :)

Please Log in or Create an account to join the conversation.

Time to create page: 0.057 seconds
Powered by Kunena Forum