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.
Thanks for your order...
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.
Found the solution. My rule was already sending an email but I could not see any token for the customer first 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: