From 5ccd5643d978d0a2233d6022d34ce3c7ca305ea3 Mon Sep 17 00:00:00 2001 From: tyleralsbury Date: Wed, 6 Oct 2021 11:00:31 -0400 Subject: [PATCH 1/5] Added go to cart when adding --- assets/product-form.js | 4 +++- config/settings_schema.json | 21 +++++++++++++++++++++ locales/en.default.schema.json | 14 ++++++++++++++ sections/featured-product.liquid | 2 +- sections/main-product.liquid | 2 +- 5 files changed, 40 insertions(+), 3 deletions(-) diff --git a/assets/product-form.js b/assets/product-form.js index b2af5e37d54..ff0dae8a703 100644 --- a/assets/product-form.js +++ b/assets/product-form.js @@ -10,9 +10,11 @@ if (!customElements.get('product-form')) { } onSubmitHandler(evt) { + if (this.dataset.addToCartBehavior == 'go_to_cart') return; + evt.preventDefault(); const submitButton = this.querySelector('[type="submit"]'); - if (submitButton.classList.contains('loading')) return; + if (submitButton.classList.contains('loading')) return; this.handleErrorMessage(); this.cartNotification.setActiveElement(document.activeElement); diff --git a/config/settings_schema.json b/config/settings_schema.json index 8510ad45602..816c516c793 100644 --- a/config/settings_schema.json +++ b/config/settings_schema.json @@ -328,5 +328,26 @@ "default": true } ] + }, + { + "name": "t:settings_schema.cart.name", + "settings": [ + { + "type": "select", + "id": "add_to_cart_behavior", + "options": [ + { + "value": "cart_notification", + "label": "t:settings_schema.cart.settings.add_to_cart_behavior.cart_notification.label" + }, + { + "value": "go_to_cart", + "label": "t:settings_schema.cart.settings.add_to_cart_behavior.go_to_cart.label" + } + ], + "default": "cart_notification", + "label": "t:settings_schema.cart.settings.add_to_cart_behavior.label" + } + ] } ] diff --git a/locales/en.default.schema.json b/locales/en.default.schema.json index cfdee1899de..98c869151cc 100644 --- a/locales/en.default.schema.json +++ b/locales/en.default.schema.json @@ -209,6 +209,20 @@ } } } + }, + "cart": { + "name": "Cart", + "settings": { + "add_to_cart_behavior": { + "label": "Add to cart behavior", + "cart_notification": { + "label": "Cart notification" + }, + "go_to_cart": { + "label": "Go to cart" + } + } + } } }, "sections": { diff --git a/sections/featured-product.liquid b/sections/featured-product.liquid index 87a10646314..5fd2b37aab5 100644 --- a/sections/featured-product.liquid +++ b/sections/featured-product.liquid @@ -239,7 +239,7 @@ {%- when 'buy_buttons' -%}
{%- if product != blank -%} - +