Checkout rule: send email to Email Field


I got much of the way following the excellent post here: http://www.drupalcommerce.org/node/803

I created a website with many administrators. Each administrator is responsible for his products that he posts. Each product has an email field (using the email module) where the user can specify where to receive notifications.

After a purchase, I don't want to notify site administrator (only), I also want to notify the product creator, getting the email address from the Notify field.

the condition I want to put in place is something along the lines of:

The order complete contains a product with the "Notify" field.

And the action should send the order summary to the contents of the Notify field.

How do I do that??

Posted: Jan 25, 2012


rfay Randy Fay on January 25, 2012

Orders contain line items, some of which point to products.

You can create a loop that goes through the line items and calls a *component* for each one that has "if this is a product line item" and "if the product has the field" then send the email.

tevih on January 26, 2012

Thanks for the tip. I'm pretty new to rules so I tried a number of things that aren't working. Can you be more specific about what I need to do? This stuff is really interesting but complicated!

tevih on January 26, 2012

I've been trying further, and this is as far as I've gone:

1. created a new checkout rule
2. event: completed the checkout process
3. action: loop - list: commerce-order:commerce-line-items, list item: order_line_item
4. went over to configure, rules, componenets, "add component", "rule"
5. Conditoin: data comparison - selected data list-of-commerce-line-items:0:type "equals" (product type name)
6. AND
7. Entity has field
8. Entity: commerce-product:0
9. field: field_notify
10. Then, I went back to my checkout rule and tried to add an action to the loop, and that's where things fall apart.

lmatthews on September 24, 2012

I have setup custom email notifications using this tutorial, and it worked great. I did run into an issue that I still cannot include shipping information in the email. I have setup the commerce_email module also and made one small change to the setup in the screencast. I now am using the commerce_email as an action vs. System-Mail. I assigned the admin-email template to my custom "vendor" notification email, until I can figure out how to make its own template. When the regular administrators email is sent at checkout, the information is populated just fine. However, when my custom email rule fires off a "vendor" email, the same template is used, but the variable names are spit out instead of the actual shipping information. I have tried lots of things to bring in a reference to the shipping information from within the rule and/or components, with no success. Any thoughts?

tevih on January 28, 2012

wow!! Thanks so much! This cleared up a lot of the confusion for me! I understood the concepts but was messing things up in the particulars.

thanks again!