Отображаемая цена, включая налог
В настоящее время мы используем этот код для отображения цен на товары на нашей домашней странице. Но это действительно увеличивает цену без учета налога.
Как я могу отредактировать код, в котором цена будет включать налог?
<?php
$first_amount_before_split = substr($_product->getPrice(), 0, -2);
$my_array = explode(".", $first_amount_before_split);
?>
<a href="<?php echo $_product->getProductUrl() ?>">
<span class="sticker-wrapper top-right home">
<span class="sticker prijs">
<span class="main-price"><?php echo $my_array[0]; ?>,</span>
<span class="sub-price"><?php echo $my_array[1]; ?></span>
</span>
</span>
</a>
РЕДАКТИРОВАТЬ:
Цена отображается с учетом налога с этим кодом. Но он пропускает последние 0. Таким образом, $49,90 становится $49,9 Как я могу отобразить 2 десятичных знака
<?php $first_amount_before_split = $this->helper('tax')->getPrice($_product, $_product->getFinalPrice());
$my_array = explode(".", $first_amount_before_split); ?>
Спасибо.
4
Author: Siarhey Uchukhlebau, 2015-01-23
2 answers
Попробуйте сделать это в вашем файле phtml.
$_priceIncludingTax = Mage::helper('tax')
->getPrice($_product, $_product->getFinalPrice());
7
Author: Siddharth Vaghasia, 2015-01-23 10:16:13
Вы можете сделать это с помощью налогового помощника
$_priceInclTax = Mage::helper('tax')->getPrice($_product, $_finalPrice, true,
null, null, null, null, null, false);
Здесь $_finalPrice=$_product->getFinalprice()
Оригинал:
public function getPrice($product, $price, $includingTax = null, $shippingAddress = null, $billingAddress = null,
$ctc = null, $store = null, $priceIncludesTax = null, $roundPrice = true)
{
Mage_Catalog_Model_Product $product
float $price inputed product price
bool $includingTax return price include tax flag
null|Mage_Customer_Model_Address $shippingAddress
null|Mage_Customer_Model_Address $billingAddress
null|int $ctc customer tax class
null|Mage_Core_Model_Store $store
bool $priceIncludesTax flag what price parameter contain tax
return float
5
Author: Amit Bera, 2015-01-23 10:34:37