Skip to content

Commit e004888

Browse files
committed
MAGETWO-33325: Stubilize branch before pull request
- Fix configurable test - Removed _priceFormat in flavor priceUtils analogous
1 parent a6c2395 commit e004888

File tree

1 file changed

+11
-31
lines changed

1 file changed

+11
-31
lines changed

app/code/Magento/ConfigurableProduct/view/frontend/web/js/configurable.js

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ define([
77
"jquery",
88
"underscore",
99
"mage/template",
10+
"priceUtils",
11+
"priceBox",
1012
"jquery/ui",
11-
"jquery/jquery.parsequery",
12-
"Magento_Catalog/js/price-box"
13-
], function($, _, mageTemplate){
13+
"jquery/jquery.parsequery"
14+
], function($, _, mageTemplate, utils){
1415

1516
function getPrices(elems){
1617
var prices = {};
@@ -32,6 +33,7 @@ define([
3233
superSelector: '.super-attribute-select',
3334
priceHolderSelector: '.price-box',
3435
state: {},
36+
priceFormat: {},
3537
optionTemplate: '<%= data.label %>' +
3638
'<% if (data.finalPrice.value) { %>' +
3739
' <%= data.finalPrice.formatted %>' +
@@ -65,9 +67,14 @@ define([
6567
*/
6668
_initializeOptions: function() {
6769
var priceBoxOptions = $(this.options.priceHolderSelector).priceBox('option');
70+
6871
if(priceBoxOptions.priceConfig && priceBoxOptions.priceConfig.optionTemplate) {
6972
this.options.optionTemplate = priceBoxOptions.priceConfig.optionTemplate;
7073
}
74+
75+
if(priceBoxOptions.priceConfig && priceBoxOptions.priceConfig.priceFormat) {
76+
this.options.priceFormat = priceBoxOptions.priceConfig.priceFormat;
77+
}
7178
this.options.optionTemplate = mageTemplate(this.options.optionTemplate);
7279

7380
this.options.settings = (this.options.spConfig.containerId) ?
@@ -388,37 +395,10 @@ define([
388395
return {
389396
value: price,
390397
name: name,
391-
formatted: this._formatPrice(price, true)
398+
formatted: utils.formatPrice(price, this.options.priceFormat, true)
392399
};
393400
},
394401

395-
/**
396-
* Format's the price of a configurable option's choice. Add sign as needed, round,
397-
* and format the rounded price with the appropriate sign.
398-
* @private
399-
* @param price An option choice's price
400-
* @param showSign Whether to show the sign as '-' or '+' in the formatted price.
401-
* @return {String} Returns the formatted price with or without the sign.
402-
*/
403-
_formatPrice: function(price, showSign) {
404-
var str = '';
405-
price = parseFloat(price);
406-
if (showSign) {
407-
if (price < 0) {
408-
str += '-';
409-
price = -price;
410-
}
411-
else {
412-
str += '+';
413-
}
414-
}
415-
var roundedPrice = (Math.round(price * 100) / 100).toString();
416-
str = (this.options.spConfig.prices && this.options.spConfig.prices[roundedPrice]) ?
417-
str + this.options.spConfig.prices[roundedPrice] :
418-
str + this.options.spConfig.template.replace(/#\{(.*?)\}/, price.toFixed(2));
419-
return str;
420-
},
421-
422402
/**
423403
* Removes an option's selections.
424404
* @private

0 commit comments

Comments
 (0)