Black Friday & Cyber Monday SUPER SALE ALL WEEK:
Grab 40% OFF on plugins
Days
Hours
Minutes
Seconds

How to Display Custom Messages for Free Shipping in WooCommerce?

Do you want to display a custom message to your customers about the ‘free shipping’ option in your WooCommerce store? You can use a code snippet to display a custom message on the cart and checkout pages based on the customer’s shipping method. This will help you provide more information about the shipping process to your customers.

add_action('woocommerce_cart_totals_after_shipping', 'ts_shipping_method_custom_message');
add_action('woocommerce_review_order_after_shipping', 'ts_shipping_method_custom_message');

// Function to display custom message for free shipping
function ts_shipping_method_custom_message() {
    // Define your targeted shipping method(s)
    $targeted_shipping_methods = array('free_shipping:59'); // Replace with the actual shipping method ID(s)

    // Get the chosen shipping methods
    $chosen_methods = WC()->session->get('chosen_shipping_methods');

    if (!empty($chosen_methods)) {
        $chosen_method = reset($chosen_methods);

        // Check if the chosen shipping method is in the targeted list
        if (in_array($chosen_method, $targeted_shipping_methods)) {
            echo '<tr class="shipping">
                    <td colspan="2" style="text-align:center">' . sprintf(
                    __("Great choice! You have selected free shipping for your order")
                ) . '</td>
                </tr>';
        }
    }
}

Output

When a customer selects a shipping method, such as free shipping, a personalized message appears below the shipping details on the cart page.

How to Display Custom Messages for Free Shipping in WooCommerce? - Tyche Softwares

Also, it shows the custom message for the free shipping option on the WooCommerce checkout page as shown below.

How to Display Custom Messages for Free Shipping in WooCommerce? - Tyche Softwares

Additionally, you can also display a custom message based on shipping zones in WooCommerce. This feature will automatically notify customers located outside your usual shipping area.

Browse more in: Code Snippets, WooCommerce How Tos, WooCommerce Tutorials

Share It:

Subscribe
Notify of
0 Comments
Newest
Oldest
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x