如何在特色,畅销书和相关模块上打印税前金额?我尝试使用$product
数组,但没有关税税额的关键。
答案 0 :(得分:0)
打开畅销书控制器文件(catalog / controller / module / bestseller.php),然后修改此部分:
$this->data['products'][] = array(
'product_id' => $result['product_id'],
'thumb' => $image,
'name' => $result['name'],
'price' => $price,
'special' => $special,
'rating' => $rating,
'reviews' => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
'href' => $this->url->link('product/product', 'product_id=' . $result['product_id']),
);
...在products数组中声明了两个名为price_ex_tax
和special_ex_tax
的新变量:
$this->data['products'][] = array(
'product_id' => $result['product_id'],
'thumb' => $image,
'name' => $result['name'],
'price' => $price,
'price_ex_tax' => $this->currency->format($result['price']),
'special' => $special,
'special_ex_tax' => $this->currency->format($result['special'],
'rating' => $rating,
'reviews' => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
'href' => $this->url->link('product/product', 'product_id=' . $result['product_id']),
);
然后,您可以访问畅销视图文件中的新变量(catalog / view / theme / your_theme_name / template / module / bestseller.tpl)。寻找这一部分:
<?php if ($product['price']) { ?>
<div class="price">
<?php if (!$product['special']) { ?>
<?php echo $product['price']; ?>
<?php } else { ?>
<span class="price-old"><?php echo $product['price']; ?></span> <span class="price-new"><?php echo $product['special']; ?></span>
<?php } ?>
</div>
<?php } ?>
...并替换为:
<?php if ($product['price']) { ?>
<div class="price">
<?php if (!$product['special']) { ?>
<?php echo $product['price'] . "(" . $product['price_ex_tax'] . ")"; ?>
<?php } else { ?>
<span class="price-old"><?php echo $product['price'] . "(" . $product['price_ex_tax'] . ")"; ?></span> <span class="price-new"><?php echo $product['special'] . "(" . $product['special_ex_tax'] . ")"; ?></span>
<?php } ?>
</div>
<?php } ?>
您也可以为特色模块重复相同的步骤(控制器文件:catalog / controller / module / featured.php - 视图文件:catalog / view / theme / your_theme_name / template / module / featured.tpl)。您可以在产品控制器文件(catalog / controller / product / product.php)中找到相关产品,并可以在产品视图文件(catalog / view / theme / your_theme_name / product / product.tpl)中显示它。我希望这会有所帮助。
答案 1 :(得分:0)
对我来说,当我将它添加到控制器文件时它起作用:catalog / controller / module / featured.php
正好在$ this-&gt;数据[&#39;产品&#39;] [] =数组之上(添加以下行:
$extax = $this->currency->format($product_info['price']);
然后在数组中(添加:
'extax' => $extax,
最后转到catalog / view / theme / your_theme_name / template / module / featured.tpl并添加:
<?php echo $product['extax']; ?>
您希望在哪里显示无税价格或
<?php echo $product['price'] . "(" . $product['extax'] . ")"; ?>
显示inc和exc,希望有所帮助。