[英]Opencart 1.5.6 How to show price, with and without tax in shopping cart?
I want to show the individual price of each product, tax included and tax excluded on the shopping cart page. 我想在购物车页面上显示每种产品的单独价格,含税和不含税。 I configured opencart to display prices including tax, but I want to add a column to show the price without tax.
我将opencart配置为显示含税价格,但我想添加一列以显示不含税价格。 I have Opencart 1.5.6.
我有Opencart 1.5.6。 Please can someone help me ?.
请有人可以帮助我吗? I tried to modify
cart.php
and cart.tpl
but I have not succeeded, $price_extax
shows last price in all products in shopping cart. 我试图修改
cart.php
和cart.tpl
但没有成功, $price_extax
显示购物车中所有产品的最后价格。 Thank You. 谢谢。
In cart.tpl
I added following code: It shows column tittle: 在
cart.tpl
我添加了以下代码:它显示列标题:
<td class="price"><?php echo "Price ex-tax"; ?></td>
It shows price: 它显示价格:
<td class="price"><?php echo $price_extax; ?></td>
In cart.php I added following code: 在cart.php中,我添加了以下代码:
$this->data['price_extax'] = $this->currency->format($this->tax->calculate($product['price'],$product['tax_class_id'], $this->config->get('config_tax'))/1.12); //My code (tax is 12%)
You cannot declare a single variable or property and expect it to magically become part of the product array. 您不能声明单个变量或属性并期望它神奇地成为产品数组的一部分。 Learning some php basics will go a long way.
学习一些php基础知识将有很长的路要走。
Also, there is no need to use tax method here if your goal is to omit taxes. 另外,如果您的目标是忽略税款,则无需在此处使用税款方法。 You can simply use the currency->format method without it.
没有它,您可以简单地使用currency-> format方法。
You need to make price_extax
part of the product array. 您需要使
price_extax
成为产品数组的一部分。 Immediately after $this->data['products'][] = array(
add something like: 在
$this->data['products'][] = array(
添加以下内容:
'extax' => $this->currency->format($product['price']),
Then your table cell should hold $product['extax']
然后您的表格单元格应包含
$product['extax']
SOLVED 解决了
Thanks to billynoah and shaddyx for your help. 感谢Billynoah和shaddyx的帮助。 The solution to the problem, which has worked for me is:
对我有用的问题解决方案是:
In catalog/controller/checkout/cart.php
I added (only commented line //): 我在
catalog/controller/checkout/cart.php
添加了(仅注释行//):
$this->data['products'][] = array(
'extax' => $this->currency->format($product['price']), //Gets Price tax excluded
In catalog/view/theme/default/template/checkout/cart.tpl
I added (only commented lines //): 在
catalog/view/theme/default/template/checkout/cart.tpl
我添加了(仅注释行//):
<td class="price"><?php echo $column_price; ?></td>
<td class="price"><?php echo "Price (tax excluded)"; ?></td> //Shows column tittle
<td class="total"><?php echo $column_total; ?></td>
and 和
<td class="price"><?php echo $product['price']; ?></td>
<td class="price"><?php echo $product['extax']; ?></td> //Shows price tax excluded
<td class="total"><?php echo $product['total']; ?></td>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.