<?php// Send a notification to Domoticz when a new Order is processing/completedfunctioncustom_woocommerce_order_status_completed_notification($order_id=0){// Bail out if no Order ID has been providedif(empty($order_id))return;// Bail out if it’s a free Order (0.00 total)$order_total=get_post_meta($order_id,'_order_total',false);if(empty($order_total)||$order_total='0.00')return;// CURL notification to Domoticz, increase the Orders count by 1$domoticz_url='http://nas.visser.io:8080';$domoticz_username='username';$domoticz_password='password';$idx=225;$base64_string=base64_encode($domoticz_username.':'.$domoticz_password);$args=array('headers'=>array('Authorization'=>'Basic '.$base64_string));$url=$domoticz_url.'/json.htm?type=command¶m=udevice&idx='.$idx.'&svalue=1';wp_remote_get($url,$args);}add_action('woocommerce_order_status_completed','custom_woocommerce_order_status_completed_notification');?>
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.