whatsapp cant send msg
complete
Hippoo
complete
Hippoo
We looked into it further, and the issue is that the country code needs to be added to the phone number. For example, if the number is
54559977
, you should add your country code (e.g., +97
) at the beginning.You can handle this with a simple function like this(change with your country code):
<?php
/**
* Add country code to phone numbers in WooCommerce REST API orders.
* Example: 09944828217 → +979944828217
*/
add_filter('woocommerce_rest_prepare_shop_order_object', function ($response, $object, $request) {
$data = $response->get_data();
if (!empty($data['billing']['phone'])) {
$data['billing']['phone'] = format_phone_with_country_code($data['billing']['phone']);
}
if (!empty($data['shipping']['phone'])) {
$data['shipping']['phone'] = format_phone_with_country_code($data['shipping']['phone']);
}
$response->set_data($data);
return $response;
}, 20, 3);
/**
* Format phone numbers by adding the +97 country code
* (adjust this for your own country code if needed).
*/
function format_phone_with_country_code($phone) {
// Remove all non-numeric characters
$phone = preg_replace('/\D+/', '', $phone);
// If the number starts with 09, replace the 0 with +97
if (preg_match('/^09\d+$/', $phone)) {
return '+97' . substr($phone, 1);
}
return $phone;
}
Hippoo
planned
Hippoo
under review
Tanvir Ahmed Tanju
i think if you remove country code then we will able to use whatsapp foe local whatsapp numbers
Hippoo
Hello Tanvir Ahmed Tanju, Thanks for your reply. Please give us some time so the development team can review it.
Hippoo
closed
Hippoo
Dear Tanvir Ahmed Tanju,
We are aware of this issue. It happens because we cannot detect the country code for WhatsApp, so we’re unable to identify the correct WhatsApp number. We may remove this feature temporarily until we find a better solution.