Hello everyone,
I’m peter, I use the theme minimog: https://minimog.co/
I want to change the product “Add To Cart” to “GET A FREE SAMPLE” for products with a special tag.
Thank you so much for anyone’s help.
Here is the cart code file:
{%- liquid
assign atc_text = ‘products.product.add_to_cart’ | t
capture is_preorder
render ‘check-preorder’, product: product
endcapture
-%}
{% if is_preorder == “true” %}
{%- capture btn_text -%}
{% render ‘new-locale’, key: ‘products.product.preorder’ %}
{%- endcapture -%}
{% endif %}
<button
type=“submit”
name=“add”
class=“add-to-cart sf__btn flex-grow shrink not-change relative {{ class }} {% unless product.selected_or_first_available_variant.available %}disabled{% endunless %}”
data-atc-text=“{{ btn_text | default: atc_text }}”
{% if product.selected_or_first_available_variant.available %}
{{ btn_text | default: atc_text }}
{% else %}
{{ 'products.product.sold_out' | t }}
{% endif %}
Hi [email removed]Peterdot,
You can try using the code
{%- liquid
assign atc_text = 'GET A FREE SAMPLE'
capture is_preorder
render 'check-preorder', product: product
endcapture
-%}
{% if is_preorder == "true" %}
{%- capture btn_text -%}
{% render 'new-locale', key: 'products.product.preorder' %}
{%- endcapture -%}
{% endif %}
Hope my solution works perfectly for you!
Best regards,
Victor | PageFly
Hello Victor,
Thanks for your help!
I want products to show “GET A FREE SAMPLE” button for these products were tagged “wholesale”.
For other products still show “ADD TO CART” button.
Is this possible?
Thanks a lot!
Peter
you can try
{% if product.tags contains "wholesale" %}
{%- liquid
assign atc_text = 'GET A FREE SAMPLE'
capture is_preorder
render 'check-preorder', product: product
endcapture
-%}
{% else %}
{%- liquid
assign atc_text = 'products.product.add_to_cart' | t
capture is_preorder
render 'check-preorder', product: product
endcapture
-%}
{% endif %}
{% if is_preorder == "true" %}
{%- capture btn_text -%}
{% render 'new-locale', key: 'products.product.preorder' %}
{%- endcapture -%}
{% endif %}
1 Like
It works, thank you so much! 
You are welcome. I’m glad when I can help you 