Select Page

If you are a WooCommerce user, you may have come across an issue where on both archive (shop) pages and single product pages, the ‘add to cart’ button says, ‘read more’. Or, more importantly, you may not want to have the button say, ‘add to cart’ at all. This lovely little function can be added to your functions.php file to not just deal with the issue, but allow you to customise the button based on your product type.

add_filter( 'woocommerce_product_add_to_cart_text' , 'bouncing_add_to_cart_text' );
function bouncing_add_to_cart_text() {
  global $product;
  $product_type = $product->product_type;
  switch ( $product_type ) {
    case 'simple':
    return __( 'Select', 'woocommerce' ); /*change 'Options' for Simple products */
    case 'subscription':
    return __( 'Subscribe', 'woocommerce' ); /*change 'Options' for Simple Subscriptions */
    case 'variable-subscription':
    return __( 'Subscribe', 'woocommerce' ); /*change 'Options' for Variable Subscriptions */
    case 'variable':
    return __( 'select', 'woocommerce' ); /*change 'Options' for Variable Products */
    case 'booking':
    return __( 'Book now', 'woocommerce' ); /*change 'Options' for Bookable Products */

However, I came across a complication today. If you install WooCommerce Deposits, it overwrites all of these, changing the button text to ‘select options’. On inspection, it appears that WooCommerce Deposits uses it own filter for displaying text. Therefore, to make the code above also work with Deposits installed, you need to hook into that filter too:

add_filter( 'woocommerce_deposits_add_to_cart_text', 'bouncing_add_to_cart_text' );

I hope you no longer have to tear your hair out to the same extent as I have. Not that I had much to start with.