How to Build a WordPress Plugin for WhatsApp Messaging Using SendZen.io
Turn WooCommerce into a high-converting storefront by sending WhatsApp messages for abandoned carts, order updates, and click to chat. This guide shows how developers can create a WordPress plugin that talks to SendZen's Free WhatsApp Business API, with examples you can paste into your project.
Why use WhatsApp for WooCommerce instead of email
- Email open rates for abandoned carts are typically around 20 percent.
- WhatsApp open rates are near 99 percent, with 40 percent plus reply rates.
- More attention equals higher recovery and more revenue.
The challenge for most teams is integration. Dealing directly with the raw Meta Cloud API can be slow and brittle. SendZen.io provides a developer first wrapper that removes friction so you can ship in minutes.
Step 1: Get your SendZen API key
- Sign up at SendZen.io.
- Create or connect a WhatsApp number.
- Copy your API key from the dashboard.
Helpful resources:
Step 2: Create a minimal WordPress plugin
Make a new folder:
/wp-content/plugins/cartbox-whatsapp/
cartbox-whatsapp.php
includes/
assets/
Add a basic plugin header in cartbox-whatsapp.php
:
<?php
/*
Plugin Name: Cartbox WhatsApp Plugin
Description: Custom WhatsApp integration using SendZen API
Version: 1.0.0
Author: Your Name
*/
Activate the plugin in WordPress Admin - Plugins.
Step 3: Send a WhatsApp message on successful WooCommerce order
Hook into the WooCommerce thank you event and call SendZen:
<?php
function cartbox_sendzen_send_order_confirmation( $order_id ) {
if ( ! $order_id ) return;
$order = wc_get_order( $order_id );
if ( ! $order ) return;
$phone = $order->get_billing_phone();
if ( ! $phone ) return;
$api_key = 'YOUR_SENDZEN_API_KEY';
$url = 'https://api.sendzen.io/v1/messages';
$payload = array(
'to' => $phone,
'template' => 'order_confirmation',
'template_params' => array(
'order_id' => (string) $order_id,
'customer_name' => $order->get_billing_first_name()
)
);
$response = wp_remote_post( $url, array(
'headers' => array(
'Authorization' => 'Bearer ' . $api_key,
'Content-Type' => 'application/json'
),
'body' => wp_json_encode( $payload ),
'timeout' => 20
) );
// Optional: handle errors or log $response
}
add_action( 'woocommerce_thankyou', 'cartbox_sendzen_send_order_confirmation' );
Result: customers get instant WhatsApp confirmations right after checkout.
Step 4: Recover abandoned carts with a cron task
Strategy:
- Detect carts that reached checkout but never paid.
- Queue a reminder at 30 to 60 minutes after abandonment.
- Send a WhatsApp reminder through SendZen with a return to checkout link or a limited time coupon.
Register a cron event on plugin activation:
<?php
function cartbox_whatsapp_activate() {
if ( ! wp_next_scheduled( 'cartbox_abandoned_cart_cron' ) ) {
wp_schedule_event( time() + 600, 'half_hour', 'cartbox_abandoned_cart_cron' );
}
}
register_activation_hook( __FILE__, 'cartbox_whatsapp_activate' );
// Add a custom schedule if needed
add_filter( 'cron_schedules', function( $schedules ) {
if ( ! isset( $schedules['half_hour'] ) ) {
$schedules['half_hour'] = array( 'interval' => 1800, 'display' => 'Every 30 minutes' );
}
return $schedules;
} );
Scan and notify:
<?php
function cartbox_get_abandoned_orders() {
// Replace this stub with your store logic
// Example: query WooCommerce orders with status pending or failed older than 30 minutes
return array();
}
function cartbox_send_abandoned_reminder( $order_id ) {
$order = wc_get_order( $order_id );
if ( ! $order ) return;
$phone = $order->get_billing_phone();
if ( ! $phone ) return;
$api_key = 'YOUR_SENDZEN_API_KEY';
$url = 'https://api.sendzen.io/v1/messages';
$payload = array(
'to' => $phone,
'template' => 'abandoned_cart_reminder_1',
'template_params' => array(
'first_name' => $order->get_billing_first_name(),
'return_url' => wc_get_checkout_url()
)
);
wp_remote_post( $url, array(
'headers' => array(
'Authorization' => 'Bearer ' . $api_key,
'Content-Type' => 'application/json'
),
'body' => wp_json_encode( $payload )
) );
}
add_action( 'cartbox_abandoned_cart_cron', function() {
$orders = cartbox_get_abandoned_orders();
foreach ( $orders as $order_id ) {
cartbox_send_abandoned_reminder( $order_id );
}
} );
Step 5: Add click to chat, admin notifications, and opt in management
- Click to chat widget: print a floating button that opens a WhatsApp chat link. Example:
https://wa.me/<NUMBER>?text=Hi%20there
.
- Admin notifications: trigger a SendZen message to your store number whenever an order is paid.
- Opt in and opt out: store consent in user meta or order meta so reminders are compliant.
- Test mode: use SendZen sandbox to simulate delivery and inbound events without reaching real users. See Docs.
Why use SendZen instead of the raw Meta Cloud API
Feature |
Meta Cloud API |
SendZen API |
Onboarding |
Multi day approvals and manual setup |
Self serve in under 5 minutes |
SDKs and examples |
Minimal |
Node.js, Python, PHP, Ruby, Go, Java |
Webhooks |
Manual configuration |
Predictable events with retries |
Debugging |
Raw JSON and console work |
Real time logs in dashboard |
Compliance and security |
You own everything |
GDPR and CCPA ready, encryption at rest and in transit |
Going further: whitelabel and platform use cases
If you are building a multi tenant SaaS or want a branded WhatsApp portal, check the partner program. You can embed onboarding, template management, and billing with your brand. Learn more at SendZen Partner.
Wrap up and next steps
With a few hooks and a simple REST call, you can build your own WhatsApp plugin for WordPress and WooCommerce. Start with order confirmations, add abandoned cart reminders, then layer in click to chat and admin alerts. SendZen handles the heavy lifting so you can focus on user experience and revenue.
Get started now:
Free WhatsApp Business API |
API Reference and Guides |
Whitelabel and Platform Program