0

I need to build a site that will sell products on behalf of merchants referenced on the site and I need to notify these merchants every time a sell of their products occurs and send them information about the order we received for their product. Out of the box, commerce uses rules to send an email to the buyer and can also notify the site admin that a new order was created.

That is great but what if I need to notify a third party? Is there a way to do this out of the box or via configuration? Or is there a module for that? I have been looking and couldn't find anything. When I try to use rules the only email available for order checkout as tokens are the customer email and the site admin email.

For the sake of clarity here is the setup I have gone for so far and where I am stuck:

I have setup a field collection on my product pages listing the contact details for the merchant selling the product.

I collect three fields information inside the field collection:

  • name of merchant
  • address
  • contact email

I can easily make them visible on the order form with views by using relationships but I need to make the contact email available to rules so that I can set up a rule that will send and email to the merchant when the checkout process is completed.

That's it.

Thanks for your help

0

You can use a rule for that.

Use the action "Send a mail to an arbitrary mail address"

Set the recipients with php, like this (it's more powerful than tokens) :

<?php print _get_custom_emails_list( $node->field_custom );?>

Add this custom function in your custom module

<?php
// Your custom function
function _get_custom_emails_list( $field_custom ){
  // your query here.....
  return 'test@test.me, test2@test.me'    
}
?>
| improve this answer | |
  • Hi Pico, thanks for your answer, looks helpful but I don't have 'Send a mail to an arbitrary mail address' in my list of available actions... – user14522 Apr 10 '13 at 7:57
  • The action's name is : 'Send mail' simply, in 'System' category. (Sorry, 'Send a mail to an arbitrary mail address' is D6). NB : enable "php filter" module (core) – pico34 Apr 10 '13 at 8:41

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.