Skip to content

Show the stock label in product listings - #1108

Draft
boo-code wants to merge 1 commit into
PrestaShop:2.xfrom
boo-code:feat/stock-label-in-product-listings-23659
Draft

boo-code wants to merge 1 commit into
PrestaShop:2.xfrom
boo-code:feat/stock-label-in-product-listings-23659

Conversation

@boo-code

Copy link
Copy Markdown
Contributor
Questions Answers
Description? The product listing shows no stock information, so a customer has to open every product to learn whether it can be shipped now. The miniature now renders the same stock label the product page does.
Type? improvement
BC breaks? no
Deprecations? no
Fixed ticket? Fixes PrestaShop/PrestaShop#23659
Sponsor company --
How to test? See below.

Why

The listing has carried the data all along. ProductListingPresenter extends ProductPresenter, and
availability, availability_message, availability_submessage and show_availability are all in
ProductLazyArray::getProductAttributeWhitelist(), so they reach the miniature. Measured on a 9.2 shop
by rendering a probe inside the miniature on a category page:

show_availability=[1] availability=[in_stock] quantity=[300]

Only the template never read them.

What it does

The mapping from an availability state to its icon and colour was inline in
product-add-to-cart.tpl. It moves to catalog/_partials/product-availability-status.tpl, which both
the product page and the miniature include, so the two surfaces cannot drift apart. The partial takes
the caller's BEM block through $componentName, the convention the theme already uses for shared
partials, so componentName='product' reproduces the product page's existing classes exactly and the
miniature gets product-miniature__availability-* for free.

States follow the specs on the issue: in stock green, out of stock with backorders allowed orange, out
of stock with backorders denied red. Nothing new is decided here - those three colours are what the
product page has been rendering.

One indicator, not two

A listing already carried an out-of-stock signal: the flag over the thumbnail, gated by
PS_SHOW_LABEL_OOS_LISTING_PAGES, which is 1 on a default install. It renders the same words as the
new label, so a tile with every combination out of stock showed "Out-of-Stock" twice - measured before
this was addressed:

<li class="badge out_of_stock">Out-of-Stock</li>
<div class="product-miniature__availability-status text-danger">... Out-of-Stock

product-flags.tpl now takes hideOutOfStockFlag, and the miniature sets it exactly when it renders a
label of its own. Consequences, each measured:

  • default install, all combinations out of stock: one indicator, the label. The discount badge on the
    same tile is untouched, so the filter is selective rather than a blanket suppression.
  • the merchant has emptied "Label of out-of-stock products when backorders are denied": no label is
    rendered, and the flag comes back. The setting still does something.
  • the product page cover, which includes the same partial without the flag, is unchanged.

This is the listing half of PrestaShop/PrestaShop#24759, which is
PM (approved) and asks for the flag and its BO toggle to be removed outright; that issue was waiting on
this one. The toggle and the product-page flag stay here.

How to test

Requires stock management enabled (Shop parameters > Product settings).

  1. Shop parameters > Product settings, fill "Label of in-stock products", e.g. In stock.

  2. Open any category page. Each tile now shows a green check and that label under the price.

  3. Set a product's quantity to 0 with "Deny orders" - its tile turns red with the out-of-stock label.

  4. Switch that product to "Allow orders" and fill "Label of out-of-stock products with allowed
    backorders" - the tile turns orange.

  5. Clear "Label of in-stock products" again: in-stock tiles show nothing, exactly as the product page
    does in the same state.

  6. Set every combination of a product to 0 with "Deny orders": the tile shows the red label and no
    out-of-stock badge. Empty the out-of-stock label in Shop parameters > Product settings and the badge
    comes back.

Measured on a running 9.2 shop

Product page markup is byte-identical before and after the extraction (diff of the rendered
product__availability-status block: no output). Listing, same request:

in stock              <div class="product-miniature__availability-status text-success" ...>&#xE5CA;  In stock
out of stock, allowed <div class="product-miniature__availability-status text-warning" ...>&#xE002;  Available for backorder
out of stock, denied  <div class="product-miniature__availability-status text-danger"  ...>&#xE14B;  Out-of-Stock

With the label left empty the listing renders nothing, and so does the product page - checked both in
the same state rather than assumed.

Not verified: the compiled CSS. assets/ is generated and gitignored, so the SCSS added for
product-miniature__availability-status was not built; the classes and their order are what was
measured, not their rendering.

The product listing carries no stock information, so a customer has to open
every product to learn whether it can be shipped now. The data is already
presented for listings: ProductListingPresenter extends ProductPresenter, and
availability, availability_message and show_availability are all in the
listing whitelist. Only the miniature never rendered them.

The mapping from an availability state to its icon and colour lived inline in
product-add-to-cart.tpl, so it moves to a shared partial parameterised by the
caller's BEM block. Passing componentName='product' reproduces the product
page's markup unchanged; the miniature passes its own block and gets the same
label with product-miniature__ classes.

A listing already had one out-of-stock signal, the flag over the thumbnail,
and it carries the same words as the new label. Showing both would say it
twice, so product-flags.tpl takes hideOutOfStockFlag and the miniature sets it
whenever it renders a label of its own. A shop that has emptied the label
keeps the flag, and the product page is untouched.

States follow the specs on the issue: in stock in green, out of stock with
backorders allowed in orange, out of stock with backorders denied in red. As
on the product page, nothing is rendered when the merchant has left the
matching label empty in Shop parameters > Product settings.
@boo-code
boo-code force-pushed the feat/stock-label-in-product-listings-23659 branch from 4b86f23 to c98b577 Compare September 22, 2026 16:47
@ps-jarvis

Copy link
Copy Markdown

This pull request seems to contain new translation strings. I have summarized them below to ease up review:

  • Shop.Theme.Global
    • Product availability:

(Note: this is an automated message, but answering it will reach a real human)

This branch has not been deployed

No deployments
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.

2 participants