私はに不慣れですopencart
。ホームページにおすすめ商品を設定しました。そのため、訪問すると、すべての注目の製品とその説明を見ることができます。この特集ページでは、 を使用して製品価格を表示してい<?php echo $product['price']; ?>
ます。問題なく商品価格を表示しています。ここで、注目のページに製品の割引を表示したいと考えています。では、どうやってそれを行うのですか?ヘルプと提案は非常に高く評価されます。
6133 次
2 に答える
3
テストされていませんが、理論上は機能するはずです。
まず、catalog/language/english/module/featured.php
次の行を追加します。
$_['text_discount'] = '%s or more %s';
次に、次の操作をcatalog/controller/module/featured.php
行います。
$this->data['button_cart'] = $this->language->get('button_cart');
追加後:
$this->data['text_discount'] = $this->language->get('text_discount');
$product_info = $this->model_catalog_product->getProduct($product_id);
追加後:
$discounts = $this->model_catalog_product->getProductDiscounts($product_id);
$product_discounts[] = array();
foreach ($discounts as $discount) {
$product_discounts[] = array(
'quantity' => $discount['quantity'],
'price' => $this->currency->format($this->tax->calculate($discount['price'], $product_info['tax_class_id'], $this->config->get('config_tax')))
);
}
'href' => $this->url->link('product/product', 'product_id=' . $product_info['product_id']),
追加後:
'discounts' => $product_discounts
最後に、catalog/view/theme/<theme>/template/module/featured.tpl
表示したい場所にこれを追加します。
<?php foreach ($product['discounts'] as $discount) { ?>
<?php echo sprintf($text_discount, $discount['quantity'], $discount['price']); ?><br />
<?php } ?>
于 2012-11-21T09:22:00.693 に答える