All things Shopify and commerce
I'm trying to make a quick cheat code to mark porducts as out of stock on my store, even tho when they are in stock on the system.
I've created the "True or False" variante metafield: variant.metafields.custom.sold_out
And i'm trying to use the following code:
{%- liquid
assign default_text = 'products.product.add_to_cart' | t
assign button_text = 'products.product.add_to_cart' | t
if template contains 'preorder'
assign default_text = 'products.product.preorder' | t
assign button_text = 'products.product.preorder' | t
endif
unless current_variant.available and current_variant.metafield.custom.sold_out != 'true'
assign button_text = 'products.product.sold_out' | t
endunless
-%}
<button
{% if product.empty? %}type="button"{% else %}type="submit"{% endif %}
name="add"
data-add-to-cart
class="btn btn--full add-to-cart{% if enable_dynamic_buttons and product.selling_plan_groups == empty %} btn--secondary{% endif %}"
{% unless current_variant.available and current_variant.metafields.custom.sold_out != 'true' %} disabled="disabled" {% endunless %}>
<span data-add-to-cart-text data-default-text="{{ default_text }}">
{{ button_text }}
</span>
</button>
But that doesn't seem to work, can anyone help me with this?
current_variant.metafields.custom.sold_out != true
Change the condition, drop the quotes and try it out
nah same thing, no results...
{{current_variant.available}} {{current_variant.metafields.custom.sold_out}}
It is recommended to print the above conditions for judgment
It is printing "true or false" on both. That is not the issue.
Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025Discover opportunities to improve SEO with new guidance available from Shopify’s growth...
By Jacqui May 1, 2025