Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TH-187: Harmony > Refactoring skip cart feature #73

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions themes/harmony/sections/product.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,6 @@
"type": "checkbox",
"default": true
},
{
"type": "checkbox",
"id": "skip_cart",
"label": "Skip cart",
"default": false
},
{
"label": "Background color",
"id": "background_color",
Expand Down
16 changes: 9 additions & 7 deletions themes/harmony/snippets/add-to-cart.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,20 @@
class='spinner hidden'
id='loading__cart'
></span>
<span class="btn-content">
{% render 'icon', name: 'bag' %}
{{ block_settings.text_content }}
</span>
{% if skip_cart %}
<span>{{ 'snippets.product_preview.cta_button' | t }}</span>
{% else %}
<span class="btn-content">
{% render 'icon', name: 'bag' %}
{{ block_settings.text_content }}
</span>
{% endif %}
</button>
</div>

{% javascript %}

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

const IS_CART_SKIPED = "{{ block_settings.skip_cart }}";
const IS_CART_SKIPED = Boolean("{{ skip_cart }}");
{% endjavascript %}
2 changes: 1 addition & 1 deletion themes/harmony/snippets/product-preview.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
{% endif %}
</div>
<div class='product-btn'>
{% 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-secondary" 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/harmony/snippets/product-slider.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<span class='product-price'>{{ block.settings.product.price | money }}</span>
{% endif %}
</div>
{% 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-secondary--large" 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/harmony/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', block_settings: block.settings, snippetId: snippetId, is_placeholder: is_placeholder %}
{% render 'add-to-cart', block_settings: block.settings, snippetId: snippetId, 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/harmony/snippets/single-product.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,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', block_settings: block.settings, snippetId: snippetId %}
{% render 'add-to-cart', block_settings: block.settings, snippetId: snippetId, 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