• Hi, So far I changed the add to cart button text if a product is tagged with ‘preorder’ which is working fine by adding following code to my child theme’s functions.php

    I want to do the same thing with the add to cart button on the yith wishlist page, any suggestions?

    //For single product page
    add_filter( ‘woocommerce_product_single_add_to_cart_text’, ‘woo_custom_cart_button_text’ ); // 2.1 +
    function woo_custom_cart_button_text() {
    global $product;
    if ( has_term( ‘Preorder’, ‘product_tag’, $product->ID ) ) :
    return __( ‘Pre order Now !’, ‘woocommerce’ );
    else:
    return __( ‘In Winkelmand’, ‘woocommerce’ );
    endif;
    }

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

    (@yithemes)

    Hi fixdawel

    You can try to hook you function to this filter yith_wcwl_add_to_cart_label
    This should do the trick ??

    Please, let me know if this works as expected
    Have a nice day

    Thread Starter fixdawel

    (@fixdawel)

    Hi

    Thanks! It works for changing the add to cart label in general but it doens’t work for product with below specified tag ‘preorder’

    add_filter( 'yith_wcwl_add_to_cart_label', 'woo_custom_wishlist_button_text' ); // 2.1 +
        function woo_custom_wishlist_button_text() {
            global $product;
            if ( has_term( 'Preorder', 'product_tag', $product->ID ) ) :
                return __( 'Pre order Now !', 'woocommerce' );
    	else:
                return __( 'Test In Winkelmand', 'woocommerce' );
            endif;
        }
    Plugin Author YITHEMES

    (@yithemes)

    Hi again fixdawel

    If I correctly understand your request, this branch of code executes for preorder tagged products

    
     return __( 'Pre order Now !', 'woocommerce' );
    

    Anyway, you can’t see any change in “Add to Cart” label for that products

    In this case, maybe someone else is filtering “Add to Cart” label for preorder tagged products, with a priority higher then 10

    Could you please try to increase priority in add_filter, and see if something changes?

    
    add_filter( 'yith_wcwl_add_to_cart_label', 'woo_custom_wishlist_button_text', 20 ); 
    

    Please, let me know
    Have a nice day

    Thread Starter fixdawel

    (@fixdawel)

    Hi,

    Thanks but no, unfortunately it doesn’t work.
    FYI: I also did a test based on category but doesn’t work either.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Change YITH add to cart button text on wishlist page’ is closed to new replies.