Skip to content

Commit 175c938

Browse files
ENGCOM-1336: Display Wrong Data On Cart Update Page #14765
- Merge Pull Request #14765 from nit-it/magento2:nit-it-patch-2 - Merged commits: 1. 1690bb2 2. 4f3c9c5 3. 3b636d6 4. d8d51e9
2 parents 13de5d2 + d8d51e9 commit 175c938

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

app/code/Magento/Catalog/view/frontend/templates/product/view/form.phtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<input type="hidden" name="product" value="<?= /* @escapeNotVerified */ $_product->getId() ?>" />
2323
<input type="hidden" name="selected_configurable_option" value="" />
2424
<input type="hidden" name="related_product" id="related-products-field" value="" />
25+
<input type="hidden" name="item" value="<?= /* @noEscape */ $block->getRequest()->getParam('id') ?>" />
2526
<?= $block->getBlockHtml('formkey') ?>
2627
<?= $block->getChildHtml('form_top') ?>
2728
<?php if (!$block->hasOptions()):?>

app/code/Magento/Checkout/view/frontend/web/js/view/configure/product-customer-data.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ require([
77

88
var selectors = {
99
qtySelector: '#product_addtocart_form [name="qty"]',
10-
productIdSelector: '#product_addtocart_form [name="product"]'
10+
productIdSelector: '#product_addtocart_form [name="product"]',
11+
itemIdSelector: '#product_addtocart_form [name="item"]'
1112
},
1213
cartData = customerData.get('cart'),
1314
productId = $(selectors.productIdSelector).val(),
15+
itemId = $(selectors.itemIdSelector).val(),
1416
productQty,
1517
productQtyInput,
1618

@@ -40,8 +42,10 @@ require([
4042
return;
4143
}
4244
product = data.items.find(function (item) {
43-
return item['product_id'] === productId ||
44-
item['item_id'] === productId;
45+
if (item['item_id'] === itemId) {
46+
return item['product_id'] === productId ||
47+
item['item_id'] === productId;
48+
}
4549
});
4650

4751
if (!product) {

app/code/Magento/ConfigurableProduct/view/frontend/web/js/options-updater.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ define([
77

88
var selectors = {
99
formSelector: '#product_addtocart_form',
10-
productIdSelector: '#product_addtocart_form [name="product"]'
10+
productIdSelector: '#product_addtocart_form [name="product"]',
11+
itemIdSelector: '#product_addtocart_form [name="item"]'
1112
},
1213
cartData = customerData.get('cart'),
1314
productId = $(selectors.productIdSelector).val(),
15+
itemId = $(selectors.itemIdSelector).val(),
1416

1517
/**
1618
* set productOptions according to cart data from customer-data
@@ -24,8 +26,10 @@ define([
2426
if (!(data && data.items && data.items.length && productId)) {
2527
return false;
2628
}
27-
changedProductOptions = _.find(data.items, function (item) {
28-
return item['product_id'] === productId;
29+
changedProductOptions = data.items.find(function (item) {
30+
if (item['item_id'] === itemId) {
31+
return item['product_id'] === productId;
32+
}
2933
});
3034
changedProductOptions = changedProductOptions && changedProductOptions.options &&
3135
changedProductOptions.options.reduce(function (obj, val) {

0 commit comments

Comments
 (0)