简体   繁体   English

Magento 2:获得含税的产品价格/特价?

[英]Magento 2: get product price/special price with Tax?

With Magento 1, you could do the following to get the price of a product with tax:使用 Magento 1,您可以执行以下操作来获取含税产品的价格:

$_product = $this->getProduct();
$_taxHelper  = $this->helper('tax');
$final_price = $_taxHelper->getPrice($_product, $_product->getFinalPrice(), true);

How do I do the same in Magento 2 within a .phtml file?我如何在 .phtml 文件中的 Magento 2 中做同样的事情? The prices that are set in the backend are EX vat so I'd need the price to get the relevant tax rate and multiply it to get the price inc vat.在后端设置的价格是增值税增值税,所以我需要价格来获得相关税率并将其乘以得到价格含增值税。 I read somewhere that Magento does this automatically however I can't seem to get it to pull the amount and I really don't want to do it manually (hardcode a tax amount as a variable and multiply the variable by the price variable).我在某处读到 Magento 会自动执行此操作,但是我似乎无法让它提取金额,而且我真的不想手动执行此操作(将税额硬编码为变量并将变量乘以价格变量)。

Any help is greatly appreciated!任何帮助是极大的赞赏!

Magento2 using knockout. Magento2 使用淘汰赛。 For this, you can edit html file.为此,您可以编辑 html 文件。

For example:例如:

Path: app/design/frontend/Vendor/Theme_Name/Magento_Checkout/web/template/checkout/summary/item/details.html路径: app/design/frontend/Vendor/Theme_Name/Magento_Checkout/web/template/checkout/summary/item/details.html

<span class="price" data-bind="text: getFormattedPrice($parent.price_incl_tax)"></span>

Or maybe, this topic can help you.或者,这个主题可能对您有所帮助。

https://magento.stackexchange.com/questions/173028/magento-2-minicart-display-line-item-subtotal-rather-than-unit-price https://magento.stackexchange.com/questions/173028/magento-2-minicart-display-line-item-subtotal-rather-than-unit-price

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM