• Resolved arskadirr

    (@arskadirr)


    Hi,

    I’ve been trying to change the ‘add to cart’ text of the button for variable products on the products catalog.

    I’ve tried this code
    ‘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 __( ‘Wybierz opcje’, ‘hello-elementor’ ); }’ but this changes for all the languages. I don’t want that. After that I removed the code and tried Loco Translate. I was able to make the change for single products with Loco Translate but I cannot do that for variable products. I have checked every theme and plugin with loco. I cannot find the string for the button.

    Can you please help here dronuj.com/shop

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi @arskadirr

    Thanks for reaching out!

    I understand that you want to change the text string Add to Cart for variable products on the Shop page, is that correct?

    I checked your shop page and found that the text for variable products states: Add to Cart.

    Image Link: https://snipboard.io/FYWijz.jpg

    Under Loco Translate, select WooCommerce and the language file you would like to edit and search the text string: Add to Cart. On my test site, the string is Select Options.

    Image Link: https://snipboard.io/30zhVu.jpg

    Here’s the output on the shop page:

    Image Link: https://snipboard.io/573VQI.jpg

    Let us know how it goes!

    Thread Starter arskadirr

    (@arskadirr)

    Hello @xue28

    Thank you for reply.

    With Loco translate I am able change only single product button text. Select options is also translated in Loco, but seems like something is over writing the button. Like I said I can only change the text using

    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 __( ‘Select options’, ‘hello-elementor’ ); }

    but this changes for the second language too which I don’t want that.

    I tried to disable the plugins to see if any interfere but I wasn’t successful with that. The issue continues.

    • This reply was modified 2 years ago by arskadirr.
    • This reply was modified 2 years ago by arskadirr.
    Saif

    (@babylon1999)

    Hello @arskadirr,

    So if I understand you correctly, you want to change the “Add to cart” text on the Shop page to something else.

    You can add the following code to your site:

    /* Change Add to Cart text on shop page */
    function custom_cart_button_Shop_Page( $text, $product ) {
        if( $product->is_type( 'variable' ) ){
            $text = __('Mytext', 'woocommerce');
        }
        return $text;
    }
    add_filter( 'woocommerce_product_add_to_cart_text', 'custom_cart_button_Shop_Page', 9, 2 );

    I’ve texted it on my site and it works as you can see below.


    Link to image: https://i.imgur.com/08Zslo7.png

    Hope it helps!

    Saif

    (@babylon1999)

    Just a quick follow-up, I just realised that your concern is with text overriding the translation in another language. In that case, you’ll need to stick to what Xue28 recommended by changing the text in LocoTranslate.

    I’ve tested it on my site and as you can see below the English modification doesn’t override the ones in Arabic.


    Link to image: https://i.imgur.com/CAmncDi.png


    Link to image: https://i.imgur.com/ifJHNtp.png

    If something is overriding the text in the other language then you probably left a snippet like the one above in your function.php file.

    Hope this helps!

    Thread Starter arskadirr

    (@arskadirr)

    Hello,

    Thank you for your responses. Loco translate didn’t help but finally I fixed it. It was the one of the elementor customization plugins, I deactivated it.

    Hi @arskadirr

    I’m glad you were able to find a solution to your inquiry here and thanks for sharing it with the community too! ??

    Meanwhile, if you have a few minutes, we’d love it if you could leave us a review:

    https://www.ads-software.com/support/plugin/woocommerce/reviews/

    Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to change add to cart button text for variable products’ is closed to new replies.