Custom Badges Help on Dawn Theme

Custom Badges Help on Dawn Theme

DanielPK-JMC
Visitor
3 0 0

Hello

I am struggling editing this code for my webstore. I want to replace the default "SOLD OUT" badge for a custom icon. I have tried inserting the image source URL into the Span for the Sold Out badge but it doesn't scale inside the product cards the same way the other custom badges do. They either output a syntax error or are way too large and completely cover the product card.

thanks everyone

 

Code Liquid:

 

{% comment %}
Renders a custom badge based on provided settings.
{% endcomment %}

{%- if badge_type == "standard" -%}
{%- if product.available == false -%}
<span
id="NoMediaStandardBadge-{{ section_id }}-{{ product.id }}"
class="badge badge--bottom-left color-{{ settings.sold_out_badge_color_scheme }}"
style="display: {{ settings.custom_badge_layout }}; margin-top: {{ settings.custom_badge_spacing }}px;"
>

{{- 'products.product.sold_out' | t -}}
</span>

{% comment %} ------------------------- 'SALE' BUTTON -------------------------------------------------------------{% endcomment %}

{%- elsif product.compare_at_price > product.price and product.available -%}
<span
id="NoMediaStandardBadge-{{ section_id }}-{{ product.id }}"
class="badge badge--bottom-left color-{{ settings.sale_badge_color_scheme }}"
style="display: none; margin-top: {{ settings.custom_badge_spacing }}px;"
>
{{- 'products.product.on_sale' | t -}}
</span>
{%- endif -%}
{%- elsif badge_type == "custom" -%}
{%- if custom_badge_option == "text" -%}
<span
id="NoMediaCustomBadge-{{ section_id }}-{{ product.id }}"
class="badge badge--bottom-left color-{{ custom_badge_color_scheme }}"
style="display: {{ settings.custom_badge_layout }}; margin-top: {{ settings.custom_badge_spacing }}px;"
>
{{ custom_badge_text }}
</span>
{%- elsif custom_badge_option == "image" -%}
<span
id="NoMediaCustomBadge-{{ section_id }}-{{ product.id }}"
>
<img src="{{ custom_badge_image | img_url: 'master' }}" width={{ custom_badge_image_width }} height="auto">
</span>

{%- elsif custom_badge_option == "dynamic_image" -%}
{% if product.metafields.custom.custom_dynamic_badge != nil %}
<span
id="NoMediaCustomBadge-{{ section_id }}-{{ product.id }}"
>
<img src="{{ product.metafields.custom.custom_dynamic_badge | img_url: 'master' }}" width={{ custom_badge_image_width }} height="auto">
</span>
{% endif %}
{%- endif -%}
{% endif %}

Reply 1 (1)

websensepro
Shopify Partner
1880 225 267

Hi  @DanielPK-JMC , kindly provide your store URL please and if it is password protected, please share the password as well. Thanks

Need a Shopify developer? Hire us at WebSensePro For Shopify Design Changes/Coding
For Free Tutorials Subscribe to our youtube
Get More Sales Using Big Bulk Discount APP
Create Your Shopify Store For Just 1$/Month
Get More Sales Using Big Bulk Discount APP