@@ -360,7 +360,12 @@ define([
360
360
index = 1 ,
361
361
allowedProducts ,
362
362
i ,
363
- j ;
363
+ j ,
364
+ basePrice = parseFloat ( this . options . spConfig . prices . basePrice . amount ) ,
365
+ optionPriceLabel ,
366
+ optionFinalPrice ,
367
+ optionPriceDiff ,
368
+ optionPrices = this . options . spConfig . optionPrices ;
364
369
365
370
this . _clearSelect ( element ) ;
366
371
element . options [ 0 ] = new Option ( '' , '' ) ;
@@ -374,6 +379,8 @@ define([
374
379
if ( options ) {
375
380
for ( i = 0 ; i < options . length ; i ++ ) {
376
381
allowedProducts = [ ] ;
382
+ optionPriceLabel = '' ;
383
+ optionPriceDiff = 0 ;
377
384
378
385
/* eslint-disable max-depth */
379
386
if ( prevConfig ) {
@@ -387,14 +394,27 @@ define([
387
394
}
388
395
} else {
389
396
allowedProducts = options [ i ] . products . slice ( 0 ) ;
397
+ if ( typeof allowedProducts [ 0 ] !== "undefined"
398
+ && typeof optionPrices [ allowedProducts [ 0 ] ] !== "undefined" ) {
399
+
400
+ optionFinalPrice = parseFloat ( optionPrices [ allowedProducts [ 0 ] ] . finalPrice . amount ) ;
401
+ optionPriceDiff = optionFinalPrice - basePrice ;
402
+
403
+ if ( optionPriceDiff !== 0 ) {
404
+ options [ i ] . label = options [ i ] . label + ' ' + priceUtils . formatPrice (
405
+ optionPriceDiff ,
406
+ this . options . priceFormat ,
407
+ 1 ) ;
408
+ }
409
+ }
390
410
}
391
411
392
412
if ( allowedProducts . length > 0 ) {
393
413
options [ i ] . allowedProducts = allowedProducts ;
394
414
element . options [ index ] = new Option ( this . _getOptionLabel ( options [ i ] ) , options [ i ] . id ) ;
395
415
396
416
if ( typeof options [ i ] . price !== 'undefined' ) {
397
- element . options [ index ] . setAttribute ( 'price' , options [ i ] . prices ) ;
417
+ element . options [ index ] . setAttribute ( 'price' , options [ i ] . price ) ;
398
418
}
399
419
400
420
element . options [ index ] . config = options [ i ] ;
0 commit comments