這聽起來很有趣,所以我決定嘗試一下。
我把它通過修改文件的工作:
應用程序/代碼/社區/ OrganicInternet/SimpleConfigurableProducts /目錄/產品/ Price.php
(它複製到代碼/本地/ ...目錄樹理智的緣故; d)
既然你不想實際「價格從:」文,你可以註釋掉這些行:
if ($product->getMaxPossibleFinalPrice() != $product->getFinalPrice()) {
$extraHtml .= $this->__('Price From:');
}
現在,這裏是它變得有趣。
return substr_replace($priceHtml, $extraHtml, strpos($priceHtml, $htmlToInsertAfter)+strlen($htmlToInsertAfter),0);
到這些行:我基本上是通過改變這一行復制自己的插入方法
$finalHtml = substr_replace($priceHtml, $extraHtml, strpos($priceHtml, $htmlToInsertAfter)+strlen($htmlToInsertAfter),0);
if ($product->getMaxPossibleFinalPrice() != $product->getFinalPrice()) {
$finalPriceHtml = ' - $' . strval(number_format($product->getMaxPossibleFinalPrice(),2,'.',','));
$finalPriceInsertAfter = strval(number_format($product->getFinalPrice(),2,'.',','));
$finalHtml = substr_replace($finalHtml, $finalPriceHtml, strpos($finalHtml, $finalPriceInsertAfter)+strlen($finalPriceInsertAfter),0);
}
return $finalHtml;
基本上照搬原來的插入配置價格標籤的方法,但這次將最高價格默認價格後。雖然它不會爲多貨幣商店真正起作用,但您必須獲取商店貨幣運營商並根據所用貨幣更改number_format。您可能可以使用內置的貨幣格式方法,但我並不熟悉它,因爲我沒有在多貨幣商店工作過。
給它一個跑步,讓我知道你是否有任何問題。
不得不改變我的上面的代碼使用round()到number_format()。 round()會導致產品價格整體出現問題($ 5.00 vs $ 5.98)。 – Jason 2013-05-29 18:44:01