问题描述
我是新来的。 wordpress更新后,我的代码不起作用。请指导我。 经过长时间的努力,我编写了这段代码。即使我对编码没有太多了解。一切正常。但是毫无疑问,它现在无法正常工作。下订单后,这实际上会向管理员发送短信。
add_action( 'woocommerce_order_status_processing','adminsms');
function adminsms( $order_id ){
// Order Setup Via WooCommerce
$order = new WC_Order($order_id);
$orderid = get_post_meta($order_id,'_order_number',true);
$odd = get_post_meta($order_id,'_id',true);
$orderdd = get_post_meta($order_id,'_order_id',true);
$billing_firstname = get_post_meta($order_id,'_billing_first_name',true);
$billing_lastname = get_post_meta($order_id,'_billing_last_name',true);
$billing_phone = get_post_meta($order_id,'_billing_phone',true);
$shipping_address1 = get_post_meta($order_id,'_billing_address_1',true);
$shipping_address2 = get_post_meta($order_id,'_billing_address_2',true);
$city = get_post_meta($order_id,'_billing_city',true);
$medallion = strtoupper(get_user_Meta($order->user_id,'loyalty_status',true));
$order_amount = get_post_meta($order_id,'_order_total',true);
$pay_type = get_post_meta($order_id,'_payment_method',true);
$num1 = preg_replace("/[^0-9]/","",$billing_phone );
$num2 = ltrim($num1,"0");
$num3 = str_replace('+9203','923',$num2);
$number = str_replace('+923',$num3);
//YOUR CREDENTIALS
$sender = "awra";
$username = "****";///Your Username
$password = "****";///Your Password
$mobile = "$number";///Recepient Mobile Number
//YOUR MESSAGE to ADMIN
$wa1 = "$billing_firstname%20$billing_lastname%20I%20have%20recieved%20your%20order%23%20$order_id%20of%20amount%20Rs.%20$order_amount.";
$wamsg = preg_replace('/[^A-Za-z0-9%\-]/','',$wa1);
$alert = "$billing_firstname $billing_lastname
Order# $order_id
Amount: Rs. $order_amount
City: $city
wa.me/$billing_phone?text=$wamsg";
$url = 'http://api.muxmarketo.com/api/sendsms?id='.urlencode($username).'&pass='.urlencode($password).'&mobile='.urlencode(923234442972).'&brandname='.urlencode($sender).'&msg='.urlencode($alert).'&language=English';
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
$output=curl_exec($ch);
if(curl_errno($ch))
{
echo 'error:' . curl_error($c);
}
else
{
echo $output;
}
curl_close($ch);
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)