Created
August 28, 2014 00:07
-
-
Save brookinsconsulting/90b7e8c3ccd761682dfb to your computer and use it in GitHub Desktop.
The following is a quick and dirty way to send an email to the user informing them of an order status change. This is a kernel hack of the kernel shop module view orderlist. This solution was posted to the forums and then cleaned up here: http://share.ez.no/forums/setup-design/webshop-how-do-i-trigger-a-function-when-changing-status#comment84390
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// begin snippet | |
if ( $http->hasPostVariable( 'SaveOrderStatusButton' ) ) | |
{ | |
if ( $http->hasPostVariable( 'StatusList' ) ) | |
{ | |
foreach ( $http->postVariable( 'StatusList' ) as $orderID => $statusID ) | |
{ | |
$order = eZOrder::fetch( $orderID ); | |
$access = $order->canModifyStatus( $statusID ); | |
if ( $access and $order->attribute( 'status_id' ) != $statusID ) | |
{ | |
$order->modifyStatus( $statusID ); | |
// STATUS EMAIL .... | |
$email = $order->attribute( 'account_email' ); | |
$tpl->setVariable( 'order', $order ); | |
$templateResult = $tpl->fetch( 'design:shop/statusemail.tpl' ); // create a template | |
$subject = $tpl->variable( 'subject' ); | |
$mail = new ezcMailComposer(); | |
$emailSender = $ini->variable( 'MailSettings', 'EmailSender' ); | |
if ( !$emailSender ) | |
{ | |
$emailSender = $ini->variable( "MailSettings", "ShopAdminEmail" ); | |
} | |
$mail->charset = 'utf-8'; | |
$mail->addTo( new ezcMailAddress( $email ) ); | |
$mail->from = new ezcMailAddress( $emailSender ); | |
$mail->subject = $subject; | |
$mail->htmlText = $templateResult ; | |
$mail->build(); | |
$transport = new ezcMailMtaTransport(); | |
$transport->send( $mail ); | |
} | |
} | |
} | |
} | |
// end snippet | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment