WordPress.org

Forums

WooCommerce - excelling eCommerce
[resolved] Add to Cart Custom Text Reverts to Default (6 posts)

  1. lussovita
    Member
    Posted 1 year ago #

    Upon upgrading to WC 2.1, my "Add to Cart" buttons (which I had renamed to read "Buy") reverted back to the default "Add to Cart" text. I am using the following code (which I believe is updated for 2.1:

    add_filter( 'woocommerce_product_single_add_to_cart_text', 'woo_custom_cart_button_text' );    // 2.1 +
    
    function woo_custom_cart_button_text() {
    
            return __( 'Buy', 'woocommerce' );
    
    }
    
    add_filter( 'woocommerce_product_single_add_to_cart_text', 'woo_custom_cart_button_text_single' );
    function woo_custom_cart_button_text_single() {
    
                        return __('Buy', 'woocommerce');
    
    }

    I'm sure I've missed something simple, I just don't know what it is. Thanks!

    https://wordpress.org/plugins/woocommerce/

  2. lussovita
    Member
    Posted 1 year ago #

    Ignore the duplicate code entries above, by the way. The first add_filter + function entry is the one I am using.

  3. lussovita
    Member
    Posted 1 year ago #

    And nevermind - I forgot to use the 2.1 compatible version of the product archive code in addition to the product code above:

    add_filter( 'woocommerce_product_single_add_to_cart_text', 'woo_custom_cart_button_text_archive' );    // 2.1 +
    
    function woo_custom_cart_button_text_archive() {
    
            return __( 'Buy', 'woocommerce' );
    
    }
  4. lussovita
    Member
    Posted 1 year ago #

    Or rather:

    add_filter( 'woocommerce_product_add_to_cart_text', 'woo_custom_cart_button_text' );    // 2.1 +
    
    function woo_custom_cart_button_text() {
    
            return __( 'Buy', 'woocommerce' );
    
    }
  5. rosso711
    Member
    Posted 1 year ago #

    thanks for the latest two codes they work perfectly.

    I am trying to change the following texts also:

    Select options, Show details, Read More.

    And also the "Add to cart" button for variable products.

    Do you have any suggestions for how do this with similar codes?

    thanks in advance.

  6. rosso711
    Member
    Posted 1 year ago #

    Forget the "Add to cart" button for variable products, i found it.

    the following texts are all i need:

    Select options, Show details, Read More.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce - excelling eCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic