Putting a label on products when they are showing on any page

Solved

Putting a label on products when they are showing on any page

robertsolcan
Excursionist
31 0 2

Screenshot 2024-08-12 at 14.01.50.png

Hello! I need some help with customising our product box, so that in the top left corner it should be a little box in which our customers will see which tehnology we are using for the product. I also created a metafield, named Tehnology, in which i wrote down the technologies they use.

Accepted Solution (1)

GTLOfficial
Shopify Partner
444 89 87

This is an accepted solution.

Hello 
@robertsolcan 
here is a code 

step 1 Go to Online Store------>     Edit code----------------> go to file "card-product.liquid"  line number  516 to 532
find this code

 

 

<div class="card__badge {{ settings.badge_position }}">
          {%- if card_product.available == false -%}
            <span
              id="Badge-{{ section_id }}-{{ card_product.id }}"
              class="badge badge--bottom-left color-{{ settings.sold_out_badge_color_scheme }}"
            >
              {{- 'products.product.sold_out' | t -}}
            </span>
          {%- elsif card_product.compare_at_price > card_product.price and card_product.available -%}
            <span
              id="Badge-{{ section_id }}-{{ card_product.id }}"
              class="badge badge--bottom-left color-{{ settings.sale_badge_color_scheme }}"
            >
              {{- 'products.product.on_sale' | t -}}
            </span>
          {%- endif -%}
        </div>

 

 


and replace with this one

 

<div class="card__badge {{ settings.badge_position }}">
            {%- if card_product.available == false -%}
              <span
                id="NoMediaStandardBadge-{{ section_id }}-{{ card_product.id }}"
                class="badge badge--bottom-left color-{{ settings.sold_out_badge_color_scheme }}"
              >
                {{- 'products.product.sold_out' | t -}}
              </span>
            {%- elsif card_product.compare_at_price > card_product.price and card_product.available -%}
              <span
                id="NoMediaStandardBadge-{{ section_id }}-{{ card_product.id }}"
                class="badge badge--bottom-left color-{{ settings.sale_badge_color_scheme }}"
              >
                {{- 'products.product.on_sale' | t -}}
              </span>
               {%- elsif  card_product.metafields.custom.custom_badge != blank -%}
              <span
                id="NoMediaStandardBadge-{{ section_id }}-{{ card_product.id }}"
                class="badge badge--bottom-left color-{{ settings.sold_out_badge_color_scheme }}"
              >
               {{ card_product.metafields.custom.custom_badge }}
              </span>
            {%- endif -%}
          </div> 

 

go to Settings --------------> Custom Data-----------------> Product----------------->Add Definition-------> Add name "Custom Badge"-----------> Select type------> "Single Line Text" and then save


now go to products start adding your label whatever you want.

Thanks

- Buy me a Pizza
- If helpful then please Like and Accept Solution.
- Want to modify or custom changes or bug fix on the store Hire me. GTL web solutions
- Want Complete Storefront: Send an email ⇨- Email: info@gtlofficial.com - Skype: ritesh_27dh

View solution in original post

Replies 6 (6)

WalkYourStyle
Explorer
440 53 78

Can you please share you store's URL, as well as the theme you are using currently?

robertsolcan
Excursionist
31 0 2

I'm using Dawn 14.0.0, and the url is www.bymo.ro

WalkYourStyle
Explorer
440 53 78

Instructions
1. Go to Online Store -> Themes -> Edit Code

2. In the sections folder locate the file 'main-collection-product-grid.liquid'

3. Find this code in the file

{% render 'card-product',
  card_product: product,
  media_aspect_ratio: section.settings.image_ratio,
  image_shape: section.settings.image_shape,
  show_secondary_image: section.settings.show_secondary_image,
  show_vendor: section.settings.show_vendor,
  show_rating: section.settings.show_rating,
  lazy_load: lazy_load,
  skip_styles: skip_card_product_styles,
  quick_add: section.settings.quick_add,
  section_id: section.id
%}

4. Just below it, add this code

