Skip to content

Commit

Permalink
fix(storefront): BCTHEME-1006 When price list price is set for curren…
Browse files Browse the repository at this point in the history
…cy, the cart does not respect product's price (#2190)
  • Loading branch information
bc-vlad-dlogush committed Apr 7, 2022
1 parent 7093931 commit 6719254
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Draft
- When price list price is set for currency, the cart does not respect product's price.[#2190](https://github.com/bigcommerce/cornerstone/issues/2190)

## 6.3.0 (03-11-2022)
- Update blog component to use H1 tags on posts [#2179](https://github.com/bigcommerce/cornerstone/issues/2179)
Expand Down
2 changes: 2 additions & 0 deletions assets/js/theme/common/product-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import forms from '../common/models/forms';
import { normalizeFormData } from './utils/api';
import { isBrowserIE, convertIntoArray } from './utils/ie-helpers';
import bannerUtils from './utils/banner-utils';
import currencySelector from '../global/currency-selector';

export default class ProductDetails extends ProductDetailsBase {
constructor($scope, context, productAttributesData = {}) {
Expand Down Expand Up @@ -399,6 +400,7 @@ export default class ProductDetails extends ProductDetailsBase {

// Add item to cart
utils.api.cart.itemAdd(normalizeFormData(new FormData(form)), (err, response) => {
currencySelector(response.data.cart_id);
const errorMessage = err || response.data.error;

$addToCartBtn
Expand Down
13 changes: 10 additions & 3 deletions assets/js/theme/global/currency-selector.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
import swal from './sweet-alert';
import utils from '@bigcommerce/stencil-utils';

let currencySelectorCalled = false;

export default function (cartId) {
if (!cartId) return;

if (!currencySelectorCalled) {
currencySelectorCalled = true;
} else {
return;
}

function changeCurrency(url, currencyCode) {
$.ajax({
url,
Expand All @@ -21,9 +31,6 @@ export default function (cartId) {

$('[data-cart-currency-switch-url]').on('click', event => {
const currencySessionSwitcher = event.target.href;
if (!cartId) {
return;
}
event.preventDefault();
utils.api.cart.getCart({ cartId }, (err, response) => {
if (err || response === undefined) {
Expand Down

0 comments on commit 6719254

Please sign in to comment.