1

I have a Drupal 8.6.7 site with Commerce 8.x-2.11 installed. I would like to include slightly more information in the emails sent out when customers complete the checkout process. I would like to reference both the equipment category field and a more general category field present in both the product and product variations.

At the moment I just see the Title, Unit Price and Quantity if I look at the list of orders (all tests right now) at /Administration/Commerce/Orders.

Is there a way of adding these fields through the web admin GUI so that they end up in an order receipt email? I also have 'MIME Mail' and 'Mail System' modules installed if that helps.

0

This is not really an answer but closer to one than I've been before; even though I cannot go any further.

In /core/themes/bartik/templates I've placed a copy of commerce-order-receipt.html.twig. I can change the wording in this template, refresh the cache and I can see that come through in new emails. I see there's a mention of an 'order_entity' which I do not know how to reference so it appears in an email receipt.

If you can see the screenshot I've uploaded, it may become clear where I'm at or where I'm going wrong.

Order Item

I thought I might be able to change one of the columns in the order item (as the current four columns are exactly those that appear in receipt emails) and then try and reference it through {{ order_entity.getSomething }} in commerce-order-receipt.html.twig (after clearing the cache).

If I can get the fields in 'Purchased Entity' into the receipt email, I can then complete my business case for my Drupal site as everything else works a treat.

Thanks again.

4
  • Official documentation: docs.drupalcommerce.org/commerce2/developer-guide/orders/… Jan 29 '19 at 23:06
  • Thanks Bojan. I must've landed on that page a dozen times but I've checked it out again. I think 'order_entity' is the variable I need to check but I don't know what to use. I will put more information in another 'answer' as I can then include a screenshot.
    – Pete L
    Jan 31 '19 at 14:45
  • @BojanZivanovic: How do we get the value of a field added to an order item? If the machine name of the field is "field_somekey", do we use order_item.getData('somekey') in the Twig template? There are no examples in the template to indicate that this might work.
    – hansfn
    Apr 22 '19 at 8:02
  • @hansfn, did you figure out how to add values from Order Item Types fields?
    – hockey2112
    Jul 17 '19 at 3:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.