To add a custom badge to a product in Shopify, you can use the product tags feature. Here’s how:
- Go to the Products section of your Shopify admin and select the product that you want to add the badge to.
- In the Product Details section, scroll down to the Tags field and enter the tag that you want to use for the badge. For example, you might use a tag like “Sale” or “New.”
- Save the product.
- To display the badge on your product pages, you’ll need to add some code to your theme. In the Themes section of your Shopify admin, click the “Actions” button next to the theme that you want to edit, and then select “Edit code.”
- In the theme code editor, open the product-template.liquid file. This is the template file that controls the layout and appearance of your product pages.
- In the product-template.liquid file, locate the section of the code where you want to display the badge. This could be in the product description, the product image, or any other part of the page.
- To display the badge, you’ll need to use an “if” statement to check whether the product has the tag that you added in step 2. You can do this using the following code:
{% if product.tags contains 'tag-name' %}
<div class="badge">Badge Text</div>
{% endif %}
Liquid
Replace “tag-name” with the name of the tag that you added in step 2, and replace “Badge Text” with the text that you want to display in the badge. Save the changes to the product-template.liquid file and preview your product pages to see the badge displayed on the products that have the tag.