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