Creating a voucher applicable only on products belongs to selected category and doesn't apply on products on sale. if we add the voucher in cart whose contain only the product sale, an error message popup (That's OK) but if the cart contain another product doesn't belong to the selected category, we can apply the voucher (NOK) instead the value of discount is 0 (OK).
An error message pop up saying "you cannot use this voucher on products on sale"
Steps to reproduce the behavior:




Screenshots
https://drive.google.com/file/d/1wzBKm-ltqVdo35Cihv34lgFMQSxHR8ha/view
Hi,
i was investigating this issue and found the problem in CartRule.php method checkValidity.
There is a loop that already skips the error message when there is another product in the cart where the reduction does not apply.
`if ($this->reduction_exclude_special) {
$products = $cart->getProducts();
$is_ok = false;
$has_already_reduced_product = false;
foreach ($products as $product) {
if (!$product['reduction_applies']) {
$is_ok = true;
break;
}
}
if (!$is_ok) {
return (!$display_error) ? false : $this->trans('You cannot use this voucher on products on sale', [], 'Shop.Notifications.Error');
}
}`
Not sure if this is the right place to fix this issue but i would think that it should check if there is already any product in the cart where the reduction is applied
Hello @kevin0x90
If you have already fixed it on your end, please do send us a pull request!
Thank you
@hibatallahAouadni i didn鈥檛 fixed it yet, first I wanted to make sure I identified the correct location a fix would be appropriate at. For example one could argue this is not the right place and it should be fixed way earlier in the location reduction_applies is set. I would prefer this approach but I鈥檓 not that familiar with the architecture of the codebase yet. How about your opinion / view on this?
Hello @kevin0x90
Well this issue is in the Backlog, so let's wait for the developers to try to fix it.
Cause I'm not an expert :wink: and I don't want to give you a false statement :slightly_smiling_face:
Thanks!