Forum

Thread tagged as: Question, Shop

Perch Shop promotion panel display

Is there are way to detect if a promotion exists or is active so that the promotion code panel in the cart can be shown or hidden on that basis?

Robert Sinclair

Robert Sinclair 4 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You should be able to test it with a perch:if in the template. Have you tried that?

Sorry, I had got to that but what template ID would I test for?

Drew McLellan

Drew McLellan 2638 points
Perch Support

What does <perch:showall /> give you?

It shows - 'discount_code', which registers the actual code, and 'promotions', which is an object with the promotion details. There are other other IDs like 'total_items_discount' and 'total_items_discount_formatted', which are simple values calculated once the code is input.

'promotions' is the most promising but doesn't show any details until a valid, active promo code is applied. These details include [promoActive], which is the sort of thing I'm after.

Is that enough info?

For the moment it looks like the answer is no to the original question.


An interesting side discovery for anyone that's looking at discounts is that you can test for a discount code being input and if it's incorrect or not active, you output feedback for the user:

<perch:if exists="discount_code AND !promotions">Sorry that isn't accepted.</perch:if>

Many thanks