Php Opencart在产品特色页面中显示折扣价格

Php Opencart在产品特色页面中显示折扣价格,php,opencart,Php,Opencart,我是新来的opencart。我已经在我的主页上设置了特色产品。因此,当一个人访问时,他可以看到所有的特色产品及其描述。现在,在这个特色页面中,我使用显示了产品价格。这是显示产品价格没有任何问题。 现在我想在特色页面中显示产品折扣。那怎么做呢?任何帮助和建议都是值得赞赏的。未经测试,但在理论上应该有效 首先,在catalog/language/english/module/featured.php中添加以下行: $_['text_discount'] = '%s or more %s';

我是新来的
opencart
。我已经在我的主页上设置了特色产品。因此,当一个人访问时,他可以看到所有的特色产品及其描述。现在,在这个特色页面中,我使用
显示了产品价格。这是显示产品价格没有任何问题。
现在我想在特色页面中显示产品折扣。那怎么做呢?任何帮助和建议都是值得赞赏的。

未经测试,但在理论上应该有效

首先,在
catalog/language/english/module/featured.php中添加以下行:

$_['text_discount']     = '%s or more %s';
<?php foreach ($product['discounts'] as $discount) { ?>
<?php echo sprintf($text_discount, $discount['quantity'], $discount['price']); ?><br />
<?php } ?>
接下来,在
目录/controller/module/featured.php中执行以下操作:

$_['text_discount']     = '%s or more %s';
<?php foreach ($product['discounts'] as $discount) { ?>
<?php echo sprintf($text_discount, $discount['quantity'], $discount['price']); ?><br />
<?php } ?>
$this->data['button\u cart']=$this->language->get('button\u cart')之后添加:

$this->data['text_discount'] = $this->language->get('text_discount');
$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')))
    );
}
'discounts'  => $product_discounts
$product\u info=$this->model\u catalog\u product->getProduct($product\u id)之后添加:

$this->data['text_discount'] = $this->language->get('text_discount');
$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')))
    );
}
'discounts'  => $product_discounts
'href'=>$this->url->link('product/product','product\u id='。$product\u info['product\u id'))之后,
添加:

$this->data['text_discount'] = $this->language->get('text_discount');
$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')))
    );
}
'discounts'  => $product_discounts
最后,在
catalog/view/theme//template/module/featured.tpl
中,将此添加到您希望显示的任何位置:

$_['text_discount']     = '%s or more %s';
<?php foreach ($product['discounts'] as $discount) { ?>
<?php echo sprintf($text_discount, $discount['quantity'], $discount['price']); ?><br />
<?php } ?>



最后,在catalog/view/theme//template/module/featured.tpl中,在希望显示的任何位置添加以下内容:



在进行任何否决投票之前,任何建议和建议都会更有帮助。您尝试过什么?产品折扣存储在
$Product['special']
中,因为OpenCart在折扣(如果您购买5件,价格会打折;如果您购买10件,价格会打折更多,等等)和特价-限时价格特别折扣之间存在差异。这一特殊功能出现在所有显示产品的模块中,甚至在特色模块中。可能你玩过模板,删除了那段代码…谢谢你的回复。但我想要的是折扣价格,而不是这里的实际价格。我已经在特色模板中得到了价格,但现在我想要的是产品折扣价格,可以在产品详细信息页面中看到。我想在特色产品中显示。感谢您的回复,但当我使用您的总代码并进行
打印时,
catalog/view/theme//template/module/featured.tpl
中显示了类似“未定义索引:数量”的错误($折扣)内部
/catlog/controller/module
然后结果是这样的
数组([0]=>数组([product\u discount\u id]=>483[product\u id]=>43[customer\u group\u id]=>8[quantity]=>2[priority]=>1[priority]=>345.0000[date\u start]=>0000-00-00[date\u end]=>0000-00-00][1]=>数组([product\u discount\u id]))
今晚,我将尝试在我的开发服务器上测试上述代码,然后与您联系。我还没来得及进行测试-查看上面的阵列,它正在正确构建一个阵列,而第二个阵列缺少元素-您对该产品有多少折扣?