From 831ffa52bd47d8e7d81ceec84b02dbe74212b2ba Mon Sep 17 00:00:00 2001 From: BC-tymurbiedukhin <66319629+BC-tymurbiedukhin@users.noreply.github.com> Date: Tue, 19 Jan 2021 15:04:25 +0200 Subject: [PATCH] fix(storefront): BCTHEME-384 When default option is out of stock add to cart button does not populate for in stock options (#1955) --- CHANGELOG.md | 1 + .../js/theme/common/product-details-base.js | 6 ++ .../amp/products/product-options.html | 4 +- .../components/products/add-to-cart.html | 84 ++++++++++--------- .../components/products/product-view.html | 4 +- 5 files changed, 55 insertions(+), 44 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 163c68c7dd..7e10315255 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog ## Draft +- Fixed case when default option is out of stock add to cart button does not populate for in stock options. [#1955](https://github.com/bigcommerce/cornerstone/pull/1955) - Dots on carousel should have similar colours as other slider controls. [#1958](https://github.com/bigcommerce/cornerstone/pull/1958) - PDP - Fixed Empty "Description" Hiding All Tabs When in Tab View. [#1947](https://github.com/bigcommerce/cornerstone/pull/1947) - Added custom event for product price change on PDP page. [#1948](https://github.com/bigcommerce/cornerstone/pull/1948) diff --git a/assets/js/theme/common/product-details-base.js b/assets/js/theme/common/product-details-base.js index 82659d2046..71982946e7 100644 --- a/assets/js/theme/common/product-details-base.js +++ b/assets/js/theme/common/product-details-base.js @@ -264,6 +264,12 @@ export default class ProductDetailsBase { } else if (typeof (data.bulk_discount_rates) !== 'undefined') { viewModel.$bulkPricing.html(''); } + + const addToCartWrapper = $('#add-to-cart-wrapper'); + + if (addToCartWrapper.is(':hidden') && data.purchasable) { + addToCartWrapper.show(); + } } /** diff --git a/templates/components/amp/products/product-options.html b/templates/components/amp/products/product-options.html index 372911a367..13c41a7300 100644 --- a/templates/components/amp/products/product-options.html +++ b/templates/components/amp/products/product-options.html @@ -8,9 +8,7 @@ {{{dynamicComponent 'components/products/options'}}} {{/each}} - {{#if product.can_purchase}} - {{> components/products/add-to-cart}} - {{/if}} + {{> components/products/add-to-cart}}
diff --git a/templates/components/products/add-to-cart.html b/templates/components/products/add-to-cart.html index 9ff3ade1d3..acc0ef2118 100644 --- a/templates/components/products/add-to-cart.html +++ b/templates/components/products/add-to-cart.html @@ -1,43 +1,51 @@ -{{#if theme_settings.show_product_quantity_box}} -
- -
- - - -
-
-{{/if}} +
+ {{#if theme_settings.show_product_quantity_box}} +
+ +
+ + + +
+
+ {{/if}} -