这听起来很有趣,所以我决定尝试一下。
我把它通过修改文件的工作:
应用程序/代码/社区/ 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