How-to: Setup Sale Badges on Product and Search page
This guide walks you through integrating a custom snippet to display manual sale badges on your Shopify store.
1. Create the Snippet File
- Navigate to your Shopify admin dashboard.
- Go to Online Store > Themes > Actions > Edit Code.
- Under the Snippets folder, click Add a new snippet.
- Name the snippet:
pe-manual-sale-tag-integration
- Paste the following code into the new snippet file and save:
{% if product %} <div sale-tag-slug="{{ product.handle }}" data-handle="{{ product.handle }}" data-price="{{ product.price }}" data-price-min="{{ product.price_min }}" data-price-max="{{ product.price_max }}" data-price-varies="{{ product.price_varies }}" data-compare-at-price="{{ product.compare_at_price }}" data-compare-at-price-min="{{ product.compare_at_price_min }}" data-compare-at-price-max="{{ product.compare_at_price_max }}" data-compare-at-price-varies="{{ product.compare_at_price_varies }}" {% for field in product.metafields.discoapp %} data-{{ field | first }}="{{ field | last }}" {% endfor %} > </div> {% endif %}
2. Update card-product.liquid
- Locate the
card-product.liquid
file under the Snippets folder. - Add the following line above the
card__badge
section:
{% render 'pe-manual-sale-tag-integration', product: card_product %}
3. Update product-thumbnail.liquid
- Open the
product-thumbnail.liquid
file under the Snippets folder. - Add the following line below the
product-media-container
section:
{% render 'pe-manual-sale-tag-integration', product: product %}
4. Save and Preview
- Save all changes.
- Preview your store to confirm that the manual sale badges are displaying correctly on product cards and thumbnails.
This integration ensures dynamic sale badge display based on product data and metafields.