@@ -279,7 +279,7 @@ define([
279
279
_configureElement : function ( element ) {
280
280
this . simpleProduct = this . _getSimpleProductId ( element ) ;
281
281
282
- if ( element . value ) {
282
+ if ( element . value && element . config ) {
283
283
this . options . state [ element . config . id ] = element . value ;
284
284
285
285
if ( element . nextSetting ) {
@@ -298,9 +298,11 @@ define([
298
298
}
299
299
300
300
this . _reloadPrice ( ) ;
301
- this . _displayRegularPriceBlock ( this . simpleProduct ) ;
302
- this . _displayTierPriceBlock ( this . simpleProduct ) ;
303
- this . _displayNormalPriceLabel ( ) ;
301
+ if ( element . config ) {
302
+ this . _displayRegularPriceBlock ( this . simpleProduct ) ;
303
+ this . _displayTierPriceBlock ( this . simpleProduct ) ;
304
+ this . _displayNormalPriceLabel ( ) ;
305
+ }
304
306
this . _changeProductImage ( ) ;
305
307
} ,
306
308
@@ -439,8 +441,10 @@ define([
439
441
filteredSalableProducts ;
440
442
441
443
this . _clearSelect ( element ) ;
442
- element . options [ 0 ] = new Option ( '' , '' ) ;
443
- element . options [ 0 ] . innerHTML = this . options . spConfig . chooseText ;
444
+ if ( element . options ) {
445
+ element . options [ 0 ] = new Option ( '' , '' ) ;
446
+ element . options [ 0 ] . innerHTML = this . options . spConfig . chooseText ;
447
+ }
444
448
prevConfig = false ;
445
449
446
450
if ( element . prevSetting ) {
@@ -552,8 +556,10 @@ define([
552
556
_clearSelect : function ( element ) {
553
557
var i ;
554
558
555
- for ( i = element . options . length - 1 ; i >= 0 ; i -- ) {
556
- element . remove ( i ) ;
559
+ if ( element . options ) {
560
+ for ( i = element . options . length - 1 ; i >= 0 ; i -- ) {
561
+ element . remove ( i ) ;
562
+ }
557
563
}
558
564
} ,
559
565
@@ -588,23 +594,25 @@ define([
588
594
allowedProduct ;
589
595
590
596
_ . each ( elements , function ( element ) {
591
- var selected = element . options [ element . selectedIndex ] ,
592
- config = selected && selected . config ,
593
- priceValue = this . _calculatePrice ( { } ) ;
594
-
595
- if ( config && config . allowedProducts . length === 1 ) {
596
- priceValue = this . _calculatePrice ( config ) ;
597
- } else if ( element . value ) {
598
- allowedProduct = this . _getAllowedProductWithMinPrice ( config . allowedProducts ) ;
599
- priceValue = this . _calculatePrice ( {
600
- 'allowedProducts' : [
601
- allowedProduct
602
- ]
603
- } ) ;
604
- }
597
+ if ( element . options ) {
598
+ var selected = element . options [ element . selectedIndex ] ,
599
+ config = selected && selected . config ,
600
+ priceValue = this . _calculatePrice ( { } ) ;
601
+
602
+ if ( config && config . allowedProducts . length === 1 ) {
603
+ priceValue = this . _calculatePrice ( config ) ;
604
+ } else if ( element . value ) {
605
+ allowedProduct = this . _getAllowedProductWithMinPrice ( config . allowedProducts ) ;
606
+ priceValue = this . _calculatePrice ( {
607
+ 'allowedProducts' : [
608
+ allowedProduct
609
+ ]
610
+ } ) ;
611
+ }
605
612
606
- if ( ! _ . isEmpty ( priceValue ) ) {
607
- prices . prices = priceValue ;
613
+ if ( ! _ . isEmpty ( priceValue ) ) {
614
+ prices . prices = priceValue ;
615
+ }
608
616
}
609
617
} , this ) ;
610
618
@@ -664,19 +672,20 @@ define([
664
672
_getSimpleProductId : function ( element ) {
665
673
// TODO: Rewrite algorithm. It should return ID of
666
674
// simple product based on selected options.
667
- var allOptions = element . config . options ,
668
- value = element . value ,
669
- config ;
670
-
671
- config = _ . filter ( allOptions , function ( option ) {
672
- return option . id === value ;
673
- } ) ;
674
- config = _ . first ( config ) ;
675
+ if ( element . config ) {
676
+ var allOptions = element . config . options ,
677
+ value = element . value ,
678
+ config ;
675
679
676
- return _ . isEmpty ( config ) ?
677
- undefined :
678
- _ . first ( config . allowedProducts ) ;
680
+ config = _ . filter ( allOptions , function ( option ) {
681
+ return option . id === value ;
682
+ } ) ;
683
+ config = _ . first ( config ) ;
679
684
685
+ return _ . isEmpty ( config ) ?
686
+ undefined :
687
+ _ . first ( config . allowedProducts ) ;
688
+ }
680
689
} ,
681
690
682
691
/**
0 commit comments