Skip to content

Early-bird lifetime licence: $199 once, for the first 200 buyers only. See the offer

Change the "Add to cart" button text

Change the WooCommerce "Add to cart" button text on product pages and shop listings, without touching other button types.

  • Type PHP
  • Runs Everywhere
PHP
// Button text on single product pages (not external/affiliate products).
add_filter(
	'woocommerce_product_single_add_to_cart_text',
	function ( $text, $product ) {
		return $product->is_type( 'external' ) ? $text : 'Add to basket';
	},
	10,
	2
);

// Button text in shop and category listings, for simple products that can be bought.
// Variable, grouped and out-of-stock products keep "Select options", "View products" or "Read more".
add_filter(
	'woocommerce_product_add_to_cart_text',
	function ( $text, $product ) {
		if ( $product->is_type( 'simple' ) && $product->is_purchasable() && $product->is_in_stock() ) {
			return 'Add to basket';
		}
		return $text;
	},
	10,
	2
);

What it does

WooCommerce labels its buttons "Add to cart". You might prefer "Add to basket", "Buy now" or wording that suits your shop.

This snippet changes the button on single product pages, and in shop and category listings for simple products that are in stock. Variable, grouped, external and out-of-stock products keep their usual labels, such as "Select options" and "Read more".

Good to know

  • Change Add to basket in both places.
  • It also works in block themes, because the Product button block uses the same filters.

Move your snippets over this afternoon.

Importing changes nothing until you switch over, and your old shortcodes keep working.