[英]Opencart show discount price in product featured page
我是opencart
。 我在我的主頁上設置了特色產品。 因此,當人們訪問時,他可以看到所有特色產品及其描述。 現在在這個特色頁面中,我使用<?php echo $product['price']; ?>
顯示了產品價格<?php echo $product['price']; ?>
<?php echo $product['price']; ?>
. 它顯示產品價格沒有任何問題。 現在我想在特色頁面中顯示產品折扣。 那么怎么做呢? 任何幫助和建議將是非常可觀的。
未經測試,但理論上應該有效。
首先,在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 } ?>
最后,在catalog/view/theme//template/module/featured.tpl 中添加這個你想要它顯示的地方:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.