Skip to content

Instantly share code, notes, and snippets.

@VivekSaha
Last active May 17, 2019 11:20
Show Gist options
  • Save VivekSaha/9362f8a81a86a7ddc51b626bb7bdd2e8 to your computer and use it in GitHub Desktop.
Save VivekSaha/9362f8a81a86a7ddc51b626bb7bdd2e8 to your computer and use it in GitHub Desktop.
change-add-to-cart-text
// 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 __( 'Add Me', 'woocommerce' );
break;
case 'variable':
return __( 'Select Me', 'woocommerce' );
break;
default:
return __( 'Read more', 'woocommerce' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment