File tree Expand file tree Collapse file tree 1 file changed +24
-5
lines changed Expand file tree Collapse file tree 1 file changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -39,18 +39,37 @@ const checkout = async (
39
39
40
40
// Select option for every swatch if there are any.
41
41
await page . evaluate ( ( ) => {
42
- Array . from (
43
- document . querySelectorAll (
44
- '.product-options-wrapper .swatch-attribute'
45
- )
46
- ) . forEach ( ( swatch ) => {
42
+ const swatches = document . querySelectorAll (
43
+ '.product-options-wrapper .swatch-attribute'
44
+ ) ;
45
+ Array . from ( swatches ) . forEach ( ( swatch ) => {
47
46
const swatchOption = swatch . querySelector (
48
47
'.swatch-option:not([disabled])'
49
48
) ;
50
49
swatch . querySelector ( '.swatch-input' ) . value =
51
50
swatchOption . getAttribute ( 'option-id' ) ||
52
51
swatchOption . getAttribute ( 'data-option-id' ) ;
53
52
} ) ;
53
+
54
+ if ( swatches . length ) {
55
+ return ;
56
+ }
57
+
58
+ Array . from (
59
+ document . querySelectorAll (
60
+ '.product-options-wrapper .super-attribute-select'
61
+ )
62
+ ) . forEach ( ( select ) => {
63
+ select . value = Array . from ( select . options ) . reduce (
64
+ ( selectedValue , option ) => {
65
+ return (
66
+ selectedValue ||
67
+ ( option . value ? option . value : selectedValue )
68
+ ) ;
69
+ } ,
70
+ null
71
+ ) ;
72
+ } ) ;
54
73
} ) ;
55
74
56
75
await Promise . all ( [
You can’t perform that action at this time.
0 commit comments