Skip to content

Instantly share code, notes, and snippets.

@swoboda
Created December 16, 2016 09:22
Show Gist options
  • Save swoboda/8ba50f42598731bd9167aca332f3d6e7 to your computer and use it in GitHub Desktop.
Save swoboda/8ba50f42598731bd9167aca332f3d6e7 to your computer and use it in GitHub Desktop.
product-add-to-cart-text
<?php
add_filter( 'woocommerce_product_add_to_cart_text' , 'wpdesk_product_add_to_cart_text' );
/**
* Change add to cart text for product types
*
*/
function wpdesk_product_add_to_cart_text() {
global $product;
$product_type = $product->product_type;
switch ( $product_type ) {
case 'external':
return __( 'Buy product', 'woocommerce' );
break;
case 'grouped':
return __( 'View products', 'woocommerce' );
break;
case 'simple':
return __( 'Add to cart', 'woocommerce' );
break;
case 'variable':
return __( 'Select options', '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