Automatically Add WooCommerce Customers to Groups with WP SMS Plugin

Updated on Sep 05, 2023

In the world of e-commerce, tailoring communication to your customers’ preferences can greatly enhance their experience. One powerful way to achieve this is by using the WooCommerce platform alongside plugins like WP SMS. This article walks you through a simple method to automatically group customers who purchase specific products and effectively communicate with them using the WP SMS plugin.

Automating SMS Group Membership Based on Purchases:

The WP SMS plugin, when combined with WooCommerce, allows you to automatically add customers to designated groups based on their purchases. This enables targeted messaging, fostering personalized interaction and engagement.

Steps to Add WooCommerce Customers to Groups:

  1. Install and Activate WP SMS Plugin:
    Start by installing and activating the WP SMS plugin from the WordPress Plugin Directory. This plugin enables you to send SMS notifications to customers and provides various functionalities to enhance communication.
  2. Locate Theme Functions File:
    Navigate to your WordPress theme’s directory and find the functions.php file. This is where you’ll insert the code to trigger automatic group membership.
  3. Insert the Code:
    Add the following code to your functions.php file. Replace '2' with the actual group ID you want to use.
add_action('woocommerce_checkout_order_processed', function ($orderId, $postedData, WC_Order $order) {
    $mobileNumber = \WP_SMS\Helper::getWooCommerceCustomerNumberByOrderId($orderId);
        '2' // Replace with your Group ID
  1. Save and Test:
    Save the functions.php file and perform a test purchase on your WooCommerce store. Upon successful payment, the code will automatically add the customer to the designated group.

Keep in mind that staying up-to-date with plugin updates and maintaining your code ensures a smooth experience for both you and your customers. Elevate your e-commerce communication strategy with this powerful combination of plugins and automation.