0

I have added the field field_e_mail to the Billing profile type in Commerce and would like to use this for sending an confirmation email to the customer (customers never log in). However, I can't for the life of me get hold of the field in rules. I've tried to use Entity has field in different ways, but I still can't get it to work.

What can I do to get the field_e_mail field from Billing into rules and use it for sending a confirmation email?

This is where I am at the moment ([email protected] is just a placeholder where I'd like to put the field_e_mail value):

{ "commerce_checkout_checkout_send_order_activation" : {
"LABEL" : "Send an order notification e-mail (cloned)",
"PLUGIN" : "reaction rule",
"WEIGHT" : "4",
"OWNER" : "rules",
"TAGS" : [ "Commerce Checkout" ],
"REQUIRES" : [ "rules", "commerce_checkout" ],
"ON" : { "commerce_checkout_complete" : [] },
"IF" : [
  { "entity_has_field" : { "entity" : [ "commerce-order" ], "field" : "commerce_customer_billing" } },
  { "entity_has_field" : {
      "entity" : [ "commerce-order:commerce-customer-billing" ],
      "field" : "field_e_mail"
    }
  }
],
"DO" : [
  { "mail" : {
      "to" : "[email protected]",
      "subject" : "Order [commerce-order:order-number] at [site:name] test",
      "message" : "hello.",
      "from" : "[email protected]",
      "language" : [ "commerce-order:state" ]
    }
  }
]

} }

10
  • This is the right approach and should work. Did you manage to find the right commerce profile type in rules? You should use Entity has field on that, not on the commerce order. Mar 27, 2017 at 8:54
  • @Neograph734 Right now I'm using Entity has field to look for field_e_mail on commerce-order (see initial post for export), is this correct?
    – Lenny
    Mar 27, 2017 at 9:04
  • 1
    Nope, the field is on the profile. So you should look it for it there. (Might even need another Entity has field to get the profile in, but I guess not.) Mar 27, 2017 at 9:05
  • 1
    Do note that you have to access it through the entire chain though. So it is commerce-order:commerce-customer-billing:field_e_mail. In case you were looking for it directly Mar 27, 2017 at 9:35
  • 1
    @Neograph734 Aah, absolutely brilliant! I can't thank you enough for your help, thank you so much!
    – Lenny
    Mar 27, 2017 at 9:41

1 Answer 1

0

If you have added the e-mail field on the commerce profile type as you said, you should access is via the profile type as well. (It is not a property of the commerce order.)

Normally, the commerce profiles are already available when the commerce order is loaded. But you might not recognize them as such. Nothing indicates it it a profile.

For instance I have access to these profiles:

profiles

And then you can use a condition like this:

  { "entity_has_field" : {
      "entity" : [ "commerce-order:commerce-customer-quotation" ],
      "field" : "commerce_customer_address"
    }
  }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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