Skip to content

Instantly share code, notes, and snippets.

@SiR-DanieL
Created October 30, 2023 05:21
Show Gist options
  • Save SiR-DanieL/5137f7d6fd9dc19adeba4cdbdeb32b93 to your computer and use it in GitHub Desktop.
Save SiR-DanieL/5137f7d6fd9dc19adeba4cdbdeb32b93 to your computer and use it in GitHub Desktop.
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