Created
October 30, 2023 05:21
-
-
Save SirDarcanos/5137f7d6fd9dc19adeba4cdbdeb32b93 to your computer and use it in GitHub Desktop.
Change the Add to Cart text in WooCommerce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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