Skip to content

Instantly share code, notes, and snippets.

@squamuglia
Created January 6, 2023 15:11
Show Gist options
  • Save squamuglia/08f001b7f07592bf89826f9684a9d0e6 to your computer and use it in GitHub Desktop.
Save squamuglia/08f001b7f07592bf89826f9684a9d0e6 to your computer and use it in GitHub Desktop.
Mayple Code Samples
# Product Variant Metafields
namespace: mayple_inventory
key: is_available
# Product Page Sample Sold Out Message
{%- if product.selected_or_first_available_variant.metafields.mayple_inventory.is_available != true and localization.country.iso_code != 'US' -%}
{{ 'products.product.sold_out' | t }}
{%- elsif product.selected_or_first_available_variant.available -%}
{{ 'products.product.add_to_cart' | t }}
{%- else -%}
{{ 'products.product.sold_out' | t }}
{%- endif -%}
# Collections Page
<!-- Checks if there is a variant with Mayple inventory -->
{%- assign no_available_intl_variant = false -%}
{%- if localization.country.iso_code != 'US' -%}
{%- assign no_available_intl_variant = true -%}
{%- for variant in product_card_product.variants -%}
{%- if variant.metafields.mayple_inventory.is_available == true -%}
{%- assign no_available_intl_variant = false -%}
{%- break -%}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{%- if no_available_intl_variant -%}
<span class="badge badge--bottom-left color-{{ settings.sold_out_badge_color_scheme }}">
{{- 'products.product.sold_out' | t -}}
</span>
{%- elsif product_card_product.available == false -%}
<span class="badge badge--bottom-left color-{{ settings.sold_out_badge_color_scheme }}">
{{- 'products.product.sold_out' | t -}}
</span>
{%- elsif product_card_product.compare_at_price > product_card_product.price
and product_card_product.available
-%}
<span class="badge badge--bottom-left color-{{ settings.sale_badge_color_scheme }}">
{{- 'products.product.on_sale' | t -}}
</span>
{%- endif -%}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment