Skip to content

Instantly share code, notes, and snippets.

@ejntaylor
Created December 2, 2017 12:15
Show Gist options
  • Save ejntaylor/c7d315cc996976994b0d4d19febd9fe9 to your computer and use it in GitHub Desktop.
Save ejntaylor/c7d315cc996976994b0d4d19febd9fe9 to your computer and use it in GitHub Desktop.
Rename cart to bag
<?php
function woo_custom_change_cart_string($translated_text, $text, $domain) {
$translated_text = str_replace("cart", "bag", $translated_text);
$translated_text = str_replace("Cart", "Bag", $translated_text);
$translated_text = str_replace("View Cart", "View Bag", $translated_text);
return $translated_text;
}
add_filter('gettext', 'woo_custom_change_cart_string', 100, 3);
add_filter('ngettext', 'woo_custom_change_cart_string', 100, 3);
add_filter( 'woocommerce_product_add_to_cart_text', 'woo_custom_single_add_to_cart_text' ); // < 2.1
add_filter( 'woocommerce_product_single_add_to_cart_text', 'woo_custom_single_add_to_cart_text' ); // 2.1 +
function woo_custom_single_add_to_cart_text() {
return __( 'Add to Bag', 'woocommerce' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment