MakeMeHappy.sk
SK EN
All snippets

Change the button text for simple products

To give the button on a simple product page a more specific label, use this filter. Add it through a PHP snippet manager or to the functions.php file of your child theme on a test store.

add_filter( 'woocommerce_product_single_add_to_cart_text', function ( $label, $product ) {
    if ( $product->is_type( 'simple' ) && $product->is_purchasable() ) {
        return 'Add this item to my basket';
    }

    return $label;
}, 10, 2 );

Open an in-stock simple product, then a variable product. Check for the new label on the first page and the existing label on the second. The filter is used in the classic WooCommerce template. If your store uses a button block with a custom label, also check its settings in the template editor.

WooCommerce documentation on button labels