Change checkout button text for customer with specific tag.

JustinW1
New Member
8 0 0

I've been looking but can't find my answer. 

Here is my code. Using this code I can get the checkout button on the /cart page to show "Checkout test" for VIP customers and the standard "Checkout" for everyone else. (even though it looks reversed to me, it works !!??).

{% if customer.tags != 'VIP'  %}
						<input type="hidden" name="attributes[collection_products_per_page]" value="">
                    	<input type="hidden" name="attributes[collection_layout]" value="">
                    	<button type="submit" name="checkout" class="cart-recap__checkout button button--primary button--full button--large">{{ 'cart.general.checkout' | t }} test</button>        
                    
                    {% else %}
           				<input type="hidden" name="attributes[collection_products_per_page]" value="">
                    	<input type="hidden" name="attributes[collection_layout]" value="">
                    	<button type="submit" name="checkout" class="cart-recap__checkout button button--primary button--full button--large">{{ 'cart.general.checkout' | t }} </button>        
                    
					{%- endif -%}


What I want to do is to have a translation specifically for the VIP customers, so it says "Quote Request" as these customers do not have a payment gateway (that bits all working fine). How do I add a custom translation or apply inline "Quote Request"  text to: 

{{ 'cart.general.checkout' | t }} 

 

All help appreciated.

0 Likes
Michal17
Shopify Partner
820 73 143

Hi @JustinW1 

Hope you're having a great day!

You should use contains operator. contains checks for the presence of a substring in a string.

So:

 

{% if customer.tags contains "VIP"  %}
	<input type="hidden" name="attributes[collection_products_per_page]" value="">
	<input type="hidden" name="attributes[collection_layout]" value="">
	<button type="submit" name="checkout" class="cart-recap__checkout button button--primary button--full button--large">{{ 'cart.general.checkout' | t }} test</button>
{% else %}
  <input type="hidden" name="attributes[collection_products_per_page]" value="">
  <input type="hidden" name="attributes[collection_layout]" value="">
  <button type="submit" name="checkout" class="cart-recap__checkout button button--primary button--full button--large">{{ 'cart.general.checkout' | t }} </button>        
{%- endif -%}

 

If you found this comment useful, hit the 'Like' and 'Accepted solution' buttons.

0 Likes
JustinW1
New Member
8 0 0

Thanks @Michal17 super helpful for the identification.

Do you know how I can tackle the second part, and change the button text for these customers?

0 Likes