WhatsApp API for WordPress & WooCommerce (No Plugin Required)
Any statistics or percentages in this article are general industry figures or illustrations, not QuackAPI measurements or promises. Results depend on your audience, consent and sending patterns. QuackAPI connects to WhatsApp as a linked device (an unofficial method), so read our risk and acceptable use policy before sending.
WhatsApp + WooCommerce: The Plugin-Free Approach
Most WhatsApp WooCommerce plugins cost $50–200/year and add bloat to your WordPress installation. QuackAPI lets you integrate directly using WooCommerce action hooks — a few lines of PHP in your theme's functions.php or a tiny custom plugin.
This approach gives you full control, no recurring plugin fees, and works on any WordPress hosting. The only external cost is QuackAPI's subscription (free tier available).
Before building, review the WhatsApp messaging best practices guide for compliance tips and anti-ban guidelines. For webhook event handling and delivery receipts, see the WhatsApp webhook setup guide. For a Shopify equivalent, see our WhatsApp Shopify integration guide.
Method 1: PHP Hook in functions.php
Add this code to your theme's functions.php or create a simple WordPress plugin. It hooks into WooCommerce's order status change events and sends a WhatsApp notification:
<?php
// Add to functions.php or a custom plugin file
define('QUACKAPI_KEY', getenv('QUACKAPI_KEY') ?: 'your-api-key');
define('QUACKAPI_DEVICE_ID', 1);
function send_whatsapp_via_quackapi($phone, $message) {
$response = wp_remote_post('https://quackapi.com/v1/messages/send', [
'headers' => [
'Content-Type' => 'application/json',
'x-api-key' => QUACKAPI_KEY,
],
'body' => json_encode([
'deviceId' => QUACKAPI_DEVICE_ID,
'to' => preg_replace('/[^0-9]/', '', $phone),
'content' => $message,
'type' => 'text',
]),
'timeout' => 10,
]);
return !is_wp_error($response);
}
// Hook: order placed
add_action('woocommerce_order_status_pending', function($order_id) {
$order = wc_get_order($order_id);
$phone = $order->get_billing_phone();
if (!$phone) return;
$name = $order->get_billing_first_name();
$num = $order->get_order_number();
$total = $order->get_formatted_order_total();
send_whatsapp_via_quackapi(
$phone,
"Hi {$name}! Your order #{$num} has been received. Total: {$total}. We'll notify you when it ships!"
);
});
// Hook: order shipped (processing → completed)
add_action('woocommerce_order_status_completed', function($order_id) {
$order = wc_get_order($order_id);
$phone = $order->get_billing_phone();
if (!$phone) return;
$name = $order->get_billing_first_name();
$num = $order->get_order_number();
send_whatsapp_via_quackapi(
$phone,
"Hi {$name}, great news! Order #{$num} has been shipped and is on its way to you!"
);
});Method 2: WooCommerce Webhooks → External Server
If you prefer to keep the WhatsApp logic off your WordPress server, use WooCommerce's built-in Webhook system to forward order events to an external Node.js or Python server, which then calls QuackAPI.
Go to WooCommerce → Settings → Advanced → Webhooks → Add Webhook. Set Topic to 'Order Created', Delivery URL to your server endpoint, and Status to Active.
// Node.js receiver for WooCommerce webhooks
const express = require('express');
const axios = require('axios');
const app = express();
app.use(express.json());
app.post('/woo-webhook', async (req, res) => {
const order = req.body;
const phone = order.billing?.phone;
if (!phone) return res.json({ ok: true });
const name = order.billing?.first_name;
const num = order.number;
const total = order.total;
await axios.post('https://quackapi.com/v1/messages/send', {
deviceId: 1,
to: phone.replace(/[^0-9]/g, ''),
content: `Hi ${name}! Order #${num} confirmed. Total: ${total}. We'll send tracking soon!`,
type: 'text'
}, {
headers: { 'x-api-key': process.env.QUACKAPI_KEY }
});
res.json({ sent: true });
});
app.listen(3000);Setting Your API Key Securely
Never hardcode your QuackAPI API key in functions.php — it will be visible in version control. Use WordPress's environment variable support or a secrets plugin.
If you are on a hosting provider that supports .env files or server environment variables, set QUACKAPI_KEY there. Otherwise, store it in wp-config.php (which should be outside your web root) using define('QUACKAPI_KEY', 'wa_your_key_here');.
// In wp-config.php (above the "That's all" comment):
define('QUACKAPI_KEY', 'wa_your_actual_key_here');
define('QUACKAPI_DEVICE_ID', 1);
// Then in functions.php, use:
$key = defined('QUACKAPI_KEY') ? QUACKAPI_KEY : '';WooCommerce WhatsApp Message Templates
The right message template converts browsers into buyers and keeps existing customers coming back. Here are proven WooCommerce notification templates optimized for WhatsApp:
Order placed: 'Hi {name}! Order #{order_id} received. Total: {total}. We'll confirm payment and send shipping updates here. Questions? Just reply!' This reassures the customer immediately after checkout, reducing support contacts by up to 30%.
Payment confirmed: 'Great news, {name}! Payment for order #{order_id} confirmed. We're preparing your items now. Estimated dispatch: {dispatch_date}.'
Order shipped: 'Your order is on its way, {name}! Tracking: {tracking_link}. Estimated delivery: {delivery_date}. Reply TRACK for updates.'
Order delivered (+ review request): 'Hi {name}! Your order should have arrived. Hope you love it! If you have a moment, a quick review means a lot: {review_link}. Need anything? Just reply.'
Subscription renewal reminder (7 days before): 'Hi {name}! Your {product_name} subscription renews in 7 days. No action needed — we'll charge the card on file. To update payment details: {account_link}.'
These templates use WooCommerce order data available directly in the webhook payload. For e-commerce WhatsApp automation patterns, see our e-commerce use cases. For advanced bulk messaging techniques, see the bulk WhatsApp messaging guide.
Handling Errors and Retries
Network errors and API rate limits are normal in production. Your WordPress integration must handle failures gracefully to avoid losing important customer notifications.
Wrap every wp_remote_post call in a try-catch equivalent and check the response code. A 429 response from QuackAPI means you have hit your daily message limit. Log the failure and retry the next day using wp_schedule_single_event.
For critical messages (order confirmations), implement a retry mechanism: if the first send fails, queue a retry for 15 minutes later using WordPress cron. After 3 failed attempts, log the failure to a custom WooCommerce order note so your support team can follow up manually.
Store the QuackAPI API response for each notification in WooCommerce order meta. This gives you a complete audit trail: order ID, customer phone, message sent, timestamp, and delivery status. In the QuackAPI dashboard, configure a webhook callback to receive delivery receipts and update the order meta accordingly.