How to Change WooCommerce Variable Products “Select Options” to “Add to cart” 

 December 29, 2020

By  NickLitten

WooCommerce Variable Products

Working on the Snug CBD website this morning, I found that the when you add a SIMPLE PRODUCT to WooCommerce it shows the BUY NOW text as ADD TO CART by default. But when you use a WooCommerce VARIABLE PRODUCT the default text says SELECT OPTIONS

WooCommerce Variable Products

This looks ugly, but I need to use variable products to handle various packaging sizes, flavours, strengths etc.

I want these variable product types to say ADD TO CART the same as the simple products and product bundles — How can I do this?

We have two ways of doing this:

  1. The Hard Way – writing some PHP script to over-ride the text defaults ourselves and
  2. The Easy Way – installing a plugin to change the text for us automatically

The Hard Way – Manually Add PHP

Let’s add a little PHP code to over-ride the value of the text in the button to change SELECT OPTIONS to ADD TO CART for VARIABLE PRODUCTS

Changing it as “Add to Cart” is done using a PHP code snippet that you can (a) add to your function.php in your child theme or (b) use a code snippet plugin like My Custom Functions to add the PHP script – this is my preferred technique

snug cbd discount coupon 15% off

20% Off with Coupon: NICKLITTEN

I highly recommend the SNUG CBD Tincture to help keep you in the zone when programming!

In Partnership with SNUG CBD - American readers get 20% off

The code looks like this:

add_filter('woocommerce_product_add_to_cart_text', function ($text) {
     global $product;
     if ($product instanceof WC_Product && $product->is_type('variable')) {
         $text = $product->is_purchasable() ? ('Add to cart', 'woocommerce')             : ('Read more', 'woocommerce');
     return $text;
 }, 10);

Activate this code snippet and *boom*

WooCommerce Variable Products

The Easy Way – WordPress Plugin WooCommerce Customizer

WooCommerce Customizer is a neat little plugin that adds extra customization options to WooCommerce. You never would have guessed that from it name right??

Step 1 – Download WooCommerce Customizer

Either download it manually and upload or select it from the ADD PLUGINS screen in WordPress

Step 2 – Install Plugin

How to Change WooCommerce Variable Products “Select Options” to "Add to cart" 1

Step 3 – Add new button text for buttons in Plugin Settings

How to Change WooCommerce Variable Products “Select Options” to "Add to cart" 2

Step 4 – Sit back and sip your cup of tea while admiring your new website

It’s really as simple as that:

How to Change WooCommerce Variable Products “Select Options” to "Add to cart" 3

So which technique is best?

Watch me Add this PHP code snippet to WordPress in Realtime and then install the Customizer plugin to do the same thing:

FINAL Recommendation

Install WooCommerce Customizer and let it do the heavy lifting for you.


IBM i Software Developer, Digital Dad, AS400 Anarchist, RPG Modernizer, Shameless Trekkie, Belligerent Nerd, Englishman Abroad and Passionate Eater of Cheese and Biscuits. Nick Litten Dot Com is a mixture of blog posts that can be sometimes serious, frequently playful and probably down-right pointless all in the space of a day. Enjoy your stay, feel free to comment and remember: If at first you don't succeed then skydiving probably isn't a hobby you should look into.

Nick Litten

related posts:

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Get In Touch

I’m always looking for awesome input, feedback and critique!