Okay
  Public Ticket #2074865
Change the name of a button / add to cart
Closed

Comments

  • Eleazar started the conversation

    How do I change the name to the "add to cart" button?

    Thanks in advance

    Attached files:  Captura de pantalla 2019-07-09 a las 17.35.23.png

  •  1,249
    Support Agent 1 replied

    Hi Eleazar,

    Regarding the 'Add to cart' button please make sure that you translate Woocommerce first.

    In order to do so, please refer to the following article:

    https://docs.woocommerce.com/document/woocommerce-localization/

    (Please note that the Woocommerce strings can't be changed to another language if that language is not set as site language so please add the desired language as Site language).

    Let us know if you need additional assistance.


    Regards, BoldThemes team

    If you like our products please consider leaving us a rating. A huge thank you from BoldThemes in advance!

  • Eleazar replied

    I do not want to translate the language, I just want to change the name of the button

  •  1,249
    Support Agent 1 replied

    Hi Eleazar,

    We will take a closer look at this and we will get back to you tomorrow.

    Thank you for understanding!


    Regards, BoldThemes team

    If you like our products please consider leaving us a rating. A huge thank you from BoldThemes in advance!

  •  1,249
    Support Agent 1 replied

    Hi Eleazar,

    Thank you for your patience.

    In order to be able to change the text on that button, please navigate to your functions.php file in wp-content\themes\shopscape (preferably in your child theme functions.php) and please add the following code:

    add_filter( 'woocommerce_product_add_to_cart_text' , 'custom_woocommerce_product_add_to_cart_text' );
    /**
     * custom_woocommerce_template_loop_add_to_cart
    */
    function custom_woocommerce_product_add_to_cart_text() {
        global $product;
        
        $product_type = $product->product_type;
        
        switch ( $product_type ) {
            case 'external':
                return __( 'Buy product', 'woocommerce' );
            break;
            case 'grouped':
                return __( 'View products', 'woocommerce' );
            break;
            case 'simple':
                return __( 'Add to cart', 'woocommerce' );
            break;
            case 'variable':
                return __( 'test', 'woocommerce' );
            break;
            default:
                return __( 'Read more', 'woocommerce' );
        }
        
    }

    Please note that the word 'Add to cart' should be replaced with the desired text.

    The code should be added at the bottom of functions.php file, before the closing tags: 

    ?>

    9759073135.png
    3977904093.png

    Please note that these changes will affect all "Add to cart" buttons throughout your website (on shop page also).

    Let us know if you need additional assistance.



    Regards, BoldThemes team

    If you like our products please consider leaving us a rating. A huge thank you from BoldThemes in advance!

  • Eleazar replied

    Thanks for the code. Works correctly

  •  1,249
    Support Agent 1 replied

    Hi Eleazar,

    You're welcome!smile.png

    Also, if that is not too much of a hassle, please consider supporting us by giving us a rating at the downloads section of your ThemeForest profile (just below the download button) - http://themeforest.net/downloads. We would really appreciate it. :)

    Thanks a lot in advance.



    Regards, BoldThemes team

    If you like our products please consider leaving us a rating. A huge thank you from BoldThemes in advance!