on-internet
← Community

How to make returned text translatable in WooCommerce product add to cart filter

Stack Overflow ·

I have the following code where I need to make the 'Pas de Stock' string translatable. I tried changing the line to the following, but it throws a syntax error: return <?php _e('Pas de Stock','veho'); ?> Is there a standard way to return translatable text in this filter? add_filter( 'woocommerce_product_add_to_cart_text', 'bbloomer_archive_custom_cart_button_text' ); function bbloomer_archive_custom_cart_button_text( $text ) { global $product; if ( $product && ! $product->is_in_stock() ) { return 'Pas de Stock'; } return $text; }

Comments

Sign in or sign up to comment and upvote.

No comments yet.