woocommerce_product_single_add_to_cart_text
Filters the Add to cart button text on single product pages. Return your own label, per product if you like.
When it fires
WooCommerce applies this filter in the product's single_add_to_cart_text() method, which the single product templates use for the button label. The default is 'Add to cart'; external products use the button text you entered, or 'Buy product'.
The Add to Cart + Options block and the Store API use the same method, so the filter works with block themes too.
Parameters
$textstring |
The button text. Default 'Add to cart'. |
|---|---|
$productWC_Product |
The product object. |
What to return
The button text as a plain string. WooCommerce escapes it when printing.
Example: Say Pre-order now for products on backorder
add_filter( 'woocommerce_product_single_add_to_cart_text', function ( $text, $product ) {
if ( $product->is_type( 'simple' ) && $product->is_on_backorder() ) {
return __( 'Pre-order now', 'my-snippets' );
}
return $text;
}, 10, 2 );
Good to know
- This only changes single product pages. Buttons on shop and category pages use woocommerce_product_add_to_cart_text.
- For variable products the object passed in is the parent product, so the text is the same for every variation.