{% assign product_technology = product.metafields.custom.technology %}
{% if product_technology != blank %}
  <div class="technology-label-container">
    <a id="product-technology-label" href="{{ product.url }}">{{ product_technology }}</a>
  </div>
{% endif %}

5. After you've added the above code, it should look like this
likethis.PNG

6. Finish it with some CSS to make it look nice. Go to the assets folder and locate the file 'base.css'.
At the end of the file add the below code

/* Collection Grid Card Product Technology Label CSS */
.technology-label-container{
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  line-height: initial;
}
#product-technology-label{
  width: 100%;
  background: black;
  color: white;
  padding: 4px 10px 4px 10px;
  text-decoration: none;
  font-weight: 400;
  font-size: 11px;
}
/*  Collection Grid Card Product Technology Label CSS Ends here */

If you have any other questions please feel free to ask.

BSS-TekLabs
Shopify Partner
1902 546 634

Can you try app BSS: Product Labels & Badges

https://apps.shopify.com/product-labels-by-bss?search_id=c2b0ee9e-2986-4c74-901b-af32074a4011&surfac...

If our suggestions are useful, please let us know by giving it a like or marking it as a solution .
Need help from our expert? Kindly share your request with us via community@bsscommerce.com
BSS Commerce - Full-service eCommerce Agency

For give Gift to customers and Upsell in Cart, check out Salepify: Free Gifts with purchase


Post purchase upsell, downsell offers to improve sales and AOV
Salemate Post Purchase Upsell

robertsolcan
Excursionist
31 0 2

I want to use some code directly, without any additional app.

GTLOfficial
Shopify Partner
444 89 87

This is an accepted solution.

Hello 
@robertsolcan 
here is a code 

step 1 Go to Online Store------>     Edit code----------------> go to file "card-product.liquid"  line number  516 to 532
find this code

 

 

<div class="card__badge {{ settings.badge_position }}">
          {%- if card_product.available == false -%}
            <span
              id="Badge-{{ section_id }}-{{ card_product.id }}"
              class="badge badge--bottom-left color-{{ settings.sold_out_badge_color_scheme }}"
            >
              {{- 'products.product.sold_out' | t -}}
            </span>
          {%- elsif card_product.compare_at_price > card_product.price and card_product.available -%}
            <span
              id="Badge-{{ section_id }}-{{ card_product.id }}"
              class="badge badge--bottom-left color-{{ settings.sale_badge_color_scheme }}"
            >
              {{- 'products.product.on_sale' | t -}}
            </span>
          {%- endif -%}
        </div>

 

 


and replace with this one

 

<div class="card__badge {{ settings.badge_position }}">
            {%- if card_product.available == false -%}
              <span
                id="NoMediaStandardBadge-{{ section_id }}-{{ card_product.id }}"
                class="badge badge--bottom-left color-{{ settings.sold_out_badge_color_scheme }}"
              >
                {{- 'products.product.sold_out' | t -}}
              </span>
            {%- elsif card_product.compare_at_price > card_product.price and card_product.available -%}
              <span
                id="NoMediaStandardBadge-{{ section_id }}-{{ card_product.id }}"
                class="badge badge--bottom-left color-{{ settings.sale_badge_color_scheme }}"
              >
                {{- 'products.product.on_sale' | t -}}
              </span>
               {%- elsif  card_product.metafields.custom.custom_badge != blank -%}
              <span
                id="NoMediaStandardBadge-{{ section_id }}-{{ card_product.id }}"
                class="badge badge--bottom-left color-{{ settings.sold_out_badge_color_scheme }}"
              >
               {{ card_product.metafields.custom.custom_badge }}
              </span>
            {%- endif -%}
          </div> 

 

go to Settings --------------> Custom Data-----------------> Product----------------->Add Definition-------> Add name "Custom Badge"-----------> Select type------> "Single Line Text" and then save


now go to products start adding your label whatever you want.

Thanks

- Buy me a Pizza
- If helpful then please Like and Accept Solution.
- Want to modify or custom changes or bug fix on the store Hire me. GTL web solutions
- Want Complete Storefront: Send an email ⇨- Email: info@gtlofficial.com - Skype: ritesh_27dh