Joe*_*ing 0 javascript magento
我在Magento 1.7安装上有一个产品页面,其产品具有分层定价.它应该说买入4并保存13%,它在一瞬间完成,然后13%的值被100%覆盖(这是不正确的).我只能假设页面上有一些错误的JavaScript导致了这种情况,但我不知道如何找到它.有人可以给我一些关于如何找到并修复这个bug的建议吗?
查看了Chrome检查器中的HTML元素:class="benefit".
在"资源"选项卡中搜索".benefit",1匹配,在loupe.js文件中.
去了Scripts选项卡,loupe.js文件,美化代码,搜索".benefit".
$$('.benefit').each(function(el) {
var parsePrice = function(html) {
return parseFloat(/\d+\.?\d*/.exec(html));
};
var container = $(this.containers[3]) ? this.containers[3] : this.containers[0];
var price = parsePrice($(container).innerHTML);
var tierPrice = $$('.price.tier-' + i);
tierPrice = tierPrice.length ? parseInt(tierPrice[0].innerHTML, 10) : 0;
var $percent = Selector.findChildElements(el, ['.percent.tier-' + i]);
$percent.each(function(el) {
el.innerHTML = Math.ceil(100 - ((100 / price) * tierPrice));
});
}, this);
Run Code Online (Sandbox Code Playgroud)
Chrome Inspector在不到一分钟的时间内找到了该脚本.
现在,这是罪魁祸首:
el.innerHTML = Math.ceil(100 - ((100 / price) * tierPrice));
Run Code Online (Sandbox Code Playgroud)
这是一个简单的数学计算.我不知道是什么tierPrice,但我相信你可以找到适合你的业务的正确计算(Math.ceil将数字四舍五入).
| 归档时间: |
|
| 查看次数: |
713 次 |
| 最近记录: |