Jump to content

Apply discount code only for items in stock [PS 1.7.6.5]


zwaem

Recommended Posts

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 by zwaem (see edit history)
Link to comment
Share on other sites

  • zwaem changed the title to Apply discount code only for items in stock [PS 1.7.6.5]

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

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 by 4you.software (see edit history)
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...