Skip to content

Instantly share code, notes, and snippets.

View coleatkinson's full-sized avatar

Cole Atkinson coleatkinson

View GitHub Profile
@coleatkinson
coleatkinson / main-product.liquid
Last active March 23, 2023 18:54
Example of edits to Shopify Dawn theme to change products based on country
{% comment %}
Replace the Add to Cart button with a link to an external website for products with tags containing do_not_sell_to_UK when the buyer's context is set to the United Kingdom.
{% endcomment %}
{% if product.tags contains "do_not_sell_to_UK" and localization.country.iso_code == 'GB' %}
<p><a href="https://example.com">Go to retailer website</a></p>
{% elsif product.selected_or_first_available_variant.available %}
{{ 'products.product.add_to_cart' | t }}
{% else %}
{{ 'products.product.sold_out' | t }}
@coleatkinson
coleatkinson / customize-content-basics-shopify.liquid
Created October 27, 2021 20:51
Customize content by country on Shopify: Basics
{% if localization.country.iso_code == 'FR' %}
// show custom content only meant for France
{% else %}
show generic content
{% endif %}
@coleatkinson
coleatkinson / main-collection-product-grid.liquid
Last active March 23, 2023 18:53
Example of edits to Shopify Dawn theme to change collections based on country
{% comment %}
Hide products on collection pages that are tagged with do_not_sell_to_UK when the buyer's context is set to the United Kingdom.
{% endcomment %}
{% unless product.tags contains "do_not_sell_to_UK" and localization.country.iso_code == 'GB' %}
<li class="grid__item">
{% render 'product-card', product_card_product: product, media_size: section.settings.image_ratio, show_secondary_image: section.settings.show_secondary_image, add_image_padding: section.settings.add_image_padding, show_vendor: section.settings.show_vendor, show_image_outline: section.settings.show_image_outline, show_rating: section.settings.show_rating %}
</li>
{% endunless %}
@coleatkinson
coleatkinson / image-banner.liquid
Created October 27, 2021 21:04
Customize the image banner section in Shopify's Dawn theme
{% comment %}
Schema that adds a basic text input field to the image banner home page section of Shopify's Dawn theme.
{% endcomment %}
{
"type": "text",
"id": "available_countries",
"label": "Add the ISO code of the country that should see this banner."
}
@coleatkinson
coleatkinson / image-banner.liquid
Created October 27, 2021 21:10
Customizations to the image banner section of Shopify's Dawn theme that allow it to be shown only to certain countries
{% comment %}
Replace the standard image-banner.liquid file in Shopify's Dawn theme with the below to allow you to show or hide a hero image on the home page based on country.
{% endcomment %}
{% if section.settings.available_countries != blank %}
{% if localization.country.iso_code == section.settings.available_countries %}
{{ 'section-image-banner.css' | asset_url | stylesheet_tag }}
{%- if section.settings.adapt_height_first_image and section.settings.image != blank -%}
{% unless product.tags contains "do_not_sell_to_UK" and localization.country.iso_code == 'GB' %}
{%- if block.settings.show_dynamic_checkout -%}
{{ form | payment_button }}
{%- endif -%}
{% endunless %}