CoopDaddio
CoopDaddio

Reputation: 637

How to change the 'select options' text on button hover on the shop page for woocommerce?

I would like to change the text on the button that appears when hovering over an item on the shop page for my Wordpress/Woocommerce site. I have searched through many posts but cannot find a solution. I am using the ShopIsle theme. How can I change this select options text to 'view product'? enter image description here

Upvotes: 0

Views: 2012

Answers (3)

Brian
Brian

Reputation: 1

I modified the above to check stock status and bring it to the add to cart text. See below:

add_filter( 'woocommerce_product_add_to_cart_text', 'woo_archive_custom_cart_button_text' );

function woo_archive_custom_cart_button_text() {

global $product;

$product_sstatus = $product->get_stock_status();

switch ( $product_sstatus ) {
case 'instock':
    return __( 'Add to Cart', 'woocommerce' );
break;
case 'outofstock':
    return __( 'Sold Out', 'woocommerce' );
break;
case 'onbackorder':
    return __( 'On Backorder', 'woocommerce' );
break;
default:
    return __( 'More Info', 'woocommerce' );

}}

Upvotes: 0

Vidish Purohit
Vidish Purohit

Reputation: 1078

If you are using 2.1+ then this should work for you

add_filter( 'woocommerce_product_add_to_cart_text', 'woo_archive_custom_cart_button_text' );    // 2.1 +

function woo_archive_custom_cart_button_text() {

    return __( 'My Button Text', 'woocommerce' );

}

For woocommerce < 2.1

add_filter( 'add_to_cart_text', 'woo_archive_custom_cart_button_text' );    // < 2.1

function woo_archive_custom_cart_button_text() {

    return __( 'My Button Text', 'woocommerce' );

}

Upvotes: 1

cnrhgn
cnrhgn

Reputation: 703

Add this to the child theme functions.php file and you can change the text on any of the buttons.

add_filter( 'woocommerce_product_add_to_cart_text' , 'custom_woocommerce_product_add_to_cart_text' );
/**
 * custom_woocommerce_template_loop_add_to_cart
*/
function custom_woocommerce_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' );
}

Upvotes: 0

Related Questions