与OpenCart和Journal模板合作,我有几种产品具有批量订购折扣。在产品网格中显示它们时,我希望显示最低折扣价格,而不是常规价格(如果产品有折扣)。我已经了解了OpenCart的MVC系统的基本知识,但我不知道访问category.tpl文件中的折扣数据的最佳方法,因为它不是$product的一部分。
访问product.tpl中的折扣数据是使用$discounts数组完成的。我可以使用$this->journal2->settings->get()函数在category.tpl或者我需要在模型中调整访问数据吗?
发布于 2018-03-27 11:43:15
你必须加上
$discounts_data = $this->model_catalog_product->getProductDiscounts($result['product_id']);
$discounts = array();
foreach ($discounts_data as $discount) {
$discounts[] = array(
'quantity' => $discount['quantity'],
'price' => $this->currency->format($this->tax->calculate($discount['price'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency'])
);
}在此之前:
$data['products'][] = array(
'product_id' => $result['product_id'],
'thumb' => $image,在category.php & add中
'discount' => $discounts,之后
$data['products'][] = array(
'product_id' => $result['product_id'],
'thumb' => $image,然后,您可以访问$discount对category.tpl中的每个产品。
https://stackoverflow.com/questions/49510444
复制相似问题