I created a module in admin/controller/module, and included this install code:
Code: Select all
class ControllerModuleLivingmagic extends Controller {
public function install() {
$this->load->model( 'extension/event' );
$this->model_extension_event->addEvent( 'livingmagic', 'post.order.add', 'admin/module/livingmagic/post_order_add' );
}
public function uninstall() {
$this->load->model('extension/event');
$this->model_extension_event->deleteEvent('livingmagic');
}
public function post_order_add($order_id) {
// this code is tested and works. It's not getting triggered by the post.order.add event
$success = 0;
$this->load->model('sale/order');
$products = $this->model_sale_order->getOrderProducts($order_id);
$questionable_product_ids = [512,604];
// these are private variables set above
$headers = "From: {$this->from}\n\n"; // from email address
$to = "{$this->phone}@{$this->carrier_address}"; // email to use with carrier and send SMS
foreach ($products as $p) {
if (in_array($p['product_id'],$questionable_product_ids)) {
$message = "Check order #{$order_id} for credit card fraud!";
$success = mail($to,$this->subject,$message, $headers);
}
}
return $success;
}
Any feedback on what I'm doing wrong or how I would go about debugging this?
Thanks!