- Posts: 80
- Thank you received: 1
Re: Affiliate program for some products only
14 years 10 months ago - 14 years 10 months ago #30807
by seoweb
Affiliate program for some products only was created by seoweb
Hello,
I have the Business edition of Hikashop and would really need to enable Affiliate feature working for only products I want to promote and not for any sale within the website. I assume there is something to do with Hika's Affiliate plugin and A cart module. This could possibly be done using the logic:
or may be a string like prod=1 or prod=2 could be included in the affeliate link.
I will be happy to amend the core files to get it done, but not that good at Hika coding. I am sure a lot of people would like to see this implemented.
Any help will be highly appreciated.
SeoWeb
I have the Business edition of Hikashop and would really need to enable Affiliate feature working for only products I want to promote and not for any sale within the website. I assume there is something to do with Hika's Affiliate plugin and A cart module. This could possibly be done using the logic:
Code:
if ( prodict_id = '1' || prodict_id = '2' ) {
use affiliate plugin
}
else {
do not use affiliate plugin
}
or may be a string like prod=1 or prod=2 could be included in the affeliate link.
I will be happy to amend the core files to get it done, but not that good at Hika coding. I am sure a lot of people would like to see this implemented.
Any help will be highly appreciated.
SeoWeb
Last edit: 14 years 10 months ago by seoweb.
Please Log in or Create an account to join the conversation.
14 years 10 months ago #30833
by nicolas
Replied by nicolas on topic Re: Affiliate program for some products only
You would need to add your check in the file plugins/system/hikashopaffiliate.php in the onBeforeOrderCreate function.
In the $order variable, you should find the products in either $order->cart->products or $order->products.
so you could do something like that:
foreach($order->cart->products as $product){
if($product->product_id!=YY){
return true; //don't add the affiliate to the order
}
}
In the $order variable, you should find the products in either $order->cart->products or $order->products.
so you could do something like that:
foreach($order->cart->products as $product){
if($product->product_id!=YY){
return true; //don't add the affiliate to the order
}
}
Please Log in or Create an account to join the conversation.
14 years 10 months ago - 14 years 10 months ago #30857
by seoweb
Replied by seoweb on topic Re: Affiliate program for some products only
Thank you for your prompt reply!
I only want the commission to be calculated for products with IDs 1, 2, and 3.
How could the ready file look like?
Please advice.
Just noticed. The calculations of affiliate comission are not correct. If I sell the product for 5.00 and comission for this is 2.00 system gives 7.00 to the Affiliate. Strange....
I only want the commission to be calculated for products with IDs 1, 2, and 3.
How could the ready file look like?
Please advice.
Just noticed. The calculations of affiliate comission are not correct. If I sell the product for 5.00 and comission for this is 2.00 system gives 7.00 to the Affiliate. Strange....
Last edit: 14 years 10 months ago by seoweb.
Please Log in or Create an account to join the conversation.
14 years 10 months ago #30907
by nicolas
Replied by nicolas on topic Re: Affiliate program for some products only
It would be:
$orderClass = hikashop_get('class.order');
if(empty($order->cart->products)) $order->cart = $orderClass->loadFullOrder($order->order_id);
foreach($order->cart->products as $product){
if(!in_array($product->product_id,array(1,2,3))){
return true;
}
}
For the comission problem, that's already fixed on our end and will be in next version of HikaShop.
It comes from the line:
$order_price = $order->order_full_price;
which should be:
$order_price = 0;
in that same file.
$orderClass = hikashop_get('class.order');
if(empty($order->cart->products)) $order->cart = $orderClass->loadFullOrder($order->order_id);
foreach($order->cart->products as $product){
if(!in_array($product->product_id,array(1,2,3))){
return true;
}
}
For the comission problem, that's already fixed on our end and will be in next version of HikaShop.
It comes from the line:
$order_price = $order->order_full_price;
which should be:
$order_price = 0;
in that same file.
Please Log in or Create an account to join the conversation.
14 years 10 months ago - 14 years 10 months ago #30909
by seoweb
Replied by seoweb on topic Re: Affiliate program for some products only
The comission problem is solved with your fix. Thanx for this!
Last edit: 14 years 10 months ago by seoweb.
Please Log in or Create an account to join the conversation.
14 years 10 months ago - 14 years 10 months ago #30920
by seoweb
Replied by seoweb on topic Re: Affiliate program for some products only
After a quick test the plugin still adds an Affiliate comission to the product with id=4. May be i put the code in the wrong place?
Now it looks like this:
Now it looks like this:
Code:
function onBeforeOrderCreate(&$order,&$do){
$app =& JFactory::getApplication();
if ($app->isAdmin()) return true;
// add affiliate logic to specific products
$orderClass = hikashop_get('class.order');
if(empty($order->cart->products)) $order->cart = $orderClass->loadFullOrder($order->order_id);
foreach($order->cart->products as $product){
if(!in_array($product->product_id,array(1,2,3))){
return true;
}
}
// end of add affiliate logic to specific products
Last edit: 14 years 10 months ago by seoweb.
Please Log in or Create an account to join the conversation.
14 years 10 months ago #30932
by nicolas
Replied by nicolas on topic Re: Affiliate program for some products only
You put it at the correct place.
So there must be a problem with that code. You should put traces in it to see where is problem.
So there must be a problem with that code. You should put traces in it to see where is problem.
Please Log in or Create an account to join the conversation.
14 years 10 months ago - 14 years 10 months ago #30963
by seoweb
Replied by seoweb on topic Re: Affiliate program for some products only
Hello Nicolas,
Does this look ok?
Does this look ok?
Code:
// add affiliate logic to specific products
$orderClass = hikashop_get('class.order');
if(empty($order->cart->products)){
$order->cart = $orderClass->loadFullOrder($order->order_id);
}
foreach($order->cart->products as $product){
if(!in_array($product->product_id,array(1,2,3))){
return true;
}
}
// end of add affiliate logic to specific products
Last edit: 14 years 10 months ago by seoweb.
Please Log in or Create an account to join the conversation.
14 years 10 months ago #30964
by nicolas
Replied by nicolas on topic Re: Affiliate program for some products only
Hi,
This looks like the code I posted before apart from the fact that you added some brackets which don't change anything.
Does that work for you ?
This looks like the code I posted before apart from the fact that you added some brackets which don't change anything.
Does that work for you ?
Please Log in or Create an account to join the conversation.
14 years 10 months ago #30967
by seoweb
Replied by seoweb on topic Re: Affiliate program for some products only
Tested and works well. Was a bit confused with your comment that there is might be something wrong with the code.
Please Log in or Create an account to join the conversation.
3 years 8 months ago #348173
by Lumiga
Kind regards,
Lumiga
Replied by Lumiga on topic Re: Affiliate program for some products only
Hi Nicolas,
Does this code still worked with the latest version?
we would also like to indicate a number of products to for which no fee will be paid.
It would also be nice to have some extra code where we can set an minimum order amount.
So you only get a fee when the orders are above some amount.
Kind regards,
Lumiga
Does this code still worked with the latest version?
we would also like to indicate a number of products to for which no fee will be paid.
It would also be nice to have some extra code where we can set an minimum order amount.
So you only get a fee when the orders are above some amount.
Kind regards,
Lumiga
Kind regards,
Lumiga
Please Log in or Create an account to join the conversation.
3 years 8 months ago #348175
by nicolas
Replied by nicolas on topic Re: Affiliate program for some products only
Hi,
It still works but please note that it is some simplified solution.
This code will only add the affiliate fees to a order if all the products of the order are in the list of allowed products. Also, it doesn't handle variants.
A proper solution would handle the variants and calculate the affiliate fees based on the amount of the allowed products in the order and not the total of the order. And that's more complex to do.
It still works but please note that it is some simplified solution.
This code will only add the affiliate fees to a order if all the products of the order are in the list of allowed products. Also, it doesn't handle variants.
A proper solution would handle the variants and calculate the affiliate fees based on the amount of the allowed products in the order and not the total of the order. And that's more complex to do.
Please Log in or Create an account to join the conversation.
Time to create page: 0.277 seconds