我主要使用 Magento 1.7 并且:
[跳到下面的更新了解我的回答。摘要:我们学到了什么?我认为您使用的是 Magento 1.5。但即使是 Magento 1.7 也不够好。您尝试使用的功能在 Magento 1.8 之前尚未完全修复错误。]
我打算在这里为您提供帮助,因为我知道使用捆绑包可能会很复杂。我没有使用分级定价,所以我在我的开发服务器上进行了设置,并开始逐步执行您上面列出的 bundle.js 函数。
我发现了两件事让我感到困惑:
a) 我的 tierPrice[] 是 一个索引为 0,1,2 的数组(我通过 Magento 管理员设置了三层):
这里帮助你的是我的bundle JSON对象定义中的一个sn-p,即来自app/design/frontend/themename/default/template/bundle/catalog/product/view/type/bundle/bundle.phtml
<script type="text/javascript">
//<![CDATA[
var bundle = new Product.Bundle(<?php echo $this->getJsonConfig() ?>);
//]]>
</script>
片段:
var bundle = new Product.Bundle({"options":{"837":{"selections":{"4205":{"qty":1,"customQty":"1","price":52,"priceInclTax":52,"priceExclTax":52,"priceValue":0,"priceType":"0","tierPrice":[{"price_id":"4","website_id":"0","all_groups":"1","cust_group":32000,"price":29.99,"price_qty":"2.0000","website_price":"29.9900"},{"price_id":"5","website_id":"0","all_groups":"1","cust_group":32000,"price":18.88,"price_qty":"3.0000","website_price":"18.8800"},{"price_id":"6","website_id":"0","all_groups":"1","cust_group":32000,"price":7.77,"price_qty":"4.0000","website_price":"7.7700"}], ...
你的像这样吗?
b) 所以在我的开发服务器上,在上面的 for 循环之后,bundle.js 已经正确识别了一个等级价格但是在代码的后面,可变价格会根据显示的含税或不含税价格被重置税,即这个代码:
//file: skin/frontend/theme/default/js/bundle.js
//function: selectionPrice()
//...
selection = this.config.options[optionId].selections[selectionId];
if (selection.priceInclTax !== undefined) {
priceInclTax = selection.priceInclTax;
price = selection.priceExclTax !== undefined ? selection.priceExclTax : selection.price;
} else {
priceInclTax = price;
}
//...
因此,最后,我的“配置价格”也以不正确告终。
你怎么看?你能弄清楚为什么你的 bundle 对象是 tierPrice['32000-5'] 而不是 tierPrice[0] 吗?当bundle.js 尝试应用显示价格含税或不含税时,您的等级价格是否被覆盖?
(而且似乎没有默认方式知道 tierPrice 是含税还是不含税。我在这里闻到了一个错误)。
实际上,您可能会对这个错误报告感兴趣。http://www.magentocommerce.com/bug-tracking/issue?issue=11477(需要登录)] 并且有 some other bugs tracked on tier pricing 这将有助于解释 Magento 1.8 中的代码更新
更新:我指的是 Magento 1.7 中的 bundle.js
我可以在 Magento 1.8 中看到 bundle.js 已经改进,以考虑 tierPrice 和 tierPrice 包括和不包括税-但还必须伴随不同的捆绑 JSON 对象(以保存 tierPrice[i].priceInclTax; 的字段和值和tierPrice[i].priceExclTax;)
所以,我们现在可能有一个答案:
a) 升级到 Magento 1.8
或
b) 在文件 'app/core/Mage/Bundle/Block/Catalog /Product/View/Type/Bundle.php',通过在 1.7 和 1.8 之间检查,
Magento 1.7
//file app/core/Mage/Bundle/Block/Catalog/Product/View/Type/Bundle.php
//class Mage_Bundle_Block_Catalog_Product_View_Type_Bundle
//function getJsonConfig()
//...
$tierPrices = $_selection->getTierPrice();
foreach ($tierPrices as &$tierPriceInfo) {
$tierPriceInfo['price'] = $coreHelper->currency($tierPriceInfo['price'], false, false);
}
unset($tierPriceInfo); // break the reference with the last element
//...
Magento 1.8
//file app/core/Mage/Bundle/Block/Catalog/Product/View/Type/Bundle.php
//class Mage_Bundle_Block_Catalog_Product_View_Type_Bundle
//function getJsonConfig()
//...
$tierPrices = $_selection->getTierPrice();
foreach ($tierPrices as &$tierPriceInfo) {
$tierPriceInfo['price'] = $coreHelper->currency($tierPriceInfo['price'], false, false);
$tierPriceInfo['priceInclTax'] = $taxHelper->getPrice($_selection, $tierPriceInfo['price'], true);
$tierPriceInfo['priceExclTax'] = $taxHelper->getPrice($_selection, $tierPriceInfo['price']);
}
unset($tierPriceInfo); // break the reference with the last element
//...
因此,如果您手动更新旧版本的 Magento,您将需要扩展类 Mage_Bundle_Block_Catalog_Product_View_Type_Bundle 并使用更新后的 getJsonConfig() 创建自己的新 bundle.php
我没有在 1.7 和 1.8 的这些文件之间运行差异,这值得做,看看是否有其他变化。
所有这一切都假设您可以深入了解为什么拥有 tierPrice['32000-5'] 因此,正如我上面提到的,将我的捆绑 JSON 对象声明与您的进行比较,或者将您的粘贴到此处以供其他人检查。
我们学到了什么?我认为您使用的是 Magento 1.5。但即使是 Magento 1.7 也不够好。您尝试使用的功能在 Magento 1.8 之前尚未完全修复错误。
马拉奇。