Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.