Is there anyway to send a custom field by email? For example if a customer were to enter a shipping note and submits an order is there a way to send that note to an email address?
1 Answer
Best way to do this would be creating a small plugin (recommended on every Commerce install, to be able to easily extend it). In this plugin's init method, you could listen to the OrderComplete event and send the mail. This is untested, but should get you started:
public function init()
{
craft()->on('commerce_orders.onOrderComplete', function($event) {
$order = $event->params['order'];
$note = $order->getContent()->shippingNoteFieldHandle;
if ($note) {
//Send Mail
$email = new EmailModel();
$email->toEmail = '[email protected]';
$email->subject = 'New order completed';
$email->body = $note;
craft()->email->sendEmail($email);
}
});
}
You can use pluginfactory.io to quickly create a plugin, then put the init method in the plugin's base class.