@@ -459,20 +459,7 @@ define([
459
459
'</div>' + input +
460
460
'</div>'
461
461
) ;
462
-
463
- if ( $widget . options . jsonConfig . canDisplayShowOutOfStockStatus ) {
464
- let salableProd = $widget . options . jsonConfig . salable [ item . id ] ,
465
- swatchOptions = container . find ( '.swatch-option' ) ;
466
-
467
- swatchOptions . each ( function ( key , value ) {
468
- let optionId = $ ( value ) . data ( 'option-id' ) ;
469
-
470
- if ( ! salableProd . hasOwnProperty ( optionId ) ) {
471
- $ ( value ) . attr ( 'disabled' , true ) . addClass ( 'disabled' ) ;
472
- }
473
- } ) ;
474
- }
475
-
462
+
476
463
$widget . optionsMap [ item . id ] = { } ;
477
464
478
465
// Aggregate options array to hash (key => value)
@@ -503,11 +490,35 @@ define([
503
490
// Handle events like click or change
504
491
$widget . _EventListener ( ) ;
505
492
493
+ // Rewind options
494
+ $widget . _Rewind ( container ) ;
495
+
506
496
//Emulate click on all swatches from Request
507
497
$widget . _EmulateSelected ( $ . parseQuery ( ) ) ;
508
498
$widget . _EmulateSelected ( $widget . _getSelectedAttributes ( ) ) ;
509
499
} ,
510
500
501
+ disableSwatchForOutOfStockProducts : function ( ) {
502
+ let $widget = this , container = this . element ;
503
+
504
+ $ . each ( this . options . jsonConfig . attributes , function ( ) {
505
+ let item = this ;
506
+
507
+ if ( $widget . options . jsonConfig . canDisplayShowOutOfStockStatus ) {
508
+ let salableProd = $widget . options . jsonConfig . salable [ item . id ] ,
509
+ swatchOptions = container . find ( '.swatch-option' ) ;
510
+
511
+ swatchOptions . each ( function ( key , value ) {
512
+ let optionId = $ ( value ) . data ( 'option-id' ) ;
513
+
514
+ if ( ! salableProd . hasOwnProperty ( optionId ) ) {
515
+ $ ( value ) . attr ( 'disabled' , true ) . addClass ( 'disabled' ) ;
516
+ }
517
+ } ) ;
518
+ }
519
+ } ) ;
520
+ } ,
521
+
511
522
/**
512
523
* Render swatch options by part of config
513
524
*
@@ -898,6 +909,7 @@ define([
898
909
. attr ( 'disabled' , true )
899
910
. addClass ( 'disabled' )
900
911
. attr ( 'tabindex' , '-1' ) ;
912
+ this . disableSwatchForOutOfStockProducts ( ) ;
901
913
} ,
902
914
903
915
/**
0 commit comments