Hi All,
Please I need help , I tried to add a customer badges on my perfume store to show a text on top of the card but it won’t work ?
- Add a Product Metafield in Shopify:
- Go to your Shopify admin.
- Click on Settings at the bottom-left corner.
- In the Settings menu, click Custom data (or Metafields).
- Under *Products, click on *Add definition.
- Fill out the details:
- Name: Inspiration Text Badge
- Namespace and key: custom_badge.inspiration
- Description: (Optional) Add description if needed.
- Content type: Choose Single line text.
-
Click Save.
-
In the Sections or Snippets folder, find a file that contains the product card template, like product-card.liquid or product-grid-item.liquid.
liquid
{% if product.metafields.custom_badge.inspiration %}
{{ product.metafields.custom_badge.inspiration }}
{% endif %}
Step B: Modify the Product Page Template (to display badge on product pages)
liquid
{% if product.metafields.custom_badge.inspiration %}
4. Add Styling to the Badge:
To style the badge, you’ll need to add some CSS:
- In the Assets folder, find your theme’s CSS file (theme.css, style.css, etc.).
- Add the following CSS to style the badge:
css
.custom-text-badge {
background-color: #f8e71c; /* Customize background color /
color: #000; / Customize text color */
padding: 5px 10px;
border-radius: 4px;
font-size: 14px;
font-weight: bold;
display: inline-block;
margin-top: 10px;
}
Please note products_liquid there are 1-5 pages , I can’t find the default one check attached