Developer forum

Forum » Templates » Is it possible to remove discount code with template code?

Is it possible to remove discount code with template code?

Hans Ravnsfjall
Hans Ravnsfjall
Reply

Hi

is it possible to remove one or all discount codes with template code?

If so, how can this be done?

/Hans


Replies

 
Nicolai Pedersen
Reply

Not sure I understand. Can you ellaborate?

 
Hans Ravnsfjall
Hans Ravnsfjall
Reply

When an ordersdiscount is set and configured to validate for errors - and the visitor enters a code that is valid and or invalid, the value keeps "hanging" no mather what stage at the checkout the visitor is at.

If/When the visitor enters an invalid code - we only want to show an error message briefly. And we want to do so without setting cookies etc, and there i was wondering if we can just display the error message, and then remove the invalid value from the session.

/Hans

 
Nicolai Pedersen
Reply

If you just do not set the value of the voucher field when there are validation errors, that should be it...

 
Hans Ravnsfjall
Hans Ravnsfjall
Reply

Thank you Nicolai. I am not shure we are on the same page.

The visitor has to post the voucher code for us to validate it?

I have attached a template, that shows what I am trying to do. I am trying to distinguish between 3 scenarios.

Scenario 1 - the visitor has not entered any voucher code => render the voucher field

Scenario 2 - the visitor has entered an invalid voucher code ) => render voucher field along with an error message saying voucher code is invalid. Want to show this for a coulple of seconds, and then dissappear and only to reapear if they again enter an invalid voucher code.

Scenario 3 - The visitor has entered a valid voucher code => subtract the voucher amount, and hide the voucher field.

 

The problem i have, is with scenario 2. I can get the error message to show based on the logics in the attached template, but it keeps showing - even if i reload the page.

 

/Hans

 

You must be logged in to post in the forum