How to Customize the WooCommerce “Place Order” Button Text with woocommerce_order_button_text Filter

In WooCommerce, the “Place Order” button on the checkout page plays a critical role in completing a purchase. However, there may be times when you want to customize the text on this button based on specific conditions, such as when a certain product is in the cart. This article will show you how to change the WooCommerce “Place Order” button text using the woocommerce_order_button_text filter.

You can use the free Code snippets plugin to conveniently add code snippets to your page: How to Add Custom Code to Your Page Using the Code Snippets Plugin

Changing the Order Button Text Regardless of Cart Contents

If you want to change the “Place Order” button text regardless of what’s in the cart, you can use a simpler code snippet. This is useful if you prefer a different call-to-action for branding or messaging reasons.

Example Code Snippet for Unconditional Button Text Change using woocommerce_order_button_text

add_filter('woocommerce_order_button_text', 'change_order_button_text_to_custom');

function change_order_button_text_to_custom($button_text) {
    return 'Pay Securely Now';

In this case, the button text is changed to “Pay Securely Now” for every order. This snippet doesn’t consider cart contents, so it’s a straightforward way to customize the button text.

Customizing WooCommerce Order Button Text Based on Cart Contents

To change the WooCommerce order button text based on specific criteria, you can use the woocommerce_order_button_text filter. This example demonstrates how to change the text when a certain product, such as one with ID 91, is in the cart.

add_filter('woocommerce_order_button_text', 'change_order_button_text', 15, 1);

function change_order_button_text($button_text) {
    // Check if product with ID 91 is in the cart
    if (is_product_in_cart(91)) {
        $button_text = 'Support Us';

    return $button_text;

function is_product_in_cart($product_id) {
    // Check if the product is in the cart
    foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) {
        $product_in_cart = $cart_item['product_id'];
        if ($product_in_cart === $product_id) {
            return true;

    return false;

This snippet checks if a specific product (with ID 91) is in the cart. If it is, the button text changes to “Support Us.” Otherwise, it remains as the default “Place Order.”

Using Code Snippets Plugin to Add Custom Code

If you’re not comfortable editing your theme’s functions.php file or creating a custom plugin, the free Code Snippets plugin is a convenient alternative for adding custom PHP code to your WordPress site: