Customizing the Order Items in SMS Notifications for WooCommerce with WP SMS

Updated on Dec 08, 2024

Filter

wp_sms_notification_woocommerce_order_item

By default, when you use the %order_items% variable (reference) in the SMS message templates, the purchased items in an order are displayed in the following format:

- ProductName x Quantity Price

For example, if a customer orders a product, the purchased item in the SMS looks like this:

- Product A x 2 $49.99

You can customize how order item details are displayed in the SMS using the wp_sms_notification_woocommerce_order_item filter.

Example Usage

To modify the order item data in the SMS notification, add the following hooks to the functions.php file of your active theme.

Basic Customization: Display Only the Product Name

add_filter('wp_sms_notification_woocommerce_order_item', function ($itemString, $orderItemData, $item, $order) {
    return "- {$orderItemData['name']}";
}, 10, 4);

Display the Item Name and the Quantity

add_filter('wp_sms_notification_woocommerce_order_item', function ($itemString, $orderItemData, $item, $order) {
    return "- {$orderItemData['name']} x {$orderItemData['quantity']}";
}, 10, 4);