@@ -7,11 +7,12 @@ define([
7
7
'jquery' ,
8
8
'underscore' ,
9
9
'mage/template' ,
10
+ 'mage/translate' ,
10
11
'priceUtils' ,
11
12
'priceBox' ,
12
13
'jquery/ui' ,
13
14
'jquery/jquery.parsequery'
14
- ] , function ( $ , _ , mageTemplate ) {
15
+ ] , function ( $ , _ , mageTemplate , $t , priceUtils ) {
15
16
'use strict' ;
16
17
17
18
$ . widget ( 'mage.configurable' , {
@@ -38,7 +39,10 @@ define([
38
39
*
39
40
* @type {String }
40
41
*/
41
- gallerySwitchStrategy : 'replace'
42
+ gallerySwitchStrategy : 'replace' ,
43
+ tierPriceTemplateSelector : '#tier-prices-template' ,
44
+ tierPriceBlockSelector : '[data-role="tier-price-block"]' ,
45
+ tierPriceTemplate : ''
42
46
} ,
43
47
44
48
/**
@@ -84,6 +88,7 @@ define([
84
88
options . priceFormat = priceBoxOptions . priceFormat ;
85
89
}
86
90
options . optionTemplate = mageTemplate ( options . optionTemplate ) ;
91
+ options . tierPriceTemplate = $ ( this . options . tierPriceTemplateSelector ) . html ( ) ;
87
92
88
93
options . settings = options . spConfig . containerId ?
89
94
$ ( options . spConfig . containerId ) . find ( options . superSelector ) :
@@ -259,6 +264,7 @@ define([
259
264
}
260
265
this . _reloadPrice ( ) ;
261
266
this . _displayRegularPriceBlock ( this . simpleProduct ) ;
267
+ this . _displayTierPriceBlock ( this . simpleProduct ) ;
262
268
this . _changeProductImage ( ) ;
263
269
} ,
264
270
@@ -513,6 +519,31 @@ define([
513
519
var galleryObject = element . data ( 'gallery' ) ;
514
520
515
521
this . options . mediaGalleryInitial = galleryObject . returnCurrentImages ( ) ;
522
+ } ,
523
+
524
+ /**
525
+ * Show or hide tier price block
526
+ *
527
+ * @param {* } optionId
528
+ * @private
529
+ */
530
+ _displayTierPriceBlock : function ( optionId ) {
531
+ if ( typeof optionId != 'undefined' &&
532
+ this . options . spConfig . optionPrices [ optionId ] . tierPrices != [ ]
533
+ ) {
534
+ var options = this . options . spConfig . optionPrices [ optionId ] ;
535
+ if ( this . options . tierPriceTemplate ) {
536
+ var tierPriceHtml = mageTemplate ( this . options . tierPriceTemplate , {
537
+ 'tierPrices' : options . tierPrices ,
538
+ '$t' : $t ,
539
+ 'currencyFormat' : this . options . spConfig . currencyFormat ,
540
+ 'priceUtils' : priceUtils
541
+ } ) ;
542
+ $ ( this . options . tierPriceBlockSelector ) . html ( tierPriceHtml ) . show ( ) ;
543
+ }
544
+ } else {
545
+ $ ( this . options . tierPriceBlockSelector ) . hide ( ) ;
546
+ }
516
547
}
517
548
} ) ;
518
549
0 commit comments