顧客の Magento サイトを 1.7.0.2 にアップグレードした後、本当にバグが発生し始めたので、これに少し時間を費やしました。
これには 2 つの部分があります。場所と修正を記載しますが、これらはアップグレードの証明にはなりません (そのため、ファイルのコピーを作成してテーマ固有のフォルダーに配置することをお勧めしますが、問題のJSファイルで可能かどうかはわかりません)。
1) 修正を表示
ファイル内/design/frontend/base/default/template/catalog/product/view/tierprices.phtml
行を置き換える必要があります32-34
$_product = $this->getProduct();
$_tierPrices = $this->getTierPrices();
$_finalPriceInclTax = $this->helper('tax')->getPrice($_product, $_product->getFinalPrice(), true);
次のコードを使用します。
$_product = $this->getProduct();
$_tierPrices = array();
foreach($this->getTierPrices() as $index => $info) {
$_tierPrices[$index] = $info;
$_tierPrices[$index]['formated_price'] = str_replace('class="price"', 'class="price tier-'.$index.'"', $info['formated_price']);
$_tierPrices[$index]['formated_price_incl_tax'] = str_replace('class="price"', 'class="price tier-'.$index.' tier-'.$index.'-incl-tax"', $info['formated_price_incl_tax']);
}
$_finalPriceInclTax = $this->helper('tax')->getPrice($_product, $_product->getFinalPrice(), true);
これにより、すでに把握していたように、クラスが正しくレンダリングされないという問題が修正されます。ここで私はこのコードを見つけました- すべての問題を修正したわけではありませんが、JS が変更されました。
2)JS修正
ファイル内のjs/Varien/product.js
行を置き換える必要があります757-769
:
$$('.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);
これとともに:
//
// Code fixed to prevent the redundant inner loop and to use actual tiered pricing in calculation
// It also takes the optional price variants into consideration (eg: +£2 for a blue tshirt)
// Note: I've made this comment deliberately large, to keep the line numbers in sync
//
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);
$$('.percent.tier-' + i).each(function (el) {
el.innerHTML = Math.ceil(100 - ((100 / price) * (this.tierPrices[i] + parseFloat(optionPrices))));
}, this);
これにより、少なくとも 1 人の命が数時間救われることを願っています。
T