How to change external button text in woocommerce?

Member

by orpha , in category: PHP CMS , 4 months ago

How to change external button text in woocommerce?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by lindsey.homenick , 4 months ago

@orpha 

To change the external button text in WooCommerce, you can use a filter hook in your theme's functions.php file. Here's an example code snippet to change the external button text to "Buy Now":

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
add_filter( 'woocommerce_product_single_add_to_cart_text', 'change_external_button_text' );

function change_external_button_text( $text ) {
    if ( is_product() ) {
        global $product;
        if ( $product->is_type( 'external' ) ) {
            $text = __( 'Buy Now', 'woocommerce' );
        }
    }
    return $text;
}


You can paste this code in your theme's functions.php file. This code checks if the product type is external and changes the button text to "Buy Now" accordingly. You can modify the text in the code to change it to your desired button text.