• Hello,

    I need assistance in changing the gift card button text on the shop page and product category page. The current button text displayed on the aforementioned pages is “Read more”. Screenshot – https://snipboard.io/n7CbO6.jpg

    I currently use the code below which I found on this forum:

    function yith_ywgc_add_to_cart_button_text( $text, $product) {
    if ($product->get_type() == ‘gift-card’) {
    $text = __( ‘Scegli’, ‘yith-woocommerce-gift-cards’ );
    }
    return $text;
    }
    add_filter( ‘woocommerce_product_single_add_to_cart_text’, ‘yith_ywgc_add_to_cart_button_text’, 10, 2 );

    It works as should, though it only changes the gift card button text on the single product pages. But I need the gift card button text on the main shop page and category pages changed as well.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author YITHEMES

    (@yithemes)

    Hello there,

    hope you are doing well ??

    In order to change the button text on the gift card products in shop/category pages, you have to add the following code to the functions.php file of your active theme and set the text you want to show in the button:

    if ( ! function_exists( 'yith_ywgc_select_amount_text' ) ) {
    	function yith_ywgc_select_amount_text( $text ) {
    		$text = 'YOUR TEXT HERE';
    
    		return $text;
    	}
    
    	add_filter( 'yith_ywgc_select_amount_text', 'yith_ywgc_select_amount_text' );
    }

    Let us know any news, please.

    Have a nice day!

    Thread Starter joshgreg

    (@joshgreg)

    Hello,

    Thank you for getting back to me.

    Unfortunately, the code you provided didn’t work for me. Here is a screenshot – https://snipboard.io/JwVd4g.jpg

    The button shown in the screenshot is on my shop page.

    I use the Astra Theme in case that might narrow down things.

    Plugin Author YITHEMES

    (@yithemes)

    Hi there,

    The previous code only works in the catalog pages, sorry. To change also the button text in the product pages, you have to add the next one:

    if ( ! function_exists( 'ywgc_add_to_cart_button_text_custom' ) ) {
    	function ywgc_add_to_cart_button_text_custom( $text ) {
    		$text = 'YOUR TEXT HERE';
    
    		return $text;
    	}
    
    	add_filter( 'ywgc_add_to_cart_button_text', 'ywgc_add_to_cart_button_text_custom' );
    }

    Could you check it and let us know, please?

    Have a nice day!

    Thread Starter joshgreg

    (@joshgreg)

    Hello,

    Thank you for getting back to me. I tried adding the code but got a syntax error. Here is the screenshot – https://snipboard.io/Wok910.jpg

    Plugin Author YITHEMES

    (@yithemes)

    Hi there,

    We have tested the code and seem to be working fine, could you try to copy the code directly in the functions.php of your theme, please?

    Let us know any news.

    Best regards!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Change the button text on the Gift Cards products’ is closed to new replies.