Skip to content

Respect the country tax label setting on the product page - #1098

Open
boo-code wants to merge 2 commits into
PrestaShop:2.xfrom
boo-code:fix/tax-label-setting-on-product-page-21484
Open

boo-code wants to merge 2 commits into
PrestaShop:2.xfrom
boo-code:fix/tax-label-setting-on-product-page-21484

Conversation

@boo-code

@boo-code boo-code commented Sep 5, 2026

Copy link
Copy Markdown
Contributor
Questions Answers
Description? The product page prints "No tax" whenever taxes are disabled without consulting the country's "Display tax label" setting, which the very next branch of the same template already honours. $configuration.display_taxes_label is $this->context->country->display_tax_label (FrontController::getDisplayTaxesLabel()), so a merchant who turns that checkbox off still gets a tax statement on every product page. Both branches are now gated on the setting.
Type? bug fix
BC breaks? no
Deprecations? no
Fixed ticket? Fixes PrestaShop/PrestaShop#21484
Sponsor company
How to test? Set a country's "Display tax label" to No (International > Locations > Countries), then disable taxes (International > Taxes > Enable taxes: No) and open a product page. Before: "No tax" is displayed. After: nothing is displayed. With the label set to Yes the behaviour is unchanged in both tax states.

Before

{if !$configuration.taxes_enabled}
  {l s='No tax' d='Shop.Theme.Catalog'}
{elseif $configuration.display_taxes_label}
  {$product.labels.tax_long}
{/if}

After

{if $configuration.display_taxes_label}
  {if $configuration.taxes_enabled}
    {$product.labels.tax_long}
  {else}
    {l s='No tax' d='Shop.Theme.Catalog'}
  {/if}
{/if}

Empty block

With the label off and no ecotax, product__tax-infos rendered empty and still took the flex gap. It is now
rendered only when it has a label, an ecotax line or price hook output. The two displayProductPriceBlock hooks
are captured first and count only once the <!-- begin/end --> comments debug mode wraps around every rendered
template are stripped; otherwise an empty hook would bring the block back on a dev shop. Rendered both ways:
the empty-hook and comments-only cases produce no block, hook content, the label and ecotax each still produce it.

Why this shape

PrestaShop/PrestaShop#25882 fixed the same defect for the cart summary and the
order confirmation table by gating on display_taxes_label together with taxes_enabled, and was merged
in October 2021. The product page was not part of it, which is why the issue is still open with this exact
template quoted in the thread. Using the same gate keeps the three places consistent rather than inventing
a rule for this one.

Scope

Only the product page template changes. The cart summary and the order confirmation table already respect
the setting since PrestaShop/PrestaShop#25882, and so does DeliveryOptionsFinder.

Companion to the same change in classic-theme: the two themes carry the same template and the same defect.

The product page showed "No tax" whenever taxes were disabled, without
consulting the country's "Display tax label" setting that the branch just
below it already honoured. A merchant who turned that label off still saw a
tax statement on every product.

Gate both branches on the setting, the way #25882 did for the cart summary
and the order confirmation table.
@tblivet
tblivet marked this pull request as ready for review September 16, 2026 12:03
@github-project-automation github-project-automation Bot moved this to Ready for review in PR Dashboard Sep 16, 2026

@tblivet tblivet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @boo-code, the fix looks right, but I noticed one thing while testing: with the label off and no ecotax, the product__tax-infos div renders empty and still takes the 0.75rem flex gap from _product.scss. Not something you introduced, but this adds another way to get there.

Adding a hidden attribute won't do it, since the block contains the two displayProductPriceBlock hooks, so it needs a capture. I have it working locally, I can push it here or do a follow-up, up to you.

@tblivet tblivet added this to the v2.1.1 milestone Sep 16, 2026
With the tax label off and no ecotax the block rendered empty and still
took the flex gap. The price hooks are captured first and count only once
the begin/end comments debug mode wraps around rendered templates are
stripped, so an empty hook does not bring the block back on a dev shop.
@boo-code

Copy link
Copy Markdown
Contributor Author

@tblivet Done here: the two displayProductPriceBlock hooks are captured and product__tax-infos renders only with a label, an ecotax line or hook output. The capture is tested after stripping the <!-- begin/end --> comments debug mode wraps around rendered templates, otherwise an empty hook keeps the block on a dev shop. Rendered with empty hooks, comments-only hooks, hook content, label only and ecotax only: no block in the first two, the block in the other three.

@tblivet tblivet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @boo-code, the gate is good but I think we should avoid the regex_replace. We don't use it anywhere else in the theme, and the <!-- begin/end --> comments only show up in dev mode so visitors should never see that empty block. We can, however, keep the |trim. So can you also drop the {* WHY *} comment.

{capture name='product_price_hooks'}{hook h='displayProductPriceBlock' product=$product type="price"}{hook h='displayProductPriceBlock' product=$product type="after_price"}{/capture}
{* WHY: the block holds only optional parts, and an empty one still takes the flex gap. Debug mode wraps
every rendered template in <!-- begin/end --> comments, so the hooks count only once those are stripped. *}
{if $configuration.display_taxes_label || $product.ecotax.amount > 0 || ($smarty.capture.product_price_hooks|regex_replace:'/<!--.*?-->/s':''|trim) != ''}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{if $configuration.display_taxes_label || $product.ecotax.amount > 0 || ($smarty.capture.product_price_hooks|regex_replace:'/<!--.*?-->/s':''|trim) != ''}
{if $configuration.display_taxes_label || $product.ecotax.amount > 0 || $smarty.capture.product_price_hooks|trim}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Ready for review

Development

Successfully merging this pull request may close these issues.

3 participants