RhysWolves
RhysWolves

Reputation: 39

How to change Add to basket text on the storefront theme

I cannot seem to replace the text inside the Add to basket buttons on the single product pages, im using a child theme with the storefront theme for WooCommerce.

Here's what i've tried:

add_filter('woocommerce_product_single_add_to_cart_text', 'woocommerce_custom_add_to_cart_text');

function woocommerce_custom_add_to_cart_text() {
   return __('Add to cart', 'woocommerce');
} 

How the button appears on the DOM:

<button type="submit" name="add-to-cart" value="117" class="single_add_to_cart_button button alt">Add to basket</button>

Upvotes: 0

Views: 258

Answers (1)

SLubbinge13
SLubbinge13

Reputation: 26

I do think the issue is theme-related as your code does work when I try it on a test site, though I don't have Storefront set as the theme.

You could try a string replace:

add_filter( 'gettext', 'change_woocommerce_strings', 999, 3 );

function change_woocommerce_strings( $changed, $text, $domain ) {
$changed = str_ireplace( 'Add to basket', 'Add to cart', $changed );

return $changed;
}

Upvotes: 0

Related Questions