I need to add an additional drop down field when a particular shipping method is selected, on the order information page during checkout. I only found how to add additional plugin option when adding a new shipping method through the UI. This is for a custom omniva parcel machine location implementation. Can anyone help me out where to get started with this? EDIT: im using drupal 8 and commerce 2. UPDATE: i tried creating a custom pane, thanks to the suggestion of Berry Dingle. I added the drop down and managed to pass the value to the summary page but i can't figure out how to get the value in the email receipt. I saved the selected value like this but how can i access it in the email template?

This is how i saved the value.

$form = $form_state->getValue($pane_form['#parents']);
$val = $pane_form['omniva_parcel_machines']['#options'][$form['omniva_parcel_machines']];
$this->order->setData('omniva_parcel_machines', $val);

This is how i built the summary pane.

public function buildPaneSummary()
    if ($parcel_machine = $this->order->getData('omniva_parcel_machines')) {
        return [
            '#plain_text' => $parcel_machine,
    return [];

Is it even possible to access the value in the email receipt twig template or i have to pass it somehow? I tried using

{{ order_entity.getData('omniva_parcel_machines') }}

as well as

{{ order_item.getData('omniva_parcel_machines') }}

but so far nothing.

  • 1
    Why are there downvotes on this question? Commerce is confusing and not everyone is an elite developer... Stop silent downvoting and instead help improve the question! Feb 17, 2021 at 14:08
  • 1
    I didn't down-vote, but I guess two users though the question should give more details, especially about what the user tried. It also seem the question is about code, but it doesn't show any code. If this is true, it would be a reason more for the down-vote.
    – apaderno
    Feb 17, 2021 at 17:19
  • “Get me started” questions usually aren’t a good fit for Q+A @Patrick. Commerce is indeed confusing, so it’s important the OP tell us exactly what’s confusing them about implementing this
    – Clive
    Feb 17, 2021 at 18:35
  • What I understand is, that you want to view an HTLM-select during checkout? If so, you'll need to write a plugin for the Commerce checkout pane as a custom module. After you did that, you can put it wherever you want in Commerce -> Configuration -> Orders -> Checkout flows -> Your checkout flow. Documentation on how to write such a plugin is here: docs.drupalcommerce.org/commerce2/developer-guide/checkout/… Feb 17, 2021 at 18:59
  • I want to add an HTML select field, if a specific shipping method is selected and pass the selected value to the review page and email. Will custom pane be the right approach? If i can pass the selected value to the email, this looks like it could work, i'll try it! Thanks! Addressing previous comments - it's my first post and i'm not used to this kinda format, so i'm sorry if the post come off as half-assed. I didn't show any code because i don't have any to show - i wasn't really sure even where to start. I'm not used to working with such big modules. Anyways, thanks for the feedback! Feb 17, 2021 at 19:59

1 Answer 1


I resolved the issue by adding a field to the order type and then instead of using Order interface

$this->order->setData('field_omniva_parcel_machines', $val);

i used FieldableEntityInterfaces' set

$this->order->set('field_omniva_parcel_machines', $val);

and i accessed the value in the commerce-order-receipt.html.twig by using

      {% if order_entity.field_omniva_parcel_machines.value %}
         {{ order_entity.field_omniva_parcel_machines.value }}
      {% endif %}

Thanks again, Berry, for getting me started with this!

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.