gpt4 book ai didi

javascript - 根据 Netsuite Suitecommerce Advanced 中的价格水平计算折扣

转载 作者:行者123 更新时间:2023-12-03 06:44:11 25 4
gpt4 key购买 nike

我正在尝试在 ItemsKeyMapping.js 中创建一个函数,用于计算客户在产品上节省的百分比。我是 javascript 新手,一直在使用教程。这就是我所拥有的:

// @property _DiscountPercent calculates the percentage between customers price and MSRP
, _DiscountPercent: function (item)
{
var attributes = item.get('onlinecustomerprice') || ('pricelevel15');

if ((pricelevel15 != 0) && (onlinecustomerprice != 0))

{
DiscountPercent = (1 - pricelevel15 / onlinecustomerprice) * 100;
}
else
{
DiscountPercent = null;
}
return 'DiscountPercent';
}

有熟悉 SCA Mont Blanc 的人可以帮助我完成这个吗?谢谢。

最佳答案

试试这个:

,   _DiscountPercent: function (item)
{
var normalPrice= item.get('onlinecustomerprice')
var discountedPrice= item.get('pricelevel15');
var DiscountPercent = null;

if ((discountedPrice > 0) && (normalPrice > 0))

{
DiscountPercent = (1 - discountedPrice / normalPrice) * 100;
}

return DiscountPercent;
}

关于javascript - 根据 Netsuite Suitecommerce Advanced 中的价格水平计算折扣,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37822108/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com