Skip to content

Render the order product line hook on every order product line - #1105

Merged
tblivet merged 1 commit into
PrestaShop:2.xfrom
boo-code:feat/order-product-line-hook-23245
Sep 18, 2026
Merged

tblivet merged 1 commit into
PrestaShop:2.xfrom
boo-code:feat/order-product-line-hook-23245

Conversation

@boo-code

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

Copy link
Copy Markdown
Contributor
Questions Answers
Branch? 2.x
Description? Call the new displayOrderDetailProductLine hook on every product line of the order detail page, so a module can show information next to one product of an order.
Type? new feature
BC breaks? no
Deprecations? no
How to test? See below.
Fixed issue or discussion? Fixes PrestaShop/PrestaShop#23245
Related PRs PrestaShop/PrestaShop#TBD declares the hook. PrestaShop/classic-theme#TBD does the same for the other shipped theme.
Sponsor company --

Why

The order detail page has one hook, displayOrderDetail, and it is executed once for the whole page
with the order as its only parameter. Nothing receives a single product line, so a module cannot show
information next to one product.

What it does

One {hook h='displayOrderDetailProductLine' ...} at the end of order-product__content, where the
reference, the virtual product note and the carrier note already are. It passes identifiers only -
$product.id_order, $product.id_order_detail, $product.id_product - all three of which the
presented product row already carries (Order::getProductsDetail() selects od.*), so the partials
stay self contained and nothing new has to be threaded through the includes.

Four call sites, because the theme renders a product line from four places. The two line
partials, order-detail-product-line-no-return.tpl and order-detail-product-line-return.tpl, are
used only by the two multishipment templates; order-detail-no-return.tpl and
order-detail-return.tpl hold the row inline instead. Adding the call to the partials alone would
have given a hook that fires only on a multishipment order.

Each line still renders from exactly one of those four sites, so a listener fires once per order
line here. On classic it fires twice, because that theme renders every line in both a hidden-sm-down
and a hidden-md-up block. A listener therefore has to be idempotent and must not emit fixed id or
name attributes - stated on the classic branch as well, and worth carrying into the devdocs entry.

How to test

Register a module on displayOrderDetailProductLine that returns some markup from
hookDisplayOrderDetailProductLine($params), then open an order under Your account > Order history >
Details. The markup appears under the product name of every line and $params carries the three
identifiers of that line. It should appear whether or not the order is returnable and whether or not
it has shipments.

Measured on a running 9.2 shop

A probe module returning <!--PROBE-FO id_order=... id_order_detail=... id_product=...--> was
installed and registered on the hook, this theme's four templates were deployed with a per-site
marker, and the order detail page was fetched over HTTP as a logged in customer owning a two product
order:

site                  fired   probe output
inline-no-return       2      id_order=1 id_order_detail=1 id_product=1 / ...=2 ...=2
inline-return          2      same
partial-no-return      2      same
partial-return         2      same

inline-no-return is the one the real selection reaches on that order
($order.details.is_returnable false, no shipments). The other three were forced by temporarily
including them from order-detail.tpl, which proves each template compiles and emits the hook with
the right identifiers, but not that the selection reaches them - that needs a returnable order and a
shipment fixture.

Everything was put back afterwards: the five deployed templates restored and checked by md5, the
probe module uninstalled and deleted with its hook rows, the probe customer and its
ps_customer_group / ps_customer_session / ps_guest / ps_cart / ps_psgdpr_log rows deleted,
ps_orders.id_customer for the test order set back, and PS_ORDER_RETURN set back to 0.

Notes for publishing

An order product line had no extension point in the front office, only the page level
displayOrderDetail hook, so a module could not show information next to one product of an order.

Call displayOrderDetailProductLine at the end of the product cell of every line, where the
reference, the virtual product note and the carrier note already are. It receives identifiers only
- the order, the order detail row and the product - all of which the presented product already
carries, so the partials stay self contained.

The theme renders a product line from four places: the two single shipment templates hold the row
inline and the two line partials are used by the multishipment ones, so the call goes in all four.
@kpodemski
kpodemski marked this pull request as ready for review September 12, 2026 09:52
@github-project-automation github-project-automation Bot moved this to Ready for review in PR Dashboard Sep 12, 2026
@ps-jarvis ps-jarvis added the Waiting for QA Status: Action required, Waiting for test feedback label Sep 12, 2026
@kpodemski kpodemski added this to the v2.1.1 milestone Sep 12, 2026
@ps-jarvis ps-jarvis moved this from Ready for review to To be tested in PR Dashboard Sep 12, 2026
@tblivet

tblivet commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

QA: approved. Tested on PrestaShop 9.3.0, PHP 8.1.33, Hummingbird 2.1.0, front office.
AI-assisted QA: an agent drove a real browser through the steps below and drafted this comment. Worth a sanity check.

A throwaway module registered on displayOrderDetailProductLine was installed, and four orders were staged so that each one selects a different call site. All four fired, once per product line, with the identifiers of the line the call sat on:

Template Order Lines Calls id_order/id_order_detail/id_product
order-detail-no-return.tpl not returnable, no shipments 1 1 3/5/16
order-detail-return.tpl returnable, no shipments 2 2 1/1/1, 1/2/2
order-detail-product-line-no-return.tpl not returnable, multishipment 1 1 4/6/16
order-detail-product-line-return.tpl returnable, multishipment 2 2 2/3/4, 2/4/8

Which template rendered was confirmed on the page and against the Smarty compile cache, not assumed from the fixture. The listener output appears under the product name on every line, and no line received it twice. Order history, order detail and merchandise returns still answer and render; no console or network errors during the pass.

Not covered: the merge base was not measured, so nothing here is a before and after comparison; the hook is not yet declared in core, so it was created by Hook::registerHook; no virtual products, and no order with lines split across two shipments.


Captures:
03-open-order-3-inline-row-not-returnable-no-shipme
04-open-order-1-inline-row-returnable-no-shipments
05-open-order-4-partial-not-returnable-multishipmen
06-open-order-2-partial-returnable-multishipment

@tblivet tblivet added QA with AI ✓ AI-assisted QA and removed Waiting for QA Status: Action required, Waiting for test feedback labels Sep 17, 2026
@tblivet
tblivet merged commit a3cdc9c into PrestaShop:2.x Sep 18, 2026
6 checks passed
@github-project-automation github-project-automation Bot moved this from To be tested to Merged in PR Dashboard Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

QA with AI ✓ AI-assisted QA

Projects

Status: Merged

Development

Successfully merging this pull request may close these issues.

5 participants