Skip to content

Commit

Permalink
TH-187: Meraki > Refactoring skip cart feature (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
bj-anas authored Oct 24, 2024
1 parent 6ba3b6d commit ba9ef26
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 16 deletions.
6 changes: 0 additions & 6 deletions themes/meraki/sections/product.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,6 @@
"type": "checkbox",
"default": true
},
{
"type": "checkbox",
"id": "skip_cart",
"label": "Skip cart",
"default": false
},
{
"label": "Background color",
"id": "background_color",
Expand Down
14 changes: 8 additions & 6 deletions themes/meraki/snippets/add-to-cart.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,19 @@
class='spinner hidden'
id='loading__cart'
></span>
<span>
{{ text }}
</span>
{% if skip_cart %}
<span>{{ 'snippets.product_preview.cta_button' | t }}</span>
{% else %}
<span>
{{ text }}
</span>
{% endif %}
</button>
</div>

{% javascript %}

const TRANSLATED_TEXT = {
empty_inventory: "{{ 'errors.empty_inventory' | t }}"
}

const IS_CART_SKIPED = "{{ skip_cart }}";
const IS_CART_SKIPED = Boolean("{{ skip_cart }}");
{% endjavascript %}
2 changes: 1 addition & 1 deletion themes/meraki/snippets/product-preview.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</a>

<div class="product-link-mobile">
{% if settings.direct_add_to_cart and item.variants.size <= 1 %}
{% if settings.direct_add_to_cart and item.variants.size <= 1 and item.skip_to_checkout == false %}
<button class="yc-btn" onclick="directAddToCart(event, '{{ item.variants[0].id }}', {{ item.variants[0].inventory }}, {{ item.isTrackingInventory }})">
{{ 'general.direct_add_to_cart' | t }}
</button>
Expand Down
2 changes: 1 addition & 1 deletion themes/meraki/snippets/product-slider.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
</div>
{% endif %}
<div class="product-link">
{% if settings.direct_add_to_cart and block.settings.product.variants.size <= 1 %}
{% if settings.direct_add_to_cart and block.settings.product.variants.size <= 1 and block.settings.product.skip_to_checkout == false %}
<button class="yc-btn" onclick="directAddToCart(event, '{{ block.settings.product.variants[0].id }}', {{ block.settings.product.variants[0].inventory }}, {{ block.settings.product.isTrackingInventory }});">
{{ 'general.direct_add_to_cart' | t }}
</button>
Expand Down
2 changes: 1 addition & 1 deletion themes/meraki/snippets/single-product-placeholder.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
{%- when 'product_description' -%}
<p class='product-description'>This is a placeholder description for the product.</p>
{%- when 'add_to_cart' -%}
{% render 'add-to-cart', text: block.settings.text_content, is_sticky: block.settings.is_sticky, background_color: block.settings.background_color, text_color: block.settings.text_color, is_placeholder : is_placeholder %}
{% render 'add-to-cart', text: block.settings.text_content, is_sticky: block.settings.is_sticky, background_color: block.settings.background_color, text_color: block.settings.text_color, is_placeholder : is_placeholder, skip_cart: product.skip_to_checkout %}
{%- when 'accordion' -%}
{%- render 'accordion', accordion_title: block.settings.accordion_title, accordion_details: block.settings.accordion_details, background_color: block.settings.background_color, text_color: block.settings.text_color, space_bottom: block.settings.space_bottom -%}
{%- when 'express_checkout' -%}
Expand Down
2 changes: 1 addition & 1 deletion themes/meraki/snippets/single-product.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
{%- when 'stock' -%}
{% render 'stock', stock_title: block.settings.stock_title, stock_items_left: block.settings.stock_items_left, total_stock_items: block.settings.total_stock_items %}
{%- when 'add_to_cart' -%}
{% render 'add-to-cart', text: block.settings.text_content, is_sticky: block.settings.is_sticky, background_color: block.settings.background_color, text_color: block.settings.text_color, snippetId: snippetId, skip_cart: block.settings.skip_cart %}
{% render 'add-to-cart', text: block.settings.text_content, is_sticky: block.settings.is_sticky, background_color: block.settings.background_color, text_color: block.settings.text_color, snippetId: snippetId, skip_cart: product.skip_to_checkout %}
{%- when 'accordion' -%}
{%- render 'accordion', accordion_title: block.settings.accordion_title, accordion_details: block.settings.accordion_details, border_color: block.settings.border_color, text_color: block.settings.text_color, space_bottom: block.settings.space_bottom -%}
{%- when 'express_checkout' -%}
Expand Down

0 comments on commit ba9ef26

Please sign in to comment.