@@ -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
@@ -585,26 +591,31 @@ define([
585
591
_getPrices : function ( ) {
586
592
var prices = { } ,
587
593
elements = _ . toArray ( this . options . settings ) ,
588
- allowedProduct ;
594
+ allowedProduct ,
595
+ selected ,
596
+ config ,
597
+ priceValue ;
589
598
590
599
_ . each ( elements , function ( element ) {
591
- var selected = element . options [ element . selectedIndex ] ,
592
- config = selected && selected . config ,
600
+ if ( element . options ) {
601
+ selected = element . options [ element . selectedIndex ] ;
602
+ config = selected && selected . config ;
593
603
priceValue = this . _calculatePrice ( { } ) ;
594
604
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
- }
605
+ if ( config && config . allowedProducts . length === 1 ) {
606
+ priceValue = this . _calculatePrice ( config ) ;
607
+ } else if ( element . value ) {
608
+ allowedProduct = this . _getAllowedProductWithMinPrice ( config . allowedProducts ) ;
609
+ priceValue = this . _calculatePrice ( {
610
+ 'allowedProducts' : [
611
+ allowedProduct
612
+ ]
613
+ } ) ;
614
+ }
605
615
606
- if ( ! _ . isEmpty ( priceValue ) ) {
607
- prices . prices = priceValue ;
616
+ if ( ! _ . isEmpty ( priceValue ) ) {
617
+ prices . prices = priceValue ;
618
+ }
608
619
}
609
620
} , this ) ;
610
621
@@ -664,19 +675,23 @@ define([
664
675
_getSimpleProductId : function ( element ) {
665
676
// TODO: Rewrite algorithm. It should return ID of
666
677
// simple product based on selected options.
667
- var allOptions = element . config . options ,
668
- value = element . value ,
678
+ var allOptions ,
679
+ value ,
669
680
config ;
670
681
671
- config = _ . filter ( allOptions , function ( option ) {
672
- return option . id === value ;
673
- } ) ;
674
- config = _ . first ( config ) ;
682
+ if ( element . config ) {
683
+ allOptions = element . config . options ;
684
+ value = element . value ;
675
685
676
- return _ . isEmpty ( config ) ?
677
- undefined :
678
- _ . first ( config . allowedProducts ) ;
686
+ config = _ . filter ( allOptions , function ( option ) {
687
+ return option . id === value ;
688
+ } ) ;
689
+ config = _ . first ( config ) ;
679
690
691
+ return _ . isEmpty ( config ) ?
692
+ undefined :
693
+ _ . first ( config . allowedProducts ) ;
694
+ }
680
695
} ,
681
696
682
697
/**
0 commit comments