浏览文章
文章信息
Magento2 【前端】获取格式的价格数据|get format price
13866
代码:
define( [ 'jquery', 'mage/storage', 'Magento_Checkout/js/model/quote', 'Magento_Catalog/js/price-utils', 'Magento_Checkout/js/view/summary/abstract-total', 'Magento_Checkout/js/model/url-builder' ], function ($, storage, quote, priceUtils, Component, urlBuilder) { "use strict"; let isVisible = false; let discount = 0; // 获取Quote的优惠 storage.get( urlBuilder.createUrl('/aiweline/quote/upsell') ).done(function (response) { if (response.upsell_discount_amount) { isVisible = true; discount = upsell_discount_amount; } }).error(function (response) { errorProcessor.process(response); }).always(function () { }); return Component.extend({ defaults: { template: 'Aiweline_Upsell/checkout/summary/upsell-discount' }, isDisplayedCustomdiscount: function () { return isVisible; }, getCustomDiscount: function () { return priceUtils.formatPrice(discount, quote.getPriceFormat()); } }); } );重点:
return priceUtils.formatPrice(discount, quote.getPriceFormat());