Skip to main content
Show customers that a product earns bonus points or store credit right now, and how long they have left. This recipe renders two badges on the product page:
  • A campaign pill, such as 2× points this weekend
  • A countdown, such as Ends in 2d 14h, that updates every minute
Both badges only appear while an active campaign covers the product, and disappear when it ends.

1. Add the markup

Place this where you want the badges to appear in your product template, for example above the product image or next to the price:
The hidden attribute keeps the badges out of sight until a campaign is found. If your theme CSS sets display on .bonus-campaign, add [hidden] { display: none !important; } so the attribute still wins.

2. Add the script

Add this to your product template (or your theme’s JavaScript). Replace the {{ product.id }} Liquid tag if you render the product ID another way.
Style the two elements to match your theme; the bonus-campaign__pill and bonus-campaign__timer classes are there for that.

Showing the boosted amount

To add a line like “Earn 500 points with this purchase, usually 250”, pair this recipe with getProductEarningValue. Only show the “usually” wording when its bonusApplied is true.

Notes

  • The pill text is yours to write. campaign.multiplier gives you the number; the campaign name from the Mage admin is also available if you prefer to display that.
  • The countdown is based on endsAt, which is a UTC timestamp, so it is correct for every customer regardless of their timezone.
  • When the campaign has a required product (see requiredProducts), you may want to change the wording until it is in the cart, for example “Add the gift box to unlock 2× points”.