首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在产品网格中显示产品批量订单的折扣?

如何在产品网格中显示产品批量订单的折扣?
EN

Stack Overflow用户
提问于 2018-03-27 10:26:06
回答 1查看 115关注 0票数 0

OpenCartJournal模板合作,我有几种产品具有批量订购折扣。在产品网格中显示它们时,我希望显示最低折扣价格,而不是常规价格(如果产品有折扣)。我已经了解了OpenCart的MVC系统的基本知识,但我不知道访问category.tpl文件中的折扣数据的最佳方法,因为它不是$product的一部分。

访问product.tpl中的折扣数据是使用$discounts数组完成的。我可以使用$this->journal2->settings->get()函数在category.tpl或者我需要在模型中调整访问数据吗?

EN

回答 1

Stack Overflow用户

发布于 2018-03-27 11:43:15

你必须加上

代码语言:javascript
运行
复制
$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'])
            );
        }

在此之前:

代码语言:javascript
运行
复制
$data['products'][] = array(
    'product_id'  => $result['product_id'],
    'thumb'       => $image,

在category.php & add中

代码语言:javascript
运行
复制
'discount'    => $discounts,

之后

代码语言:javascript
运行
复制
$data['products'][] = array(
    'product_id'  => $result['product_id'],
    'thumb'       => $image,

然后,您可以访问$discount对category.tpl中的每个产品。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49510444

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档