Skip to content

Instantly share code, notes, and snippets.

@bradleysa
Created April 22, 2022 07:54
Show Gist options
  • Save bradleysa/055e501f3970cc04b61421cf7c5e911d to your computer and use it in GitHub Desktop.
Save bradleysa/055e501f3970cc04b61421cf7c5e911d to your computer and use it in GitHub Desktop.
WC: Change 'add to cart' text on archives depending on product type
add_filter( 'woocommerce_product_add_to_cart_text' , 'custom_woocommerce_product_add_to_cart_text' );
function custom_woocommerce_product_add_to_cart_text() {
global $product;
$product_type = $product->product_type;
switch ( $product_type ) {
case 'external':
return __( 'Take me to their site!', 'woocommerce' );
break;
case 'grouped':
return __( 'VIEW THE GOOD STUFF', 'woocommerce' );
break;
case 'simple':
return __( "Select My Size", 'woocommerce' );
break;
case 'variable':
return __( 'Select My Size', 'woocommerce' );
break;
default:
return __( "Select My Size", 'woocommerce' );
}
}
/** https://metorik.com/blog/change-the-add-to-cart-text-in-woocommerce **/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment