# Change the Add to Cart Button Text

> Replaces "Add to cart" with "Buy now" on single product pages and on shop listings for simple, in-stock products.

- Type: PHP
- Runs: Run everywhere
- Category: [WooCommerce](https://wpide.com/library/category/woocommerce/)
- Requires: WooCommerce
- Tags: woocommerce, add-to-cart, buttons
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/woo-add-to-cart-button-text/

## Code

```php
add_filter( 'woocommerce_product_single_add_to_cart_text', function () {
    return 'Buy now';
} );

add_filter( 'woocommerce_product_add_to_cart_text', function ( $text, $product = null ) {
    if ( $product && $product->is_type( 'simple' ) && $product->is_purchasable() && $product->is_in_stock() ) {
        return 'Buy now';
    }

    return $text;
}, 10, 2 );
```

## Notes

Edit both "Buy now" strings.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Change the Add to Cart Button Text" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
