Search code examples
shopware6

Show price gross and net


I would like to show the gross price and net price on the product pages. Can I do this without a purchased extension? And if so how? Thanks in Advance

Yours sincerely, Andre

I would like to know if my problem can be solved and how it can be solved.


Solution

  • Given you're showing gross prices initially, you can simply calculate the net price by subtracting the tax.

    {% set price = page.product.calculatedPrice %}
    
    {% if page.product.calculatedPrices|length == 1 %}
        {% set price = page.product.calculatedPrices.first %}
    {% endif %}
    
    {% set tax = price.calculatedTaxes.first.tax %}
    {% set priceGross = price.unitPrice %}
    {% set priceNet = priceGross - tax %}
    
    Gross: {{ priceGross|currency }}<br>
    Net: {{ priceNet|currency }}