Admin Orders and the WhatsApp Button
Phone field on admin orders#
When you or your staff create or edit an order in WooCommerce > Orders, the billing and shipping phone get the flag dropdown. Phone orders and manual orders are saved with the country code too.
Turn it on or off under WooCommerce > Smart Phone Field > General > Phone field on admin orders. It’s on by default. In code, use the nahnu_spf_admin_order_phone filter.
Message on WhatsApp button#
On the order screen, a Message on WhatsApp button shows under the billing phone and under the shipping phone. Click it to open WhatsApp with the customer’s number and a starting message that includes their name and the order number.
The button only shows when that address has a phone number.
Turn it on or off under WooCommerce > Smart Phone Field > General > WhatsApp button on orders. It’s on by default.
In code#
nahnu_spf_whatsapp_buttonshows or hides the button. It receives true or false, the order, the phone number and the address country.nahnu_spf_whatsapp_messagechanges the starting message. It receives the message and the order. Return an empty string for no message.nahnu_spf_whatsapp_urlchanges the full link.
add_filter( 'nahnu_spf_whatsapp_message', function ( $message, $order ) {
return sprintf( 'Hi %s, about your order #%s', $order->get_billing_first_name(), $order->get_order_number() );
}, 10, 2 );