Render the order product line hook on every order product line - #238
Draft
boo-code wants to merge 1 commit into
Draft
Render the order product line hook on every order product line#238boo-code wants to merge 1 commit into
boo-code wants to merge 1 commit into
Conversation
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, next to the reference and the download link. 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 every line twice, once for the wide layout and once for the narrow one, and the single shipment templates hold those rows inline while the four line partials serve the multishipment ones. The call therefore goes in eight places, and a module's output follows the same duplication as the product name and the reference next to it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
displayOrderDetailProductLinehook on every product line of the order detail page, so a module can show information next to one product of an order.Why
The order detail page has one hook,
displayOrderDetail, and it is executed once for the whole pagewith 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 the product cell of every line, nextto the reference and the download link. It passes identifiers only -
$product.id_order,$product.id_order_detail,$product.id_product- all three of which the presented product rowalready carries (
Order::getProductsDetail()selectsod.*), so the partials stay self contained.Eight call sites. The theme renders every line twice, once in a
hidden-sm-downtable and once ina
hidden-md-uplist, and the two single shipment templates hold those rows inline while the fourline partials serve the multishipment ones:
A module's output therefore appears twice in the document and once on screen, exactly like the product
name and the reference next to it. Adding the call to only one of the two renderings would have made
the hook disappear at a breakpoint.
That makes idempotency part of the contract, and it differs between the two shipped themes: a
listener fires twice per order line here and once on hummingbird. So a listener must not count, log a
row or emit a fixed
idornameattribute - this theme already prefixes its own ids with_desktop_and_mobile_for exactly this reason, and a module rendering into the hook has tofollow that. Worth stating in the devdocs entry alongside the parameters.
How to test
Register a module on
displayOrderDetailProductLinethat returns some markup fromhookDisplayOrderDetailProductLine($params), then open an order under Your account > Order history >Details, at a wide and at a narrow viewport. The markup appears under the product name of every line
in both, and
$paramscarries the three identifiers of that line.Measured on a running 9.2 shop
A probe module returning
<!--PROBE-FO id_order=... id_order_detail=... id_product=...-->wasinstalled and registered on the hook, this theme's six templates were deployed with a per-site marker,
the shop was switched to
classic, and the order detail page was fetched over HTTP as a logged incustomer owning a two product order. All eight sites fire, once per product each:
The two
inline-nr-*sites are the ones the real selection reaches on that order(
$order.details.is_returnablefalse, no shipments); the other six were forced by temporarilyincluding them from
order-detail.tpl, which proves each template compiles and emits the hook withthe right identifiers, but not that the selection reaches them.
Everything was put back afterwards: the seven deployed templates restored and checked by md5, the shop
switched back to
hummingbird, the probe module uninstalled and deleted with its hook rows, the probecustomer and its related rows deleted,
ps_orders.id_customerfor the test order set back, andPS_ORDER_RETURNset back to 0.Notes for publishing
order-detail-return.tpl; its hunks are at lines 29 to 35 and 42 to48, and the two lines added here are at 101 and 170. No overlap.
partials. Deduplicating them would reduce this hook to two call sites, but it is a structural change
that does not belong in the same PR as a one line hook call.