File tree 3 files changed +15
-6
lines changed
Catalog/view/frontend/templates/product/view
Checkout/view/frontend/web/js/view/configure
ConfigurableProduct/view/frontend/web/js
3 files changed +15
-6
lines changed Original file line number Diff line number Diff line change 22
22
<input type="hidden" name="product" value="<?= /* @escapeNotVerified */ $ _product ->getId () ?> " />
23
23
<input type="hidden" name="selected_configurable_option" value="" />
24
24
<input type="hidden" name="related_product" id="related-products-field" value="" />
25
+ <input type="hidden" name="item" value="<?= /* @noEscape */ $ block ->getRequest ()->getParam ('id ' ) ?> " />
25
26
<?= $ block ->getBlockHtml ('formkey ' ) ?>
26
27
<?= $ block ->getChildHtml ('form_top ' ) ?>
27
28
<?php if (!$ block ->hasOptions ()):?>
Original file line number Diff line number Diff line change @@ -7,10 +7,12 @@ require([
7
7
8
8
var selectors = {
9
9
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"]'
11
12
} ,
12
13
cartData = customerData . get ( 'cart' ) ,
13
14
productId = $ ( selectors . productIdSelector ) . val ( ) ,
15
+ itemId = $ ( selectors . itemIdSelector ) . val ( ) ,
14
16
productQty ,
15
17
productQtyInput ,
16
18
@@ -40,8 +42,10 @@ require([
40
42
return ;
41
43
}
42
44
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
+ }
45
49
} ) ;
46
50
47
51
if ( ! product ) {
Original file line number Diff line number Diff line change @@ -7,10 +7,12 @@ define([
7
7
8
8
var selectors = {
9
9
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"]'
11
12
} ,
12
13
cartData = customerData . get ( 'cart' ) ,
13
14
productId = $ ( selectors . productIdSelector ) . val ( ) ,
15
+ itemId = $ ( selectors . itemIdSelector ) . val ( ) ,
14
16
15
17
/**
16
18
* set productOptions according to cart data from customer-data
@@ -24,8 +26,10 @@ define([
24
26
if ( ! ( data && data . items && data . items . length && productId ) ) {
25
27
return false ;
26
28
}
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
+ }
29
33
} ) ;
30
34
changedProductOptions = changedProductOptions && changedProductOptions . options &&
31
35
changedProductOptions . options . reduce ( function ( obj , val ) {
You can’t perform that action at this time.
0 commit comments