Skip to main content

Automatically inserting a flash sale icon, a crossed-out price, or a % discount, etc.

It is possible to condition the display of certain elements in your block based on variables/information present in your product feed.

Sample use cases and code to be integrated into templating:

  • The “flash sale” alert: insert a “flash sale” icon as soon as the offer is set up.

Code: {{#if (eq venteFlash 'true')}}<img src="http://votreurlimagepictoventeflash" /> {{/if}} 

Tips: If you use more than one product block at the same time, with a risk of having a flash sale for some products and not others: To keep them aligned, provide a space the same size as your flash sale icon for products not included in the flash sale. For example, for an icon equivalent to one row: 

 {{#if (not (eq venteFlash 'true'))}}<br /> {{/if}}

  • Indicate the volume of stock remaining in real time when it gets close to running out and reaches a previously defined threshold: “Warning: Only 12 left in stock!” 

Example when the stock indicated in the feed is less than 20 units. When it is above 20 units, the message does not appear.

Code: {{#if (lte custom.0.stock 20)}} PLUS QUE {{custom.0.in_stock}} EN STOCK{{/if}}  

  • Insert a “Discount %” sticker if the “discount” variable in your feed is greater than 0

Code : {{#if (gt custom.0.reduction 0)}} - {{custom.0.reduction}} %{{/if}} 

Find all the possible conditions that can be inserted into your source code when you create your “Templating” content: