Conversation
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
left a comment
There was a problem hiding this comment.
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.
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.
|
@tblivet Done here: the two |
tblivet
left a comment
There was a problem hiding this comment.
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) != ''} |
There was a problem hiding this comment.
| {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} |
$configuration.display_taxes_labelis$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.Before
After
Empty block
With the label off and no ecotax,
product__tax-infosrendered empty and still took the flex gap. It is nowrendered only when it has a label, an ecotax line or price hook output. The two
displayProductPriceBlockhooksare captured first and count only once the
<!-- begin/end -->comments debug mode wraps around every renderedtemplate 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_labeltogether withtaxes_enabled, and was mergedin 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.