Skip to content

Instantly share code, notes, and snippets.

@brookinsconsulting
Created August 28, 2014 00:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brookinsconsulting/90b7e8c3ccd761682dfb to your computer and use it in GitHub Desktop.
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
<?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