How to Set WooCommerce Buy Now Button For Variable Product

WooCommerce Buy Now Button For Variable ProductDo you want to change the ‘Select options’ button for variable products in your WooCommerce store? Then read on, as this post aims to provide a custom-made solution to customize this button.

By default, all variable products in WooCommerce are displayed with the select options button. When customers click on this button, they are directed to the single product page to select the variable product they were looking for. Customers press this button to show they are interested in buying a product.

This means that optimizing it can have a great impact on your store. This is because it will improve the purchase process by making it more user-friendly and simple.

It is important to note that there are many ways to customize the select options button. You can use a plugin, but they end up bloating your site leading to increased loading time. This is why we decided to create this brief tutorial.

WooCommerce Buy Now Button For Variable Product

By the end of today’s buying guide, you will be able to change the select options button text. We will share a custom code snippet to modify WooCommerce’s core files to achieve the desired result.

Before you proceed, you should install or create a child theme. This will ensure that your changes are not lost during an update.

With that in mind, let us get right into it.

Steps to Add Buy Now Button For Variable Product

Here are the simple steps you need to follow:

  1. Log into your WordPress site and access the Dashboard as the admin user.
  2. From the Dashboard menu, click on Appearance Menu > Theme Editor Menu. When the Theme Editor page is opened, look for the theme functions file to add the function to change the select options button for variable products in WooCommerce.
  3. Add the following code to the php file:
add_filter( 'woocommerce_product_single_add_to_cart_text', 'njengah_custom_cart_button_text', 10, 2 );
add_filter( 'woocommerce_product_add_to_cart_text', 'njengah_custom_cart_button_text', 10, 2 );
function njengah_custom_cart_button_text( $button_text, $product ) {
    if ( $product->is_type( 'variable' ) )
        $button_text = __('Buy Now', 'woocommerce');
    return $button_text;

  1. This is the outcome:buy now

Wrapping Up

In summary, we have shared a custom PHP code snippet to add a buy now button for all variable products in your WooCommerce store. This is the recommended way of making customization on your store

If you need additional functionality, feel free to contact us. Alternatively, you can use a plugin to get your desired result.

Remember to install or create a child theme and backup your entire site. This will help you revert to the previous version if you make any mistakes.

We hope that this post provided a solution to your problem.

Customer Reviews


Customer Reviews

Jeffrey Todd 04/07/2020

Exceptional Plugin & Service

I'm in the process of building my new website, and I had a question about changing some text within the WooCommerce plugin. I was spinning my wheels trying to figure it out. Joe reached back and worked with me - going above and beyond! - until I fully understood how to effectively change what I wanted. How can you ask for more than that? I highly recommend WooCommerce (and Joe!), the plugin and service are exceptional!
-Jeffrey Todd (