We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

Is there a way to add Unavailable instead of "Sold Out"? - Dawn Theme

Is there a way to add Unavailable instead of "Sold Out"? - Dawn Theme

randytheasian
Pathfinder
115 0 23
Replies 4 (4)
randytheasian
Pathfinder
115 0 23

Instead of Sold Out, I'd like to display it "Unavailable". Meanwhile, I still want to keep the word "Sold Out" for other products. 

TaskHusky
Shopify Partner
119 11 21

Hello Randy,

 

Yes. There is a real quick and simple way to do this. I've created a video showing you how to get there.

 

https://www.loom.com/share/0980548cfcd94f8a83334f745fc992b8

Zachary McClung, founder
Your Shopify Store Customized Your Way - 20,000 + Shopify Merchants Served
Clean Size Chart - Reduce Returns & Make More Money
Partner Party a quarterly virtual event for app developers, theme developers, agencies, and freelancers.
randytheasian
Pathfinder
115 0 23

Great! But I want some products to remain as "Sold Out". 

TaskHusky
Shopify Partner
119 11 21

Hello @randytheasian,

 

Yes, that is possible. It requires additional modifications. Here is how you'd achieve it:

We'll need to modify a few key areas where the sold out badge appears.

First, let's look at the card-product.liquid snippet where sold out badges are displayed. We need to modify two instances:

{%- 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>


and

{%- 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>

Here's how it should modify these sections to handle the new condition:

{%- 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 }}"
>
{%- if card_product.tags contains 'Unavailable' -%}
{{- 'products.product.unavailable' | t -}}
{%- else -%}
{{- 'products.product.sold_out' | t -}}
{%- endif -%}
</span>
{%- endif -%}


You'll also need to modify the price snippet since it shows sold out badges as well:

<span class="badge price__badge-sold-out color-{{ settings.sold_out_badge_color_scheme }}">
{{ 'products.product.sold_out' | t }}
</span>


Should be updated to:


<span class="badge price__badge-sold-out color-{{ settings.sold_out_badge_color_scheme }}">
{%- if product.tags contains 'Unavailable' -%}
{{ 'products.product.unavailable' | t }}
{%- else -%}
{{ 'products.product.sold_out' | t }}
{%- endif -%}
</span>

 

Make sure your theme's locale files (typically in locales/en.default.json or similar) have both translations defined:

{
"products": {
"product": {
"sold_out": "Sold Out",
"unavailable": "Unavailable"
}
}
}

Zachary McClung, founder
Your Shopify Store Customized Your Way - 20,000 + Shopify Merchants Served
Clean Size Chart - Reduce Returns & Make More Money
Partner Party a quarterly virtual event for app developers, theme developers, agencies, and freelancers.