Jump to content

Limit % discount to 1 product only


Noorlander

Recommended Posts

Hey,

 

I have created a voucher in the backend which can be used for 1 product only, called product "xyz".

When a client selects this product and enters the voucher reference, the % discount is correctly applied.

 

However, if the client selects 2 products "xyz" , the % discount is applied to both. I need the % discount to be applied to 1 product only, the second product should be paid full price.

 

In /classes/CartRule.php, i found this line:

 

 

// Discount (%) on a specific product

if ($this->reduction_percent && $this->reduction_product > 0)

{

foreach ($package_products as $product)

if ($product['id_product'] == $this->reduction_product)

$reduction_value += ($use_tax ? $product['total_wt'] : $product['total']) * $this->reduction_percent / 100;

}

 

 

 

1. Is this the correct line to modify?

2. How do i change it so the % discount doesnt apply "foreach" but only for one product "xyz"?

 

thanks

Link to comment
Share on other sites

Thanks Vekia, much appreciated

 

1. I'm not much of a developper, not really sure how to add a {break}, could you pls provide a sample

2. An alternative i thought of was this: devide the discount by the number of products. It works fine if i hardcode:

 

 

$reduction_value += ($use_tax ? $product['total_wt'] : $product['total']) * ($this->reduction_percent / 100)/4;

 

 

However, i'm unable to find how to reference the quantity selected; i tried $quantity, $cartProduct['quantity'].

 

Any ideas?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...