The commerce_shipping_preprocess_commerce_order preprocess functions render the shipping information before passing it to the template. That seems to be unnecessary and it causes problems when we want to substantially change the way shipping information is rendered in the template, including changing the display configuration of the commerce_shipment.

I have encountered the following two cases:

- Render the state of the shipment. It is a very broad assumption that the state is always internal, in some cases we want to display it to the user. Currently, we would either need to override the OrderShipmentSummary service to do that. If the shipping information is kept as a render array, we can simply set the #access property to TRUE.

- Render the Shipments separately in the template. That is not currently possible, unless we rebuild the order summary, kind of unnecessary. If the shipping information is kept as a render array, we can change it as required and provide the shipments as a separate variable in the template.

The following patch keeps the shipping information as a render array.

Comments

krystalcode created an issue. See original summary.

krystalcode’s picture

Status: Active » Needs review
StatusFileSize
new977 bytes

Patch attached.

bojanz’s picture

While I like the idea, the shipping patch is not enough.

Commerce explicitly documents the variable as rendered:

 * - billing_information: The rendered billing information.
 * - shipping_information: The rendered shipping information.

So we need to change both the docs, and the billing_information to match.

krystalcode’s picture

Good catch, I will update the patch when time permits.

goz’s picture

Status: Needs review » Reviewed & tested by the community

I have the same issue have the same conclusion. Thanks for the patch @krystalcode

@bojanz: billing_information is already a renderable array.

Issue has been created on commerce module to update documentation: #2977488: Order receipt template docs are incorrect about data being already rendered

  • bojanz committed 7cd3569 on 8.x-2.x authored by krystalcode
    Issue #2927018 by krystalcode, GoZ: Do not render shipping information...
bojanz’s picture

Status: Reviewed & tested by the community » Fixed

Committed, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.