Customize "Add to Cart" Button based on Location

Topic summary

A user wants to customize their ‘Add to Cart’ button behavior based on visitor location:

Requirements by Region:

  • North America: Standard ‘Add to Cart’ functionality
  • UK and Germany: Redirect to respective distribution websites
  • All other regions: Direct visitors to request a quote
  • Need scalability as distribution network expands

Current Situation:

  • User already has an existing theme (not Dawn)
  • Found relevant button code but unsure how to implement location-based logic
  • Shared existing Liquid template code for the add-to-cart button

Suggested Approach:

  • Determine visitor country using methods like localization ISO codes, geolocation JavaScript, or browsing context
  • Add conditional logic around the ‘Add to Cart’ button based on detected location
  • Swap button for distribution website links where applicable
  • May require Shopify expert assistance if unfamiliar with Liquid templating and JavaScript

Status: Open question seeking implementation guidance

Summarized with AI on November 4. AI used: claude-sonnet-4-5-20250929.

Hi Shopify Community!

I would like to make it so North American companies can use the ‘Add to Cart’ button, UK and Germany go to their respective distribution websites (with the ability to add other regions as our distribution network grows), and everywhere else is directed to reach out to us directly for a quote.

I know there is the Dawn theme that seems to fit what I need, but since I already have a theme I am not sure how to implement this.

This is the only bit of code I can find that is related to the button.

{%- if enable_dynamic_buttons -%}

{%- endif -%}

{%- liquid
assign default_text = ‘products.product.add_to_cart’ | t
assign button_text = ‘products.product.add_to_cart’ | t
if template == ‘product.preorder’
assign default_text = ‘products.product.preorder’ | t
assign button_text = ‘products.product.preorder’ | t
endif
unless current_variant.available
assign button_text = ‘products.product.sold_out’ | t
endunless
-%}

<button
{% if product.empty? %}type=“button”{% else %}type=“submit”{% endif %}
name=“add”
id=“AddToCart-{{ section_id }}”
class=“btn btn–full add-to-cart{% if enable_dynamic_buttons and product.selling_plan_groups == empty %} btn–secondary{% endif %}”
{% unless current_variant.available %} disabled=“disabled”{% endunless %}>

{{ button_text }}

{%- if enable_dynamic_buttons -%}
{{ form | payment_button }}
{%- endif -%}

{%- if enable_dynamic_buttons -%}

{%- endif -%}

I appreciate any help or ideas to get this working!

1 Like

Hi @AHead ,

There are many ways of determining the visitor’s country — i.e via localisation ISO code, via geo location JS, via browsing context suggestions. Each method is suitable for different scenarios and how strictly do we need to verify the visitor’s country. Your requirement will using one of the aforementioned methods to determine the visitor’s location and then add conditionals around the ‘Add to cart’ button and then swap it for distribution website links. If you are not familiar with liquid templating and javascript you may need to hire a Shopify expert. Give it a go and if you’re still struggling, we can help. Good luck!