Created
April 7, 2017 23:36
-
-
Save kbxian/cf838d214a95c986b82485a1f87b543a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$sellermessage = "From: Bei Xian Koh\r\nNew order notification: Order #".$order_id."\r\nBuyer First Name: ".$buyer_firstname."\r\nBuyer Last Name: " | |
.$buyer_lastname."\r\nBuyer Email: ".$buyer_email."\r\nBuyer Phone: ".$buyer_phone."\r\nTotal Price: ".$ordertotal; | |
$sellermessage = rawurlencode($sellermessage); | |
$vphone = ''; | |
foreach ($vids as $v) { | |
// send sms to vendors | |
$vphone = get_user_meta($v, 'billing_phone', true); | |
} | |
//get wcmp vendor details | |
$buyermessage = "From: Bei Xian Koh\r\nSummary of your order: Order #".$order_id."\r\nTotal Price: ".$ordertotal; | |
for ($v = 0; $v < sizeof($vids); $v++) { | |
$u = $v + 1; | |
// send sms to vendors | |
$sfn = get_user_meta($vids[$v], 'first_name', true); | |
$sln = get_user_meta($vids[$v], 'last_name', true); | |
$semail = get_user_meta($vids[$v], 'email', true); | |
$sphone = get_user_meta($vids[$v], 'billing_phone', true); | |
$buyermessage .="\r\nSeller ".$u." First Name: ".$sfn."\r\nSeller ".$u." Last Name: " | |
.$sln."\r\nSeller ".$u." Email: ".$semail."\r\nSeller ".$u." Phone: ".$sphone; | |
// SMS TO SELLERS | |
wp_mail( '[email protected]', 'Seller New Order Notification SMS', $sellermessage ); | |
$url = 'http://login.bulksms.my/websmsapi/ISendSMS.aspx?username=newusername&password=newpassword&message='.$sellermessage.'&mobile='.$sphone.'&sender=&type=1'; | |
$ch = curl_init($url); | |
curl_setopt($ch, CURLOPT_POST, 1); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, true); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
$response = curl_exec($ch); | |
curl_close($ch); | |
//process $response | |
if ($response === FALSE) { | |
wp_mail( '[email protected]', 'FAIL: WooCommerce Seller SMS'.$v, $sellermessage ); | |
} else { | |
wp_mail( '[email protected]', 'SUCCESS: WooCommerce Seller SMS'.$v, $sellermessage ); | |
} | |
} | |
// send sms to buyer | |
$buyermessage = rawurlencode($buyermessage); | |
wp_mail( '[email protected]', 'Buyer New Order Notification SMS', $buyermessage ); | |
$url = 'http://login.bulksms.my/websmsapi/ISendSMS.aspx?username=newusername&password=newpassword&message='.$buyermessage.'&mobile='.$buyer_phone.'&sender=&type=1'; | |
$ch = curl_init($url); | |
curl_setopt($ch, CURLOPT_POST, 1); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, true); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
$response = curl_exec($ch); | |
curl_close($ch); | |
//process $response | |
if ($response === FALSE) { | |
wp_mail( '[email protected]', 'FAIL: WooCommerce Buyer SMS' , $buyermessage ); | |
} else { | |
wp_mail( '[email protected]', 'SUCCESS: WooCommerce Buyer SMS' , $buyermessage ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment