To send SMS from WordPress, call wp_remote_post() against https://api.tryready.com/v1/messages with an X-API-Key header and a JSON body, from a function you attach to a WooCommerce order status hook. Keep the key in a wp-config.php constant, schedule the call instead of running it inline, and only text customers who ticked a consent checkbox at checkout.

This is the developer version: a small plugin, not a marketing setup. It covers the hook, the consent field, the send, and a retry that doesn't text anyone twice. For a no-code route through automation tools, see SMS API integrations for HubSpot, Zoho, n8n and WordPress. The PHP below targets current WordPress and WooCommerce, and you should run it on staging first.

The pieces and how they fit

PieceWordPress mechanismWhy
Secretdefine() in wp-config.phpStays out of the database and the admin UI
ConsentCheckbox on checkout, saved as order metaA send needs a recorded yes
Triggerwoocommerce_order_status_changedFires for every status transition
Deliverywp_schedule_single_eventKeeps the HTTP call off the customer's request
RetryTransient counter plus another scheduled eventSurvives a failed call without a queue table
DedupeIdempotency-Key stored in order metaA retry never sends twice

Keep the key in wp-config

Add the key to wp-config.php, above the line that says to stop editing:

define( 'READY_API_KEY', 'paste-your-key-here' );

Then read it with defined() before any call. A key typed into a settings page ends up in the options table, in database backups and in anything that dumps options. A constant lives in a file your host already treats as sensitive. Use a test key on staging, which simulates sends without texting or charging anyone, and read API key security and rotation for the wider habits.

Add the consent checkbox

Render a checkbox on the checkout form, unchecked by default, with plain wording about what you'll send and how to stop.

add_action( 'woocommerce_review_order_before_submit', function () {
	woocommerce_form_field( 'rdy_sms_consent', array(
		'type'  => 'checkbox',
		'label' => 'Text me updates about this order. Msg and data rates may apply. Reply STOP to opt out.',
	), '' );
} );

add_action( 'woocommerce_checkout_create_order', function ( $order, $data ) {
	if ( ! empty( $_POST['rdy_sms_consent'] ) ) {
		$order->update_meta_data( '_rdy_sms_consent', gmdate( 'c' ) );
	}
}, 10, 2 );

Saving a timestamp, not just yes, gives you something to show later. The consent_attested field on the API is your promise that the recipient agreed. It isn't a per-contact record, so the proof stays in your order data. Consent records for developers suggests what else to store, such as the wording shown.

Hook the order status and schedule the send

Don't call the API inside the status hook. A slow response would hold up whoever changed the order, and a timeout would look like a store error. Schedule an event a few seconds out and return.

add_action( 'woocommerce_order_status_changed', function ( $order_id, $from, $to, $order ) {
	if ( 'processing' !== $to && 'completed' !== $to ) {
		return;
	}
	if ( ! $order->get_meta( '_rdy_sms_consent' ) ) {
		return;
	}
	$flag = '_rdy_sms_sent_' . $to;
	if ( $order->get_meta( $flag ) ) {
		return; // already sent for this status
	}
	if ( ! $order->get_meta( '_rdy_idem_' . $to ) ) {
		$order->update_meta_data( '_rdy_idem_' . $to, wp_generate_uuid4() );
		$order->save();
	}
	wp_schedule_single_event( time() + 5, 'rdy_send_order_sms', array( $order_id, $to ) );
}, 10, 4 );

The idempotency key is made once per order and status, stored, and reused on every retry. That's what stops a second text when a slow first call actually succeeded. See idempotency keys and duplicate texts.

The send function with wp_remote_post

add_action( 'rdy_send_order_sms', function ( $order_id, $status ) {
	$order = wc_get_order( $order_id );
	if ( ! $order || ! defined( 'READY_API_KEY' ) ) {
		return;
	}
	$phone = preg_replace( '/[^\d+]/', '', (string) $order->get_billing_phone() );
	if ( '' === $phone ) {
		return;
	}
	$text = ( 'completed' === $status )
		? sprintf( 'Order #%s has shipped.', $order->get_order_number() )
		: sprintf( 'We got order #%s and are packing it.', $order->get_order_number() );

	$response = wp_remote_post( 'https://api.tryready.com/v1/messages', array(
		'timeout' => 8,
		'headers' => array(
			'X-API-Key'       => READY_API_KEY,
			'Idempotency-Key' => $order->get_meta( '_rdy_idem_' . $status ),
			'Content-Type'    => 'application/json',
		),
		'body'    => wp_json_encode( array(
			'to'                 => $phone,
			'body'               => $text,
			'consent_attested'   => true,
			'hold_until_allowed' => true,
		) ),
	) );

	$code = is_wp_error( $response ) ? 0 : (int) wp_remote_retrieve_response_code( $response );

	if ( $code >= 200 && $code < 300 ) {
		$order->update_meta_data( '_rdy_sms_sent_' . $status, gmdate( 'c' ) );
		$order->save();
		delete_transient( 'rdy_attempts_' . $order_id . $status );
		return;
	}
	$body       = is_wp_error( $response ) ? array() : json_decode( wp_remote_retrieve_body( $response ), true );
	$error_code = is_array( $body ) && isset( $body['error_code'] ) ? $body['error_code'] : '';
	if ( 0 === $code || 429 === $code || $code >= 500 || 'idempotency_in_progress' === $error_code ) {
		rdy_schedule_retry( $order_id, $status );
		return;
	}
	if ( 'idempotency_outcome_unknown' === $error_code ) {
		$order->add_order_note( 'SMS outcome unknown, check the message log before resending' );
		return;
	}
	$order->add_order_note( 'SMS not sent, API answered ' . $code );
}, 10, 2 );

Two choices here are worth explaining. hold_until_allowed asks Ready to hold the text up to 24 hours when the recipient is in quiet hours, so a 1 AM order doesn't come back as a 409 QUIET_HOURS_BLOCK. Without it, an API text is held only if the window opens within 6 hours. And the code retries only on a network failure, a 429, a 5xx or a 409 idempotency_in_progress (the first try is still running). A 4xx means the request was wrong or refused, and sending it again won't change that. The error codes reference lists what each means.

A transient-based retry

A transient is a good fit for a small attempt counter, since it expires on its own.

function rdy_schedule_retry( $order_id, $status ) {
	$key      = 'rdy_attempts_' . $order_id . $status;
	$attempts = (int) get_transient( $key ) + 1;
	if ( $attempts > 4 ) {
		delete_transient( $key );
		$order = wc_get_order( $order_id );
		if ( $order ) {
			$order->add_order_note( 'SMS gave up after 4 attempts' );
		}
		return;
	}
	set_transient( $key, $attempts, DAY_IN_SECONDS );
	$delay = 60 * ( 2 ** $attempts ); // 2, 4, 8, 16 minutes
	wp_schedule_single_event( time() + $delay, 'rdy_send_order_sms', array( $order_id, $status ) );
}

The delay doubles each time, and the stored idempotency key means a retry after an ambiguous failure can't produce a second text. The general pattern, with jitter, is in retries and failure handling.

WP-Cron runs when someone visits the site, so on a quiet store a scheduled event can run late. If timing matters, trigger wp-cron.php from a real cron job. WooCommerce also bundles Action Scheduler, which gives you a proper queue and logs if you'd rather not use WP-Cron.

What it costs and what to log

A text of one segment is billed at $0.0075 plus a $0.0045 carrier fee, so $0.012 all-in per segment. Two order texts for 500 orders, assuming one segment each, is 1,000 x $0.012 = $12. Accounts opened before November 12, 2026 keep their signup prices, shown under Billing. You need a card on file and a number of your own, at $2 a month.

Ready's all-in prices per segment include the carrier fee but not screening: Scrub lists and Number validation, the two switches in Settings under Compliance, each add $0.003 per segment when switched on, shown as screening on your bill, and both are off by default. Unless you turn the opt-out footer off, the first text to each contact, and one again from time to time, also gets "Reply STOP to opt out" and your business name if the message does not already have them, so a text close to the segment limit can bill one more segment.

Log the order id, status, HTTP code and attempt count, never the key. Order notes, as above, put the failure where support will look.

Closing notes

Hook, schedule, send, retry, and only for customers who agreed. Test the whole path against a test key on staging, then send a few real texts to phones you own before turning it on for customers. The API quickstart has the first send in curl if you want to check the key before writing PHP.