我主要使用Magento的1.7:
[跳到下面我的回答肉的更新。總結:我們學到了什麼?我認爲你使用的是Magento 1.5。但即使是Magento 1.7也不夠好。在Magento 1.8之前,您嘗試使用的功能尚未完全修復錯誤。]
我着手幫助你,因爲我知道使用bundle可以有多複雜。我沒有使用層級定價,因此我在開發服務器上設置了它,並開始逐步完成上面列出的bundle.js
函數。
我發現,讓我困惑了兩兩件事:
一)我tierPrice[]
是使用索引數組0,1,2(我設置爲通過Magento管理三個層次): ![tierPrice object is an array object](https://i.stack.imgur.com/XcPuH.png)
這裏來幫助你是從我的包JSON對象定義一個片段,即從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"}], ...
你的看起來像這樣嗎?
二)所以我的開發服務器上面的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;
}
//...
因此,到最後,我的「價格作爲配置的」最終不正確了。
您認爲如何?你能弄清楚爲什麼你的捆綁對象是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
更新:我已經提到bundle.js從Magento的1.7
我可以在Magento看到1.8捆綁.js已被改進以考慮tierPrice和tierPrice包括和不含稅 - 但也必須伴隨不同的捆綁JSON對象(以保存字段和值爲tierPrice[i].priceInclTax;
和tierPrice[i].priceExclTax;
)
因此,我們可能會現在回答:
一)升級到Magento的1.8
或
B)手動更新只是你的主題bundle.js
從bundle.js
Magento的1.8 代碼和爲JSON對象,文件中的「應用程序/核心/法師/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
並創建您自己的新bundle.php
與此更新getJsonConfig()
我還沒有運行之間的差異這些文件從1.7和1.8這是值得做的,看看是否有其他改變。
所有這一切都假設您可以深入瞭解爲什麼您有tierPrice ['32000-5'],如上所述,比較我的包JSON對象聲明與您的或粘貼在這裏供其他人檢查。
我們學到了什麼?我認爲你使用的是Magento 1.5。但即使是Magento 1.7也不夠好。在Magento 1.8之前,您嘗試使用的功能尚未完全修復錯誤。
Malachy。
在一次奇怪的事件轉變中,我實際上剛剛遇到了模塊解決的第二個問題(使用捆綁定價),現在在Google搜索將我帶回此線程後,現在正在使用它來解決此問題。幹得不錯! –