Skip to content

Drop the Product Details tab when it has nothing to show - #236

Draft
boo-code wants to merge 1 commit into
PrestaShop:developfrom
boo-code:fix/hide-empty-product-details-tab-39230
Draft

Drop the Product Details tab when it has nothing to show#236
boo-code wants to merge 1 commit into
PrestaShop:developfrom
boo-code:fix/hide-empty-product-details-tab-39230

Conversation

@boo-code

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

Copy link
Copy Markdown
Contributor
Questions Answers
Description? Every block in product-details.tpl is wrapped in an {if} except product_out_of_stock, which emitted <div class="product-out-of-stock"> even when no module answered actionProductOutOfStock. A product with no manufacturer, no reference, hidden quantities, no availability date, no features, no specific references and no condition therefore produced a Product Details pane whose entire content was that one empty div - and the tab itself is rendered unconditionally, unlike Description and Attachments which are both guarded. The out-of-stock block is now guarded the way its six siblings are, and the partial publishes whether it has any content so product.tpl can drop the nav item as well.
Type? bug fix
BC breaks? no
Deprecations? no
Fixed ticket? Fixes PrestaShop/PrestaShop#39230
Sponsor company
How to test? Create a product with stock management disabled and no reference, no brand, no features, no specific references and no condition, as the reporter describes. Before this change the product page shows a Product Details tab containing nothing but an empty div. After it, the tab is not rendered at all and Description stays selected. A product with any of those fields set is unchanged.

Verified against PrestaShop's own Smarty

Both templates compile, and the partial was rendered in the running shop for the three cases that matter.
flag is product_details_has_content, the variable product.tpl now reads; the pane column has the
debug comments stripped:

empty + description present : flag=false  pane=NONE   -> tab dropped, which is the reported case
one block has content       : flag=true   pane=387b   -> tab kept, reference rendered
empty + NO description tab  : flag=false  pane=265b   -> pane kept, because it is the one carrying `active`

Why the decision travels as a variable and not as "is the include empty"

The obvious shape is to {capture} the include in product.tpl and test the captured markup. That is wrong
here, and the render test is what caught it: in debug mode SmartyDevTemplate::fetch() wraps every include
in <!-- begin ... --> / <!-- end ... -->, so the capture is never empty on a dev shop. The guard would
have looked correct, passed a compile check, worked in production and silently done nothing for every
developer. The partial therefore decides for itself and publishes the answer with scope='root'.

The third case, and why the tab is not always dropped

product.tpl gives active to Description when there is one and to Product Details otherwise. Dropping the
tab whenever it is empty would leave a product with no description and no details with no active pane at
all, and any Attachments or extra tab would render hidden. So an empty pane is still kept when there is no
description - it is the only thing that can carry active. The reported scenario has a description, so it
is fixed.

Scope

Classic theme only. Hummingbird has no product_out_of_stock block in its product-details.tpl, so it does
not carry this defect. assets/ is untouched, as the theme requires.

Every block in product-details.tpl is conditional except product_out_of_stock, which emitted its
wrapper even when no module answered actionProductOutOfStock. A product with no manufacturer, no
reference, hidden quantities, no availability date, no features, no specific references and no
condition therefore produced a Product Details tab whose whole content was one empty div - and the
tab itself was rendered unconditionally, unlike Description and Attachments which are both guarded.

The out-of-stock block is now guarded the way its six siblings are, and the partial publishes whether
it has any content so product.tpl can drop the nav item too. When there is no description the pane is
kept even when empty, because it is the one carrying `active`.

The decision travels as a variable rather than as "is the rendered include empty": in debug mode
SmartyDevTemplate wraps every include in <!-- begin --> comments, so a caller testing the markup
would find it non-empty on every dev shop.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Classic theme 2.2.0 - empty Product Detail tab in specific specific case

1 participant