File tree Expand file tree Collapse file tree 5 files changed +42
-13
lines changed
Catalog/view/frontend/web/js
ConfigurableProduct/view/frontend
templates/product/view/type/options
Swatches/view/frontend/web/js Expand file tree Collapse file tree 5 files changed +42
-13
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,23 @@ define([
49
49
} ) ;
50
50
} ,
51
51
52
+ /**
53
+ * @private
54
+ */
55
+ _redirect : function ( url ) {
56
+ var urlParts , locationParts , forceReload ;
57
+
58
+ urlParts = url . split ( '#' ) ;
59
+ locationParts = window . location . href . split ( '#' ) ;
60
+ forceReload = urlParts [ 0 ] === locationParts [ 0 ] ;
61
+
62
+ window . location . assign ( url ) ;
63
+
64
+ if ( forceReload ) {
65
+ window . location . reload ( ) ;
66
+ }
67
+ } ,
68
+
52
69
/**
53
70
* @return {Boolean }
54
71
*/
@@ -119,12 +136,8 @@ define([
119
136
parameters . push ( eventData . redirectParameters . join ( '&' ) ) ;
120
137
res . backUrl = parameters . join ( '#' ) ;
121
138
}
122
- window . location . href = res . backUrl ;
123
139
124
- // page does not reload when anchor (#) is added
125
- if ( res . backUrl . indexOf ( '#' ) !== - 1 ) {
126
- window . location . reload ( ) ;
127
- }
140
+ self . _redirect ( res . backUrl ) ;
128
141
129
142
return ;
130
143
}
Original file line number Diff line number Diff line change @@ -22,7 +22,6 @@ $_attributes = $block->decorateArray($block->getAllowAttributes());
22
22
<div class="control">
23
23
<select name="super_attribute[<?= /* @escapeNotVerified */ $ _attribute ->getAttributeId () ?> ]"
24
24
data-selector="super_attribute[<?= /* @escapeNotVerified */ $ _attribute ->getAttributeId () ?> ]"
25
- data-attribute-code="<?= /* @escapeNotVerified */ $ _attribute ->getAttributeId () ?> "
26
25
data-validate="{required:true}"
27
26
id="attribute<?= /* @escapeNotVerified */ $ _attribute ->getAttributeId () ?> "
28
27
class="super-attribute-select">
Original file line number Diff line number Diff line change @@ -9,9 +9,7 @@ require([
9
9
10
10
$ ( 'body' ) . on ( 'catalogCategoryAddToCartRedirect' , function ( event , data ) {
11
11
$ ( data . form ) . find ( 'select[name*="super"]' ) . each ( function ( index , item ) {
12
- var $item = $ ( item ) ;
13
-
14
- data . redirectParameters . push ( $item . attr ( 'data-attribute-code' ) + '=' + $item . val ( ) ) ;
12
+ data . redirectParameters . push ( item . config . id + '=' + $ ( item ) . val ( ) ) ;
15
13
} ) ;
16
14
} ) ;
17
15
} ) ;
Original file line number Diff line number Diff line change @@ -9,9 +9,16 @@ require([
9
9
10
10
$ ( 'body' ) . on ( 'catalogCategoryAddToCartRedirect' , function ( event , data ) {
11
11
$ ( data . form ) . find ( '[name*="super"]' ) . each ( function ( index , item ) {
12
- var $item = $ ( item ) ;
12
+ var $item = $ ( item ) ,
13
+ attr ;
14
+
15
+ if ( $item . attr ( 'data-attr-name' ) ) {
16
+ attr = $item . attr ( 'data-attr-name' ) ;
17
+ } else {
18
+ attr = $item . parent ( ) . attr ( 'attribute-code' ) ;
19
+ }
20
+ data . redirectParameters . push ( attr + '=' + $item . val ( ) ) ;
13
21
14
- data . redirectParameters . push ( $item . attr ( 'data-attr-name' ) + '=' + $item . val ( ) ) ;
15
22
} ) ;
16
23
} ) ;
17
24
} ) ;
Original file line number Diff line number Diff line change @@ -1214,8 +1214,20 @@ define([
1214
1214
*/
1215
1215
_EmulateSelected : function ( selectedAttributes ) {
1216
1216
$ . each ( selectedAttributes , $ . proxy ( function ( attributeCode , optionId ) {
1217
- this . element . find ( '.' + this . options . classes . attributeClass +
1218
- '[attribute-code="' + attributeCode + '"] [option-id="' + optionId + '"]' ) . trigger ( 'click' ) ;
1217
+ var elem = this . element . find ( '.' + this . options . classes . attributeClass +
1218
+ '[attribute-code="' + attributeCode + '"] [option-id="' + optionId + '"]' ) ,
1219
+ parentInput = elem . parent ( ) ;
1220
+
1221
+ if ( elem . hasClass ( 'selected' ) ) {
1222
+ return ;
1223
+ }
1224
+
1225
+ if ( parentInput . hasClass ( this . options . classes . selectClass ) ) {
1226
+ parentInput . val ( optionId ) ;
1227
+ parentInput . trigger ( 'change' ) ;
1228
+ } else {
1229
+ elem . trigger ( 'click' ) ;
1230
+ }
1219
1231
} , this ) ) ;
1220
1232
} ,
1221
1233
You can’t perform that action at this time.
0 commit comments