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.
// 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 basketin both places. - It also works in block themes, because the Product button block uses the same filters.