/** * by Subscription and SMS Options * order_status_changed function. * @access public * @return void */ public function ws_order_status_changed($id, $status = 'new', $new_status = 'pending') { // Get WC order $order = $this->wc_get_order($id); // Customer will be added to a list after subscribe event occur if ($this->ws_subscribe_enable == 'yes' && $new_status == $this->customizations['ws_order_event']) { $ws_dopt_enabled = isset($this->customizations['ws_dopt_enabled']) ? $this->customizations['ws_dopt_enabled'] : 'no'; // get the ws_opt_in value from the post meta. $ws_opt_in = get_post_meta($id, 'ws_opt_in', true); // yes or no $info = array('NAME' => $order->billing_first_name, 'SURNAME' => $order->billing_last_name, 'SMS' => $order->billing_phone, 'ORDER_ID' => $id, 'ORDER_DATE' => strtotime($order->order_date), 'ORDER_PRICE' => $order->order_total); if ($ws_dopt_enabled == 'yes' && $ws_opt_in == 'yes') { $wc_sib_smtp = new WC_Sendinblue_SMTP(); $dopt_template_id = $this->customizations['ws_dopt_templates']; $info['DOUBLE_OPT-IN'] = '1'; $wc_sib_smtp->double_optin_signup($order->billing_email, $this->customizations['ws_sendinblue_list'], $info, $dopt_template_id); } else { if ($ws_opt_in == 'yes') { $wc_sib = new WC_Sendinblue(); $wc_sib->create_subscriber($order->billing_email, $this->customizations['ws_sendinblue_list'], $info); } } } // send confirmation SMS if ($this->ws_sms_enable == 'yes') { $wc_sib_sms = new WC_Sendinblue_SMS(); $ws_sms_send_after = isset($this->customizations['ws_sms_send_after']) ? $this->customizations['ws_sms_send_after'] : 'no'; $ws_sms_send_shipment = isset($this->customizations['ws_sms_send_shipment']) ? $this->customizations['ws_sms_send_shipment'] : 'no'; // send a SMS confirmation for order confirmation if ($ws_sms_send_after == 'yes' && $new_status == 'pending') { $from = $this->customizations['ws_sms_sender_after']; $text = $this->customizations['ws_sms_send_msg_desc_after']; $wc_sib_sms->ws_send_confirmation_sms($order, $from, $text); } // send a SMS confirmation for the shipment of the order if ($ws_sms_send_shipment == 'yes' && $new_status == 'completed') { $from = $this->customizations['ws_sms_sender_shipment']; $text = $this->customizations['ws_sms_send_msg_desc_shipment']; $wc_sib_sms->ws_send_confirmation_sms($order, $from, $text); } } }