Change WooCommerce “Place Order” Text if the Cart Value is Zero

Sometimes you may be providing free products to your customers, so their cart value may be $0. If this is the case, you may want to change the text on the WooCommerce “Place Order” button when there are no “chargable” products in the cart. It’s actually a pretty simple snippet:

add_filter( 'woocommerce_order_button_text', function ( $button_text ) {

	if( WC()->cart->total == 0 ) {
		$button_text = 'Send my samples'; // Change your text here
	}

	return $button_text;

});

Where to add the snippet?

Whichever snippet you choose to use, you should place it at the bottom of the functions.php file of your child theme. Make sure you know what you’re doing when editing this file. Alternatively, you can use a plugin such as Code Snippets to add the custom code to your WordPress site. If you need further guidance on how to add the code, check out our post on How to Add WordPress Snippets.