Celtic:
Louise,
For what it's worth, here's the two files (auto_loader & observer) I cobbled together to send a 'packing list' email triggered by the NOTIFY_ORDER_AFTER_SEND_ORDER_EMAIL notifier...
/includes/auto_loaders/config.celtic_PackingListEmail.php
<?php
// includes/auto_loaders/config.celtic_PackingList.php ...
//
// Config for class to send a Packing list email after order completion
// by Celtic, 02-June-2011
//
// see also /includes/classes/observers/class.celtic_PackingListEmail.php
// Note: 10 has been chosen to cause the observer class to be loaded before the session is started.
// Note: 90 has been chosen as the offset since the observer needs to attach to the $SESSION['cart'] class, which is instantiated at offset 80.
$autoLoadConfig[10][] = array('autoType'=>'class',
'loadFile'=>'observers/class.celtic_PackingListEmail.php');
$autoLoadConfig[90][] = array('autoType'=>'classInstantiate',
'className'=>'celticPackingListEmail',
'objectName'=>'celticPackingListEmail');
?>
>
>
> /includes/classes/observers/class.celtic_PackingListEmail.php
> ```php
<?php
// /includes/classes/observers/class.celtic_PackingListEmail.php
//
// Observer class to send a Packing list email after order completion
// by Celtic, 02-June-2011
//
// see also /includes/auto_loaders/config.celtic_PackingListEmail.php
class celticPackingListEmail extends base {
// CONSTRUCTOR METHOD
function celticPackingListEmail() {
$this->attach( $this, Array('NOTIFY_ORDER_AFTER_SEND_ORDER_EMAIL'));
}
// UPDATE METHOD
function update( &$class, $eventID, $paramsArray = array() ) {
// create a packing list email for this order and send to packing department
$packingListEmailTo = "[email protected]";
$packingListSubject = "PACKING LIST: " . EMAIL_ORDER_NUMBER_SUBJECT . $paramsArray[0] . " " . $paramsArray[3]['INTRO_DATE_ORDERED'];
$packingDetails =
$paramsArray[3]['PRODUCTS_DETAIL'] . "\n\n" .
$paramsArray[3]['ADDRESS_DELIVERY_DETAIL'] . "\n\n" .
$paramsArray[3]['SHIPPING_METHOD_DETAIL'] . "\n\n" .
$paramsArray[3]['ORDER_COMMENTS'] . "\n\n";
$html_msg = ""; //$packingDetails;
// send packing list email
zen_mail('', $packingListEmailTo, $packingListSubject, $packingDetails, STORE_NAME, EMAIL_FROM, $html_msg, 'checkout_extra');
}
}
?>
Note: to send an HTML format email needs all the various/relevant HTML email settings switched on within your Zencart admin, so I've just left mine blank in the update method above. When it's blank, zen_mail() just sends a plaintext one.
You mentioned wanting to get the order number. You can see in the update() function that it is passed an array called $paramsArray[] and in the $packingListSubject line I am getting the order number from $paramsArray[0].
To see what $paramsArray[] contains, just put: print_r($paramsArray); exit; inside the update method.
Hope it helps in some way when you get back to this,
Celtic
Hi Celtic,
I have used the same process with SMS ON SALE mod by swguy.
I have just did one modification and that is instead on zen_mail() call I have replaced by curl API which I have received from my SMS Gateway service provider.
Whats happening is that SMS is being pushed to the Gateway and is received successfully, Order is generated, Order Confirmation Mail is also generated. But, checkout_success page shows blank page with HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.
I have attached ZIP File containing the code files affected: http://www.zen-cart.com/showthread.php?198155-Execute-API-on-successful-order&p=1140554#post1140554
Kindly advice some solution as I am beginner.
Thanks & Regards,
Max