Developer forum

Forum » Templates » Invalid discount code

Invalid discount code

Anders Ebdrup
Anders Ebdrup
Reply

Hello,

 

I am trying to tell the user that an entered discount/voucher code is invalid, but say we have 10 % on all items in the shop and I am now entering an invalid discount code.

How can I tell the user that the discount code does not exists? As I cannot base my check on whether a discount exists because we already have a discount in the cart and I cannot find a template tag telling that the discount code is invalid.

I am working with DW 9.

 

Best regards,

Anders


Replies

 
Nicolai Pedersen
Reply

Hi Anders

We could maybe add that. But basically Dynamicweb do no checks on the code. It is a simple property on the order, and then the discount module might pick it up and use it for something. For some cases the voucher code does not exist in any module, but simply as a string on the discount it self.

What we could do, was to add a property on the order renderer indicating if the voucher code is in any of the voucher lists - but that would not be the full truth because of that other scenario.

BR Nicolai

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

That would be a nice Feature request.
We have this problem andwe had to deal with it with a custom code. Therefore it is possible. The downside of our approach is that we will have to maintain the code everytime you guys make a change to the discounts/vouchers logic. Look at opther solutions. If they make this check, we should definitely have it as standard.

If you want, I can share our code. But I think Imar has a better/newer version of it.

Thanks,

Adrian

 

 
Hans Ravnsfjall
Hans Ravnsfjall
Reply

Hi

Is there any news on this? I want to give the visitors a feedback of invalid cupon, if they enter an invalid cupon code.

/Hans

 
Nicolai Pedersen
Reply

Yes, it has been implemented.

When you create a discount you can mark it as "Check for validation reason" and then implement a loop of validations in the cart template - an example in the docs:

https://doc.dynamicweb.com/documentation-9/ecommerce/payment-shipping/discounts-offers#10535

 

You must be logged in to post in the forum