How do I use data selector for Billing Address > First Name in Rules for Commerce?

I want to use the order owner's first name in automatically generated emails.

For example:

Hey Scott,

Thanks for your order...

2 Answers 2


The solution likely depends on the billing customer profile's address field using a split first and last name field instead of the combined "full name" field. I've noticed on my Commerce site that there appears to be a bug in Address Field (hope to fix soon) that prevents a full name field from being split up into first and last name fields or vise versa.

Assuming your customers are entering first and last name separately, then all you have to do is drill down from the order through the profile to the first name on the address field. To do this using a Rules data selector, you'd first need to add two "Entity has field" conditions - one to ensure the commerce-order entity has the commerce_customer_billing field and a second to ensure the commerce-order:commerce-customer-billing entity has the commerce_customer_address field. IF those are in place, using the data selector you can drill down to the following token:


The problem comes when you actually want to embed this value in the body of an e-mail. Right now, as far as I can tell, there is no chain of tokens (replacement patterns in Rules UI parlance) that will drill down to the first name using that same pattern. Looking in the code for addressfield.module, I don't see any token related code. This may just need to be opened as a feature request for the Token module.

  • Is there any update on this answer?
    – jsheffers
    Commented Aug 29, 2013 at 15:12
  • 1
    Actually, yes, Address Field has core token support nowadays. : ) Commented Mar 19, 2014 at 13:36

Found the solution. My rule was already sending an email but I could not see any token for the customer first and last name.

  1. Add a condition "Entity has field" > commerce_customer_billing
  2. Add an action "Fetch entity by id":

    Entity type > Value: Commerce Customer Profile

    Identifier > Data selector: commerce-order:commerce-customer-billing:profile-id

    Provided variables
    Variable label: Customer Billing Profile
    Variable name: customer_billing_profile

  3. Add an action "Send email"
    (if you installed Mime Mail module for sending email within Rules you can choose "Send HTML e-mail" like I did)

    Use those tokens for first name and last name:

Note that it's taking the first and last name from the order itself NOT in the address book or profile. So if a user change its name in his address book it won't update in the order. I tried it.

I was inspired by a rule set found here:

  • I think this should be the accepted answer :)
    – Gokul N K
    Commented Jun 21, 2015 at 20:11

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.