在很多Magento的模板中并未在分类页对打折产品添加**% Off或You Save $**字样的折扣信息,可以通过如下方式来进行添加:
找到app/design/frontend/base/default/template/catalog/product/price.phtml文件,将price.phtml文件拷到所使用主题的相应位置,如app/design/frontend/default/YOURTEMPLATE/template/catalog/product/price.phtml。
打开price.phtml文件,找到如下代码:
<?php endif; /* if ($_finalPrice == $_price): */ ?>
在该段代码的上方添加如下代码
<?php // Show discounted percentage and price ?> <?php if($_finalPrice < $_price): ?> <?php $_savePercent = 100 - round(($_finalPrice / $_price) * 100); $_saveAmount = number_format(($_price - $_finalPrice), 2); ?> <p class="yousave"> <span class="price-label label">You Save: </span> <span class="price"> <strong class="save-amount">$<?php echo $_saveAmount; ?></strong> (<?php echo $_savePercent; ?>%) </span> </p> <?php endif; ?> <?php // Show discounted percentage and price ?>
其中的文字也可根据个人需要进行适当调整,并在style.css或其它CSS文件中来调整显示的样式,网上有一段访Amazon显示的一段CSS代码可供参考:
/********** < Product Prices */ .price { white-space:nowrap !important; } .price-label { font:normal 12px/15px verdena, Arial, Helvetica, sans-serif; white-space:nowrap; display:inline-block; width:80px; text-align:right; color:#666; } .price-box { margin:5px 0 10px; } .price-box .price { font-size:13px; line-height:22px;font-weight:bold; color:#3399ff; } /* Regular price */ .regular-price { color:#3399ff; } .regular-price .price { font-size:18px; font-weight:normal; color:#900; font-family:verdana, arial, helvetica, sans-serif;} .product-view .regular-price .price {} .product-view .regular-price .price:before { content:"Price: "; color:#666; font:normal 12px/15px verdena, Arial, Helvetica, sans-serif;} /* Old price */ .old-price { margin:0; } .old-price .price-label { } .old-price .price { font-weight:normal; font-size:13px; color:#000; text-decoration:line-through; } /* Special price */ .special-price { margin:0; } .special-price .price-label { } .special-price .price { font-size:18px; font-weight:normal; color:#900; font-family:verdana, arial, helvetica, sans-serif;} /* You save price */ .yousave { margin:0; } .yousave .price-label { } .yousave .price { font-weight:normal; color:#900; font-family:verdana, arial, helvetica, sans-serif;}