Version Notes
Send sms notification
Download this release
Release Info
Developer | Carotechs |
Extension | Carotechs_Smsnotify |
Version | 0.1.5 |
Comparing to | |
See all releases |
Code changes from version 0.1.4 to 0.1.5
app/code/local/Carotechs/Smsnotify/Helper/Data.php
CHANGED
@@ -172,52 +172,24 @@ class Carotechs_Smsnotify_Helper_Data extends Mage_Core_Helper_Data
|
|
172 |
}
|
173 |
|
174 |
}
|
175 |
-
catch(Exception $e)
|
|
|
176 |
$sendSms = '';
|
177 |
}
|
178 |
-
if($sendSms)
|
|
|
179 |
return true;
|
180 |
-
switch($sendSms) {
|
181 |
-
case '01':
|
182 |
-
$status_message = Mage::helper('smsnotify')->__('Username or password incorrect.');
|
183 |
-
$status = Mage::helper('smsnotify')->__('Not sent');
|
184 |
-
break;
|
185 |
-
case '02':
|
186 |
-
$status_message = Mage::helper('smsnotify')->__('SmsTo missing.');
|
187 |
-
$status = Mage::helper('smsnotify')->__('Not sent');
|
188 |
-
break;
|
189 |
-
case '03':
|
190 |
-
$status_message = Mage::helper('smsnotify')->__('SmsFrom missing.');
|
191 |
-
$status = Mage::helper('smsnotify')->__('Not sent');
|
192 |
-
break;
|
193 |
-
case '04':
|
194 |
-
$status_message = Mage::helper('smsnotify')->__('SmsMsg missing.');
|
195 |
-
$status = Mage::helper('smsnotify')->__('Not sent');
|
196 |
-
break;
|
197 |
-
case '09':
|
198 |
-
$status_message = Mage::helper('smsnotify')->__('Insufficient credits.');
|
199 |
-
$status = Mage::helper('smsnotify')->__('Not sent');
|
200 |
-
break;
|
201 |
-
default:
|
202 |
-
$status_message = Mage::helper('smsnotify')->__('Sms successfully sent.');
|
203 |
-
$status = Mage::helper('smsnotify')->__('Sent');
|
204 |
-
break;
|
205 |
-
}
|
206 |
}
|
207 |
-
else
|
|
|
208 |
return false;
|
209 |
-
$status_message = Mage::helper('smsnotify')->__('Not able to send the sms. Please contact the developer.');
|
210 |
-
$status = 'Not sent';
|
211 |
}
|
212 |
-
|
213 |
-
$ret['status'] = $status;
|
214 |
-
return $ret;
|
215 |
}
|
216 |
|
217 |
public function file_get_contents_curl($url)
|
218 |
{
|
219 |
-
|
220 |
-
//die();
|
221 |
$ch = curl_init();
|
222 |
|
223 |
curl_setopt($ch, CURLOPT_HEADER, 0);
|
@@ -232,9 +204,7 @@ class Carotechs_Smsnotify_Helper_Data extends Mage_Core_Helper_Data
|
|
232 |
|
233 |
public function file_get_contents_curl_POST($url,$data)
|
234 |
{
|
235 |
-
|
236 |
-
//print_r($data);
|
237 |
-
// die();
|
238 |
$ch = curl_init($url);
|
239 |
curl_setopt($ch, CURLOPT_POST, true);
|
240 |
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
172 |
}
|
173 |
|
174 |
}
|
175 |
+
catch(Exception $e)
|
176 |
+
{
|
177 |
$sendSms = '';
|
178 |
}
|
179 |
+
if($sendSms)
|
180 |
+
{
|
181 |
return true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
182 |
}
|
183 |
+
else
|
184 |
+
{
|
185 |
return false;
|
|
|
|
|
186 |
}
|
187 |
+
|
|
|
|
|
188 |
}
|
189 |
|
190 |
public function file_get_contents_curl($url)
|
191 |
{
|
192 |
+
|
|
|
193 |
$ch = curl_init();
|
194 |
|
195 |
curl_setopt($ch, CURLOPT_HEADER, 0);
|
204 |
|
205 |
public function file_get_contents_curl_POST($url,$data)
|
206 |
{
|
207 |
+
|
|
|
|
|
208 |
$ch = curl_init($url);
|
209 |
curl_setopt($ch, CURLOPT_POST, true);
|
210 |
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
app/code/local/Carotechs/Smsnotify/Model/Observer.php
CHANGED
@@ -6,10 +6,14 @@ class Carotechs_Smsnotify_Model_Observer
|
|
6 |
if($this->getHelper()->isOrdersEnabled())
|
7 |
{
|
8 |
$orders = $observer->getEvent()->getOrderIds();
|
9 |
-
$order = Mage::getModel('sales/order')->load($orders['0']);
|
10 |
|
|
|
|
|
|
|
|
|
11 |
if ($order instanceof Mage_Sales_Model_Order)
|
12 |
{
|
|
|
13 |
$api_url = $this->getHelper()->getAPI();
|
14 |
$message_field_name = $this->getHelper()->getMessageField();
|
15 |
$to_field_name = $this->getHelper()->getToField();
|
@@ -22,228 +26,383 @@ class Carotechs_Smsnotify_Model_Observer
|
|
22 |
{
|
23 |
$to_field_name = 'to';
|
24 |
}
|
25 |
-
|
26 |
$sent_method = $this->getHelper()->getSentMethod();
|
27 |
-
|
28 |
$smsto = urlencode($this->getHelper()->getTelephoneFromOrder($order));
|
29 |
$smsmsg = urlencode($this->getHelper()->getMessage($order));
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
32 |
{
|
33 |
-
$
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
}
|
41 |
else
|
42 |
{
|
43 |
-
$
|
44 |
-
$post_data[$message_field_name] = $smsmsg;
|
45 |
-
$post_data[$to_field_name] = $smsto;
|
46 |
-
$url = $api_url;
|
47 |
-
$sendSms = $this->getHelper()->sendSms($url,$post_data);
|
48 |
}
|
49 |
-
|
|
|
|
|
|
|
|
|
50 |
}
|
51 |
}
|
52 |
}
|
53 |
|
54 |
public function sendSmsOnOrderHold(Varien_Event_Observer $observer)
|
55 |
{
|
56 |
-
if($this->getHelper()->isOrderHoldEnabled())
|
57 |
-
|
58 |
-
$order =
|
59 |
-
|
60 |
-
if ($order instanceof Mage_Sales_Model_Order)
|
61 |
-
{
|
62 |
-
$api_url = $this->getHelper()->getAPI();
|
63 |
-
$message_field_name = $this->getHelper()->getMessageField();
|
64 |
-
$to_field_name = $this->getHelper()->getToField();
|
65 |
-
|
66 |
-
if($message_field_name=='')
|
67 |
-
{
|
68 |
-
$message_field_name = 'msg';
|
69 |
-
}
|
70 |
-
if($to_field_name=='')
|
71 |
{
|
72 |
-
$to_field_name = 'to';
|
73 |
-
}
|
74 |
-
|
75 |
-
$sent_method = $this->getHelper()->getSentMethod();
|
76 |
|
77 |
-
|
78 |
-
$smsmsg = urlencode($this->getHelper()->getSenderForOrderHold($order));
|
79 |
-
|
80 |
-
if($sent_method)
|
81 |
{
|
82 |
-
|
83 |
-
$
|
84 |
-
$
|
85 |
-
|
86 |
-
|
87 |
-
$
|
88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
}
|
|
|
90 |
else
|
91 |
{
|
92 |
-
$
|
93 |
-
$post_data[$message_field_name] = $smsmsg;
|
94 |
-
$post_data[$to_field_name] = $smsto;
|
95 |
-
$url = $api_url;
|
96 |
-
$sendSms = $this->getHelper()->sendSms($url,$post_data);
|
97 |
}
|
98 |
-
|
99 |
-
}
|
100 |
}
|
101 |
}
|
102 |
|
103 |
public function sendSmsOnOrderUnhold(Varien_Event_Observer $observer)
|
104 |
{
|
105 |
-
if($this->getHelper()->isOrderUnholdEnabled())
|
106 |
-
|
107 |
-
$order =
|
108 |
-
|
109 |
-
if ($order instanceof Mage_Sales_Model_Order)
|
110 |
-
{
|
111 |
-
$api_url = $this->getHelper()->getAPI();
|
112 |
-
$message_field_name = $this->getHelper()->getMessageField();
|
113 |
-
$to_field_name = $this->getHelper()->getToField();
|
114 |
-
|
115 |
-
if($message_field_name=='')
|
116 |
-
{
|
117 |
-
$message_field_name = 'msg';
|
118 |
-
}
|
119 |
-
if($to_field_name=='')
|
120 |
{
|
121 |
-
$to_field_name = 'to';
|
122 |
-
}
|
123 |
|
124 |
-
$
|
125 |
-
|
126 |
-
$smsto = urlencode($this->getHelper()->getTelephoneFromOrder($order));
|
127 |
-
$smsmsg = urlencode($this->getHelper()->getSenderForOrderUnHold($order));
|
128 |
-
|
129 |
-
if($sent_method)
|
130 |
{
|
131 |
-
|
132 |
-
$
|
133 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
|
135 |
-
$
|
136 |
-
|
137 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
}
|
|
|
139 |
else
|
140 |
{
|
141 |
-
$
|
142 |
-
$post_data[$message_field_name] = $smsmsg;
|
143 |
-
$post_data[$to_field_name] = $smsto;
|
144 |
-
$url = $api_url;
|
145 |
-
$sendSms = $this->getHelper()->sendSms($url,$post_data);
|
146 |
}
|
147 |
-
|
148 |
-
}
|
149 |
}
|
150 |
}
|
151 |
|
152 |
public function sendSmsOnOrderCanceled(Varien_Event_Observer $observer)
|
153 |
{
|
154 |
-
if($this->getHelper()->isOrderCanceledEnabled())
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
if ($order instanceof Mage_Sales_Model_Order)
|
159 |
-
{
|
160 |
-
$api_url = $this->getHelper()->getAPI();
|
161 |
-
$message_field_name = $this->getHelper()->getMessageField();
|
162 |
-
$to_field_name = $this->getHelper()->getToField();
|
163 |
-
|
164 |
-
if($message_field_name=='')
|
165 |
{
|
166 |
-
|
167 |
-
}
|
168 |
-
if($to_field_name=='')
|
169 |
{
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
|
178 |
-
|
179 |
-
|
180 |
-
$
|
181 |
-
$
|
182 |
-
$
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
}
|
|
|
188 |
else
|
189 |
{
|
190 |
-
$
|
191 |
-
$post_data[$message_field_name] = $smsmsg;
|
192 |
-
$post_data[$to_field_name] = $smsto;
|
193 |
-
$url = $api_url;
|
194 |
-
$sendSms = $this->getHelper()->sendSms($url,$post_data);
|
195 |
}
|
196 |
-
|
197 |
-
}
|
198 |
}
|
199 |
}
|
200 |
|
201 |
public function sendSmsOnShipmentCreated(Varien_Event_Observer $observer)
|
202 |
{
|
203 |
-
if($this->getHelper()->isShipmentsEnabled())
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
if ($order instanceof Mage_Sales_Model_Order)
|
208 |
-
{
|
209 |
-
$api_url = $this->getHelper()->getAPI();
|
210 |
-
$message_field_name = $this->getHelper()->getMessageField();
|
211 |
-
$to_field_name = $this->getHelper()->getToField();
|
212 |
-
|
213 |
-
if($message_field_name=='')
|
214 |
-
{
|
215 |
-
$message_field_name = 'msg';
|
216 |
-
}
|
217 |
-
if($to_field_name=='')
|
218 |
-
{
|
219 |
-
$to_field_name = 'to';
|
220 |
-
}
|
221 |
-
|
222 |
-
$sent_method = $this->getHelper()->getSentMethod();
|
223 |
|
224 |
-
|
225 |
-
$smsmsg = urlencode($this->getHelper()->getSenderForShipment($order));
|
226 |
-
|
227 |
-
if($sent_method)
|
228 |
{
|
229 |
-
|
230 |
-
$
|
231 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
232 |
|
233 |
-
|
234 |
-
$url = $api_url.$data;
|
235 |
-
$sendSms = $this->getHelper()->sendSms($url);
|
236 |
-
}
|
237 |
else
|
238 |
{
|
239 |
-
$
|
240 |
-
$post_data[$message_field_name] = $smsmsg;
|
241 |
-
$post_data[$to_field_name] = $smsto;
|
242 |
-
$url = $api_url;
|
243 |
-
$sendSms = $this->getHelper()->sendSms($url,$post_data);
|
244 |
}
|
245 |
-
|
246 |
-
}
|
247 |
}
|
248 |
}
|
249 |
|
6 |
if($this->getHelper()->isOrdersEnabled())
|
7 |
{
|
8 |
$orders = $observer->getEvent()->getOrderIds();
|
|
|
9 |
|
10 |
+
if(!empty($orders))
|
11 |
+
{
|
12 |
+
$order = Mage::getModel('sales/order')->load($orders['0']);
|
13 |
+
$order_inc_id = $order->getIncrementId();
|
14 |
if ($order instanceof Mage_Sales_Model_Order)
|
15 |
{
|
16 |
+
|
17 |
$api_url = $this->getHelper()->getAPI();
|
18 |
$message_field_name = $this->getHelper()->getMessageField();
|
19 |
$to_field_name = $this->getHelper()->getToField();
|
26 |
{
|
27 |
$to_field_name = 'to';
|
28 |
}
|
|
|
29 |
$sent_method = $this->getHelper()->getSentMethod();
|
|
|
30 |
$smsto = urlencode($this->getHelper()->getTelephoneFromOrder($order));
|
31 |
$smsmsg = urlencode($this->getHelper()->getMessage($order));
|
32 |
+
|
33 |
+
/*handling error*/
|
34 |
+
$flag = 1;
|
35 |
+
$error_message = "Error: order create - $order_inc_id - Not able to send SMS. Make sure that your provided correct API URL,Username and Password.";
|
36 |
+
if($api_url=='')
|
37 |
{
|
38 |
+
$flag = 0;
|
39 |
+
}
|
40 |
+
|
41 |
+
if($smsto=='')
|
42 |
+
{
|
43 |
+
$flag = 0;
|
44 |
+
}
|
45 |
|
46 |
+
if($smsmsg=='')
|
47 |
+
{
|
48 |
+
$flag = 0;
|
49 |
+
}
|
50 |
+
|
51 |
+
if($flag==1)
|
52 |
+
{
|
53 |
+
if($sent_method)
|
54 |
+
{
|
55 |
+
$data = '';
|
56 |
+
$data .= '?'.$message_field_name.'=' . $smsmsg;
|
57 |
+
$data .= '&'.$to_field_name.'=' . $smsto;
|
58 |
+
|
59 |
+
$method = 'GET';
|
60 |
+
$url = $api_url.$data;
|
61 |
+
$sendSms = $this->getHelper()->sendSms($url);
|
62 |
+
}
|
63 |
+
else
|
64 |
+
{
|
65 |
+
$method = 'POST';
|
66 |
+
$post_data[$message_field_name] = $smsmsg;
|
67 |
+
$post_data[$to_field_name] = $smsto;
|
68 |
+
$url = $api_url;
|
69 |
+
$sendSms = $this->getHelper()->sendSms($url,$post_data);
|
70 |
+
}
|
71 |
}
|
72 |
else
|
73 |
{
|
74 |
+
Mage::log($error_message,null,'smsnotify.log');
|
|
|
|
|
|
|
|
|
75 |
}
|
76 |
+
}
|
77 |
+
} // end empty
|
78 |
+
else
|
79 |
+
{
|
80 |
+
Mage::log("Error: order create - $order_inc_id - Not able to call observer. ",null,'smsnotify.log');
|
81 |
}
|
82 |
}
|
83 |
}
|
84 |
|
85 |
public function sendSmsOnOrderHold(Varien_Event_Observer $observer)
|
86 |
{
|
87 |
+
if($this->getHelper()->isOrderHoldEnabled())
|
88 |
+
{
|
89 |
+
$order = $observer->getOrder();
|
90 |
+
if ($order instanceof Mage_Sales_Model_Order)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
{
|
|
|
|
|
|
|
|
|
92 |
|
93 |
+
if ($order->getState() !== $order->getOrigData('state') && $order->getState() === Mage_Sales_Model_Order::STATE_HOLDED)
|
|
|
|
|
|
|
94 |
{
|
95 |
+
$order_inc_id = $order->getIncrementId();
|
96 |
+
$api_url = $this->getHelper()->getAPI();
|
97 |
+
$message_field_name = $this->getHelper()->getMessageField();
|
98 |
+
$to_field_name = $this->getHelper()->getToField();
|
99 |
+
|
100 |
+
if($message_field_name=='')
|
101 |
+
{
|
102 |
+
$message_field_name = 'msg';
|
103 |
+
}
|
104 |
+
if($to_field_name=='')
|
105 |
+
{
|
106 |
+
$to_field_name = 'to';
|
107 |
+
}
|
108 |
+
|
109 |
+
$sent_method = $this->getHelper()->getSentMethod();
|
110 |
+
$smsto = urlencode($this->getHelper()->getTelephoneFromOrder($order));
|
111 |
+
$smsmsg = urlencode($this->getHelper()->getMessageForOrderHold($order));
|
112 |
+
|
113 |
+
/*handling errors*/
|
114 |
+
$flag = 1;
|
115 |
+
$error_message = "Error: order hold - $order_inc_id - Not able to send SMS. Make sure that your provided correct API URL,Username and Password.";
|
116 |
+
if($api_url=='')
|
117 |
+
{
|
118 |
+
$flag = 0;
|
119 |
+
}
|
120 |
+
|
121 |
+
if($smsto=='')
|
122 |
+
{
|
123 |
+
$flag = 0;
|
124 |
+
}
|
125 |
+
|
126 |
+
if($smsmsg=='')
|
127 |
+
{
|
128 |
+
$flag = 0;
|
129 |
+
}
|
130 |
+
|
131 |
+
|
132 |
+
if($flag==1)
|
133 |
+
{
|
134 |
+
if($sent_method)
|
135 |
+
{
|
136 |
+
$data = '';
|
137 |
+
$data .= '?'.$message_field_name.'=' . $smsmsg;
|
138 |
+
$data .= '&'.$to_field_name.'=' . $smsto;
|
139 |
+
|
140 |
+
$method = 'GET';
|
141 |
+
$url = $api_url.$data;
|
142 |
+
$sendSms = $this->getHelper()->sendSms($url);
|
143 |
+
}
|
144 |
+
else
|
145 |
+
{
|
146 |
+
$method = 'POST';
|
147 |
+
$post_data[$message_field_name] = $smsmsg;
|
148 |
+
$post_data[$to_field_name] = $smsto;
|
149 |
+
$url = $api_url;
|
150 |
+
$sendSms = $this->getHelper()->sendSms($url,$post_data);
|
151 |
+
}
|
152 |
+
} // end flag
|
153 |
+
else
|
154 |
+
{
|
155 |
+
Mage::log($error_message,null,'smsnotify.log');
|
156 |
+
}
|
157 |
}
|
158 |
+
} // end state
|
159 |
else
|
160 |
{
|
161 |
+
Mage::log("Error: order hold - $order_inc_id - Not able to call observer.",null,'smsnotify.log');
|
|
|
|
|
|
|
|
|
162 |
}
|
163 |
+
|
|
|
164 |
}
|
165 |
}
|
166 |
|
167 |
public function sendSmsOnOrderUnhold(Varien_Event_Observer $observer)
|
168 |
{
|
169 |
+
if($this->getHelper()->isOrderUnholdEnabled())
|
170 |
+
{
|
171 |
+
$order = $observer->getOrder();
|
172 |
+
if ($order instanceof Mage_Sales_Model_Order)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
{
|
|
|
|
|
174 |
|
175 |
+
if ($order->getState() !== $order->getOrigData('state') && $order->getOrigData('state') === Mage_Sales_Model_Order::STATE_HOLDED)
|
|
|
|
|
|
|
|
|
|
|
176 |
{
|
177 |
+
$order_inc_id = $order->getIncrementId();
|
178 |
+
$api_url = $this->getHelper()->getAPI();
|
179 |
+
$message_field_name = $this->getHelper()->getMessageField();
|
180 |
+
$to_field_name = $this->getHelper()->getToField();
|
181 |
+
|
182 |
+
if($message_field_name=='')
|
183 |
+
{
|
184 |
+
$message_field_name = 'msg';
|
185 |
+
}
|
186 |
+
if($to_field_name=='')
|
187 |
+
{
|
188 |
+
$to_field_name = 'to';
|
189 |
+
}
|
190 |
+
$sent_method = $this->getHelper()->getSentMethod();
|
191 |
+
$smsto = urlencode($this->getHelper()->getTelephoneFromOrder($order));
|
192 |
+
$smsmsg = urlencode($this->getHelper()->getMessageForOrderUnhold($order));
|
193 |
+
|
194 |
+
/*handling errors*/
|
195 |
+
$flag = 1;
|
196 |
+
$error_message = "Error: order unhold - $order_inc_id - Not able to send SMS. Make sure that your provided correct API URL,Username and Password.";
|
197 |
+
if($api_url=='')
|
198 |
+
{
|
199 |
+
$flag = 0;
|
200 |
+
}
|
201 |
+
|
202 |
+
if($smsto=='')
|
203 |
+
{
|
204 |
+
$flag = 0;
|
205 |
+
}
|
206 |
+
|
207 |
+
if($smsmsg=='')
|
208 |
+
{
|
209 |
+
$flag = 0;
|
210 |
+
}
|
211 |
|
212 |
+
if($flag==1)
|
213 |
+
{
|
214 |
+
if($sent_method)
|
215 |
+
{
|
216 |
+
$data = '';
|
217 |
+
$data .= '?'.$message_field_name.'=' . $smsmsg;
|
218 |
+
$data .= '&'.$to_field_name.'=' . $smsto;
|
219 |
+
|
220 |
+
$method = 'GET';
|
221 |
+
$url = $api_url.$data;
|
222 |
+
$sendSms = $this->getHelper()->sendSms($url);
|
223 |
+
}
|
224 |
+
else
|
225 |
+
{
|
226 |
+
$method = 'POST';
|
227 |
+
$post_data[$message_field_name] = $smsmsg;
|
228 |
+
$post_data[$to_field_name] = $smsto;
|
229 |
+
$url = $api_url;
|
230 |
+
$sendSms = $this->getHelper()->sendSms($url,$post_data);
|
231 |
+
}
|
232 |
+
} // end flag
|
233 |
+
else
|
234 |
+
{
|
235 |
+
Mage::log($error_message,null,'smsnotify.log');
|
236 |
+
}
|
237 |
}
|
238 |
+
} // end state
|
239 |
else
|
240 |
{
|
241 |
+
Mage::log("Error: order unhold - $order_inc_id - Not able to call observer.",null,'smsnotify.log');
|
|
|
|
|
|
|
|
|
242 |
}
|
243 |
+
|
|
|
244 |
}
|
245 |
}
|
246 |
|
247 |
public function sendSmsOnOrderCanceled(Varien_Event_Observer $observer)
|
248 |
{
|
249 |
+
if($this->getHelper()->isOrderCanceledEnabled())
|
250 |
+
{
|
251 |
+
$order = $observer->getOrder();
|
252 |
+
if ($order instanceof Mage_Sales_Model_Order)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
253 |
{
|
254 |
+
if ($order->getState() !== $order->getOrigData('state') && $order->getState() === Mage_Sales_Model_Order::STATE_CANCELED)
|
|
|
|
|
255 |
{
|
256 |
+
$order_inc_id = $order->getIncrementId();
|
257 |
+
$api_url = $this->getHelper()->getAPI();
|
258 |
+
$message_field_name = $this->getHelper()->getMessageField();
|
259 |
+
$to_field_name = $this->getHelper()->getToField();
|
260 |
+
|
261 |
+
if($message_field_name=='')
|
262 |
+
{
|
263 |
+
$message_field_name = 'msg';
|
264 |
+
}
|
265 |
+
if($to_field_name=='')
|
266 |
+
{
|
267 |
+
$to_field_name = 'to';
|
268 |
+
}
|
269 |
+
$sent_method = $this->getHelper()->getSentMethod();
|
270 |
+
$smsto = urlencode($this->getHelper()->getTelephoneFromOrder($order));
|
271 |
+
$smsmsg = urlencode($this->getHelper()->getMessageForOrderCanceled($order));
|
272 |
|
273 |
+
|
274 |
+
/*handling errors*/
|
275 |
+
$flag = 1;
|
276 |
+
$error_message = "Error: order cancel - $order_inc_id - Not able to send SMS. Make sure that your provided correct API URL,Username and Password.";
|
277 |
+
if($api_url=='')
|
278 |
+
{
|
279 |
+
$flag = 0;
|
280 |
+
}
|
281 |
+
|
282 |
+
if($smsto=='')
|
283 |
+
{
|
284 |
+
$flag = 0;
|
285 |
+
}
|
286 |
+
|
287 |
+
if($smsmsg=='')
|
288 |
+
{
|
289 |
+
$flag = 0;
|
290 |
+
}
|
291 |
+
|
292 |
+
|
293 |
+
if($flag==1)
|
294 |
+
{
|
295 |
+
if($sent_method)
|
296 |
+
{
|
297 |
+
$data = '';
|
298 |
+
$data .= '?'.$message_field_name.'=' . $smsmsg;
|
299 |
+
$data .= '&'.$to_field_name.'=' . $smsto;
|
300 |
+
|
301 |
+
$method = 'GET';
|
302 |
+
$url = $api_url.$data;
|
303 |
+
$sendSms = $this->getHelper()->sendSms($url);
|
304 |
+
}
|
305 |
+
else
|
306 |
+
{
|
307 |
+
$method = 'POST';
|
308 |
+
$post_data[$message_field_name] = $smsmsg;
|
309 |
+
$post_data[$to_field_name] = $smsto;
|
310 |
+
$url = $api_url;
|
311 |
+
$sendSms = $this->getHelper()->sendSms($url,$post_data);
|
312 |
+
}
|
313 |
+
} // end flag
|
314 |
+
else
|
315 |
+
{
|
316 |
+
Mage::log($error_message,null,'smsnotify.log');
|
317 |
+
}
|
318 |
}
|
319 |
+
} // end state
|
320 |
else
|
321 |
{
|
322 |
+
Mage::log("Error: order cancel - $order_inc_id - Not able to call observer.",null,'smsnotify.log');
|
|
|
|
|
|
|
|
|
323 |
}
|
324 |
+
|
|
|
325 |
}
|
326 |
}
|
327 |
|
328 |
public function sendSmsOnShipmentCreated(Varien_Event_Observer $observer)
|
329 |
{
|
330 |
+
if($this->getHelper()->isShipmentsEnabled())
|
331 |
+
{
|
332 |
+
$shipment = $observer->getEvent()->getShipment();
|
333 |
+
$order = $shipment->getOrder();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
334 |
|
335 |
+
if ($order instanceof Mage_Sales_Model_Order)
|
|
|
|
|
|
|
336 |
{
|
337 |
+
$order_inc_id = $order->getIncrementId();
|
338 |
+
$api_url = $this->getHelper()->getAPI();
|
339 |
+
$message_field_name = $this->getHelper()->getMessageField();
|
340 |
+
$to_field_name = $this->getHelper()->getToField();
|
341 |
+
|
342 |
+
if($message_field_name=='')
|
343 |
+
{
|
344 |
+
$message_field_name = 'msg';
|
345 |
+
}
|
346 |
+
if($to_field_name=='')
|
347 |
+
{
|
348 |
+
$to_field_name = 'to';
|
349 |
+
}
|
350 |
+
|
351 |
+
$sent_method = $this->getHelper()->getSentMethod();
|
352 |
+
$smsto = urlencode($this->getHelper()->getTelephoneFromOrder($order));
|
353 |
+
$smsmsg = urlencode($this->getHelper()->getMessageForShipment($order));
|
354 |
+
|
355 |
+
/*handling errors*/
|
356 |
+
$flag = 1;
|
357 |
+
$error_message = "Error: order shipment - $order_inc_id - Not able to send SMS. Make sure that your provided correct API URL,Username and Password.";
|
358 |
+
|
359 |
+
if($api_url=='')
|
360 |
+
{
|
361 |
+
$flag = 0;
|
362 |
+
}
|
363 |
+
|
364 |
+
if($smsto=='')
|
365 |
+
{
|
366 |
+
$flag = 0;
|
367 |
+
}
|
368 |
+
|
369 |
+
if($smsmsg=='')
|
370 |
+
{
|
371 |
+
$flag = 0;
|
372 |
+
}
|
373 |
+
|
374 |
+
if($flag==1)
|
375 |
+
{
|
376 |
+
if($sent_method)
|
377 |
+
{
|
378 |
+
$data = '';
|
379 |
+
$data .= '?'.$message_field_name.'=' . $smsmsg;
|
380 |
+
$data .= '&'.$to_field_name.'=' . $smsto;
|
381 |
+
|
382 |
+
$method = 'GET';
|
383 |
+
$url = $api_url.$data;
|
384 |
+
$sendSms = $this->getHelper()->sendSms($url);
|
385 |
+
}
|
386 |
+
else
|
387 |
+
{
|
388 |
+
$method = 'POST';
|
389 |
+
$post_data[$message_field_name] = $smsmsg;
|
390 |
+
$post_data[$to_field_name] = $smsto;
|
391 |
+
$url = $api_url;
|
392 |
+
$sendSms = $this->getHelper()->sendSms($url,$post_data);
|
393 |
+
}
|
394 |
+
} // end flag
|
395 |
+
else
|
396 |
+
{
|
397 |
+
Mage::log($error_message,null,'smsnotify.log');
|
398 |
+
}
|
399 |
|
400 |
+
} // end state
|
|
|
|
|
|
|
401 |
else
|
402 |
{
|
403 |
+
Mage::log("Error: order shipment - $order_inc_id - Not able to call observer.",null,'smsnotify.log');
|
|
|
|
|
|
|
|
|
404 |
}
|
405 |
+
|
|
|
406 |
}
|
407 |
}
|
408 |
|
app/code/local/Carotechs/Smsnotify/etc/config.xml
CHANGED
@@ -9,7 +9,7 @@
|
|
9 |
<config>
|
10 |
<modules>
|
11 |
<Carotechs_Smsnotify>
|
12 |
-
<version>0.1.
|
13 |
</Carotechs_Smsnotify>
|
14 |
</modules>
|
15 |
|
9 |
<config>
|
10 |
<modules>
|
11 |
<Carotechs_Smsnotify>
|
12 |
+
<version>0.1.5</version>
|
13 |
</Carotechs_Smsnotify>
|
14 |
</modules>
|
15 |
|
package.xml
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Carotechs_Smsnotify</name>
|
4 |
-
<version>0.1.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSLv3.0</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
-
<summary>Send
|
10 |
-
<description>Send
|
11 |
-
<notes>Send
|
12 |
<authors><author><name>carotechs</name><user>carotechs</user><email>apps@carotechs.com</email></author></authors>
|
13 |
-
<date>2014-12-
|
14 |
-
<time>
|
15 |
-
<contents><target name="magelocal"><dir name="Carotechs"><dir name="Smsnotify"><dir name="Helper"><file name="Data.php" hash="
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Carotechs_Smsnotify</name>
|
4 |
+
<version>0.1.5</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSLv3.0</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
+
<summary>Send sms notification</summary>
|
10 |
+
<description>Send sms notification</description>
|
11 |
+
<notes>Send sms notification</notes>
|
12 |
<authors><author><name>carotechs</name><user>carotechs</user><email>apps@carotechs.com</email></author></authors>
|
13 |
+
<date>2014-12-19</date>
|
14 |
+
<time>09:44:29</time>
|
15 |
+
<contents><target name="mageetc"><dir name="modules"><file name="Carotechs_Smsnotify.xml" hash="cbc54fef2beda0afca8e70da6b1cb64e"/></dir></target><target name="magelocal"><dir name="Carotechs"><dir name="Smsnotify"><dir name="Helper"><file name="Data.php" hash="16b780071331ad3f75aa8e8e282fcff2"/></dir><dir name="Model"><dir name="Dropdown"><file name="Values.php" hash="c4b45a94203c6d01ad5c68254e9a47ef"/></dir><file name="Observer.php" hash="4d868dc8e1dbc7dfac8a520e986f641a"/></dir><dir name="etc"><file name="adminhtml.xml" hash="630a24f98f8d22583a25c1038663ec48"/><file name="config.xml" hash="e9473a9d5b2fb29c9a8be5f165a2d370"/><file name="system.xml" hash="264f6be93060b3c9624af49cff3cac45"/></dir></dir></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|