How to Change Place Order Button Text in WooCommerce?

Change Place Order Button Text in WooCommerce

In this article, we will learn how to change the place order button text on woocommerce checkout page?

This button text changes dynamically according to the selected payment method. If you have more than one payment method then it will change accordingly like for the PayPal button text is “Proceed to Paypal” and for the COD button text is “Place Order“.

So, in this article, we will learn to change the place order button text with our own custom text.

Let’s get started.

Change the Place Order Button Text in WooCommerce

You can change the place order button text in 3 ways.

For the first two methods, you need to hook a function in the functions.php file to change the text, which we will see below with examples.

Hooks are:
woocommerce_order_button_text
woocommerce_order_button_html

And in the third method, you can change the woocommerce template file, if you know about how to override the woocommerce template file.

File-path is:
plugins > woocommerce > templates > checkout > payment.php

Let’s start with hook’s methods.

Method 1: Change Place Order Button Text with woocommerce_order_button_text

This is a very simple method to change the button text. You just have to hit the function with this hook filter and return the custom own text.

Copy the below code in your active theme’s functions.php file (I would recommend child theme to use any customization).

After inserting this code in your functions.php file save it and check the result on woocommerce checkout page. You will see the difference, like the below images.

Place Order Button Before
Before hook function

Place Order Button After
After hook function

Method 2: Change Place Order Button Text with woocommerce_order_button_html

With this filter hook method, we can also change the place order button text with our own custom text. It is also a simple method.

This filter hook woocommerce_order_button_html returns the button HTML and we will use str_replace(), substr_replace() or preg_replace() PHP function to replace the “Place Order” text in the HTML.

You can also create the button HTML from scratch and make it as per your requirements.

Let’s see the code.

Place this above code in your theme’s functions.php file and save it. And you will see the result same as the first method.

Method 3: Change Place Order Button Text with Template file (payment.php)

In this method, we will override the woocommerce template file to change the place order button text.

Note: Use the child theme to override the woocommerce template files OR any changes you want to make. Check this step-by-step guide, If you don’t know how to create a child theme in WordPress.

Let’s see how to do that.

Firstly, you need to find this file (payment.php) in woocommerce’s templates folder and then copy this file in your theme folder.

  1. Go to this path plugins > woocommerce > templates > checkout
  2. Find the payment.php file and copy it
  3. Create a new folder “woocommerce” in your active theme and create a new folder “checkout” inside woocommerce folder
  4. And place that copy file in the checkout folder
  5. Now, you can make changes in this file. You will see the button in this file file like below image
Place Order Button in Template File
Place Order Button in Template File (payment.php)

In this code, you can change the button text.

Note: I will recommend using the above two filter hooks methods that are very simple and easy.

Change the Place Order Button Text on WooCommerce Checkout Based on Specific Product in Cart

Yes! you can change the place order button text based on the specific product or category in the cart OR you can make any condition.

We just have to make a condition in the above methods to check is it true or not? If it will true then the button text will change otherwise not.

Let’s see with example code.

In the above example, we check that the “shoes” category product exists in the cart or not. If it will exist then the place order button text will be changed else not.

You can also check the specific product with the ID. e.g:

This code will change the place order button text only for product ID 22 if it is in the cart.

Change the Button Text For Other Payment Gateways

You can also change the button text for other payment gateways.

Suppose, if other payment gateways OR your custom payment gateway don’t have a hook to change the button text then what you will do? Because you cannot make plugin file changes directly.

So, in this case, you will use gettext filter hook to achieve this. It will work for mostly all payment gateways and you can also use this to change any text in woocommerce files.

Let’s see the code.

Place this code in your active theme’s functions.php file and save it. And then you will see the button text has been changed for the PayPal payment gateway.

See the following images before and after the gettext filter hooks.

Paypal Button Before
PayPal Button Before gettext hook

PayPal Button After
PayPal Button After gettext hook

You can also change the translatable text with the plugin Say What.

Installed and Activate the SayWhat plugin. Follow this step-by-step guide on how to install the WordPress plugin?

After installation, you will find the option under Tools >Text Changes. And add a new Text Changes to change any specific text in woocommerce.

That’s it.

Hope! you understand the above methods about how to change woocommerce place order button text and also change for if a specific product in cart and change the button text for other payment gateways.

If you have any query ask me in the comment section, I’ll respond to you asap.

You May Also Like

About the Author: Aman Mehra

Hey! I'm Aman Mehra and I'm a full-stack developer and have 5+ years of experience. I love coding and help to people with this blog.

Leave a Reply

Your email address will not be published. Required fields are marked *