在产品页面显示含税和不含税的价格

Show Price with and without taxes into Product Page

我在 Prestashop 1.7 解决方案中遇到问题。

进入产品页面,我想显示 2 个价格(包括和不包括增值税)

<span itemprop="price" content="{$product.price_amount}">{$product.price}</span>

此示例显示的是含增值税的价格。我也没有找到没有增值税的显示价格。

谢谢

您可以使用 {$product.price_tax_exc} 变量来显示不含税的价格。

您可以在 .tpl 中使用 {debug},您将看到所有可用的变量。

我们可以使用 {$product|@var_dump} 来显示 $product 变量包含哪些子变量

您可以使用 displayPrice() 方法来格式化显示的价格。

但是从版本 1.7.6 开始,您应该使用 formatPrice() 方法,因为 displayPrice 已被弃用。

你可以这样使用它:

{block name='product_without_taxes'}
    {if $priceDisplay != 1}
        <p class="product-without-taxes">{l s='%price% tax excl.' d='Shop.Theme.Catalog' sprintf=['%price%' => Context::getContext()->currentLocale->formatPrice($product.price_tax_exc, $currency.iso_code)]}</p>
    {/if}
{/block}

这样您就可以使用当前货币和 tax excl. 文本格式化价格。例如在法语中它会显示 10,00 € HT, 'HT' 意思是 'tax excluded'