zwaem Posted March 19, 2022 Share Posted March 19, 2022 (edited) Hi, I would like to apply discount codes only on items that are in stock. Since it is not possible to configure this condition in the backend, it is necessary to create the condition manually. Can someone tell me in which file I have to insert the code and and how the code must look? Thanks in advance! Edited March 19, 2022 by zwaem (see edit history) Link to comment Share on other sites More sharing options...
james369 Posted March 19, 2022 Share Posted March 19, 2022 Usually the file is in [themes/classic/templates/checkout/_partials/cart-voucher.tpl] cart, but here is a dilemma. Suppose you have two products in cart, one of which has 100 in the stock and the other has less than 10. How can it be applied in your case ? Link to comment Share on other sites More sharing options...
ps8modules Posted March 20, 2022 Share Posted March 20, 2022 (edited) Everything is possible. You can override CartRule.php and change the checkValidity function. Here you can check the quantity in stock and if one item does not have enough, for example, display an error and do not apply the code. Another option is a custom module and a hook that would check the quantity and display the text below the voucher insertion. Edited March 20, 2022 by 4you.software (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now