Post by OceanWind115 » Fri Sep 01, 2017 8:56 am

I'm trying to build an SMS notification module in OC 2.0.3.1, so when products are ordered that are targets for credit card fraud, an SMS is generated so we can check them out immediately. To do so, I need to capture the post.order.add event.

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!

Newbie

Posts

Joined
Wed Aug 03, 2016 2:32 am

Post by DigitCart » Fri Sep 01, 2017 1:45 pm

Hello,
try this for trigger:

Code: Select all

'post.order.history.add'

My Extensions


User avatar
Active Member

Posts

Joined
Thu Jun 22, 2017 5:32 pm

Who is online

Users browsing this forum: No registered users and 2 guests