Skip to content

Instantly share code, notes, and snippets.

@zstepek
Last active August 29, 2015 14:19
Show Gist options
  • Save zstepek/4ab24037837b7ef2e29b to your computer and use it in GitHub Desktop.
Save zstepek/4ab24037837b7ef2e29b to your computer and use it in GitHub Desktop.
Change the text for the product buttons (Add To Cart, etc) on product archives and individual pages
<?php
function mindsize_wc_product_button_text() {
global $product;
$product_type = $product->product_type;
switch ( $product_type ) {
case 'external':
return __( 'EXTERNAL PRODUCT TEXT', 'woocommerce' );
break;
case 'grouped':
return __( 'GROUPED PRODUCT TEXT', 'woocommerce' );
break;
case 'simple':
return __( 'SIMPLE PRODUCT TEXT', 'woocommerce' );
break;
case 'variable':
return __( 'VARIABLE PRODUCT TEXT', 'woocommerce' );
break;
// support subscriptions
case 'subscription':
return __( 'SIMPLE SUBSCRIPTION TEXT', 'woocommerce' );
break;
case 'variable-subscription':
return __( 'VARIABLE SUBSCRIPTION TEXT', 'woocommerce' );
break;
default:
return __( 'DEFAULT TEXT', 'woocommerce' );
}
}
add_filter( 'woocommerce_product_add_to_cart_text' , 'mindsize_wc_product_button_text' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment