How to pass extra fields to the user receipt . i have defined a extra field under order item type a "/admin/commerce/config/order-item-types". Its value is set when the user selects while adding product to cart like delivery or pickup. Now i want to pass this field and its value to the order detail page opens on this url "/user/{uid}/orders/{orderid}". Also pass it to the user receipt sent when order is placed.

Comments

arpitk created an issue. See original summary.

garyg’s picture

This is an important question and someone must have an answer please.

I can find no documentation on what the variables are for the "order item types" that are created and linked to a "product variation type".
How can we make this data available in these templates?
commerce-order--user.html.twig
commerce-order-receipt.html.twig

vishal.sheladiya’s picture

I think this should work, in THEME_NAME.theme add

function THEME_NAME_preprocess_commerce_order_receipt(&$variables) {
$variables['test'] = "test";
}
Note: replace THEME_NAME with actual name of theme

Then doing {{ test }} should output "test".

Note: remember to flush all cache to see changes.

garyg’s picture

Thanks, but not exactly what I meant.
For example
- have added fields to order-item-types and want to include the field values into the order receipt
- have added fields to the order-item and want t include those field values into the order receipt.

DavidLiverneaux’s picture

The created fields will be automatically available in the template commerce-order-receipt.html.twig.
For exemple :
You create the field field_test.
You can use like this : {{ order_entity.field_test.value }}

jsacksick’s picture

Category: Task » Support request
Status: Active » Fixed

Status: Fixed » Closed (fixed)

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