Skip to content

Instantly share code, notes, and snippets.

@SiR-DanieL
Created October 30, 2023 05:21
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Change the Add to Cart text in WooCommerce
<?php
// Change add to cart text on single product page
add_filter( 'woocommerce_product_single_add_to_cart_text', 'change_add_to_cart_text' );
function change_add_to_cart_text() {
return 'Add to Bag';
}
// Change add to cart text on product archives page
add_filter( 'woocommerce_product_add_to_cart_text', 'change_add_to_cart_text_archives' );
function change_add_to_cart_text_archives() {
return 'Add to Bag';
}
// Change added to cart and view cart text
add_filter( 'wc_add_to_cart_message_html', 'change_added_to_cart_view_cart_text', 10 );
function change_added_to_cart_view_cart_text( $message ) {
$message =str_replace( ' cart', ' Bag', $message );
return $message;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment