• Resolved hebhansen

    (@hebhansen)


    I am trying to change add to cart text in woo. Now I have tried 3 different snippets to no avail. How is this done once and for all?

    // Change add to cart text on single product page
    add_filter( 'woocommerce_product_single_add_to_cart_text', 'woocommerce_add_to_cart_button_text_single' ); 
    function woocommerce_add_to_cart_button_text_single() {
        return __( 'Collect', 'woocommerce' ); 
    }
    
    // Change add to cart text on product archives page
    add_filter( 'woocommerce_product_add_to_cart_text', 'woocommerce_add_to_cart_button_text_archives' );  
    function woocommerce_add_to_cart_button_text_archives() {
        return __( 'Collect', 'woocommerce' );
    }
    
    // To change add to cart text on single product page
    add_filter( 'woocommerce_product_single_add_to_cart_text', 'woocommerce_custom_single_add_to_cart_text' ); 
    function woocommerce_custom_single_add_to_cart_text() {
        return __( 'Buy Now', 'woocommerce' ); 
    }
    
    // To change add to cart text on product archives(Collection) page
    add_filter( 'woocommerce_product_add_to_cart_text', 'woocommerce_custom_product_add_to_cart_text' );  
    function woocommerce_custom_product_add_to_cart_text() {
        return __( 'Buy Now', 'woocommerce' );
    }
    
    // Change "Add to Cart" > "Add to Bag" in Shop Page
    add_filter( 'woocommerce_product_add_to_cart_text', 'woocommerce_shop_page_add_to_cart_callback' );  
    function woocommerce_shop_page_add_to_cart_callback() {
        return __( 'Add to Bag', 'text-domain' );
    }
    
    // Change "Add to Cart" > "Add to Bag" in Single Page
    add_filter( 'woocommerce_product_single_add_to_cart_text', 'woocommerce_single_page_add_to_cart_callback' ); 
    function woocommerce_single_page_add_to_cart_callback() {
        return __( 'Add to Bag', 'text-domain' ); 
    }

    None of these have any effect.

    Theme is TT4

    Thx

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Beauty of Code (woo-hc)

    (@beautyofcode)

    Hey there ??

    Thanks for reaching out!

    Although help with custom code is outside our scope of support, the snippet provided in the developer-level support doc below, shares the snippet needed to change the “Add to cart” text:

    I’ve tested this on my end and it seems to be working as expected when using both the Storefront theme and the Twenty Twenty-Four theme:

    If this is not working as expected on your end, it’s possible that other custom code or another plugin may be conflicting with this.

    To check, you can temporarily deactivate all plugins, except for WooCommerce, and remove any other custom snippets, and see if this resolves the issue.

    Rather than testing on a live site, you can create a a staging environment where you can test changes without affecting your live site. This can be done using the free?WP Staging?plugin.

    Cheers!

    Thread Starter hebhansen

    (@hebhansen)

    Code is not working here…. Tried and tested over and over…..

    Thread Starter hebhansen

    (@hebhansen)

    After turning on and off and on and purge cache etc. the code finally works.

    Thank you Roxy. It’s appreciated

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Change “Add to Cart” text’ is closed to new replies.