DEV Community

Wabbiyo
Wabbiyo

Posted on

WooCommerce Order Updates on WhatsApp: 6 Bugs I’d Watch For


Sending a WhatsApp message when a WooCommerce order changes status sounds like a 10-line job. In production, these six problems show up first.

  1. Sending inside the request
    If you call the WhatsApp API directly inside woocommerce_order_status_changed, a slow API response slows down checkout or the admin order screen. Push the work to Action Scheduler with as_enqueue_async_action() instead.

  2. The same message twice
    Admins move an order from processing to on-hold and back. Your hook fires each time. Save a meta flag such as _wa_sent_processing and check it before sending.

  3. Bad phone numbers
    Customers type “098765 43210”, “+91-98765-43210” or a number without the country code. Normalise using the billing country, strip everything except digits, and drop the leading zero.

  4. No consent
    Sending without opt-in risks your number’s quality rating. Add a checkbox at checkout, save it to order meta, and check it before every send.

  5. Template category drift
    “Your order shipped! Use code SAVE10 on your next order” looks harmless, but Meta will treat it as marketing. Keep order templates purely transactional so they stay in the cheaper utility category.

  6. Silent failures
    The API returns a message ID even if delivery later fails. Subscribe to the status webhook, write the result to the order notes, and fall back to the WooCommerce email when it fails.

php
add_action( 'woocommerce_order_status_changed', function( $id, $from, $to, $order ) {
$tpl = $map[ $to ] ?? null;
if ( $tpl && has_opt_in( $order ) && ! $order->get_meta( "wa_sent$to" ) ) {
as_enqueue_async_action( 'send_wa_order_update', [ $id, $tpl ] );
}
}, 10, 4 );

If you’d rather not build and maintain this, Wabbiyo is a WordPress plugin that does it on the official WhatsApp Cloud API, with a free plan: Click here to learn more

Top comments (0)