Change checkout button text for customer with specific tag.

JustinW1
Tourist
8 0 1

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.

Replies 2 (2)

Michal17
Shopify Partner
835 73 175

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.

JustinW1
Tourist
8 0 1

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?