[Resolved] Change the text of 'View cart' button (Mini cart)

Home Forums Support Change the text of 'View cart' button (Mini cart)

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #982913
    Andrea

    Hi guys,
    I’m looking for change the “Visualizza carrello” text for the “View Cart” italian translation, into the mini cart.

    I’m developing locally, with GPPremium and the Merch template. All plugins, WordPress and themes are updated to the latest version and I don’t use cache plugins.

    1 I tried with Loco translate, and it doesn’t work.
    ____

    2 I tried with:

    add_filter( 'gettext', function( $translated_text ) {
        if ( 'View your shopping cart' === $translated_text ) {
            $translated_text = 'Your new text here';
        }
    
        return $translated_text;
    } );

    As written in this topic: https://generatepress.com/forums/topic/change-to-spanish-or-erase-titleview-your-shopping-cart/#post-912300
    but it still does not work.
    ____

    3 So I tried similar solutions described on stackoverflow, like this:

    function translate_text ($ translated) {
    $ translated = str_ireplace ('Kasse', 'Weiter zur Kasse', $ translated);
    return $ translated;
    }
    add_filter ('gettext', 'translate_text', 999);
    add_filter ('ngettext', 'translate_text', 999);

    But it doesn’t seem to work.
    ____

    4 I started combing the GP premium core and noticed that in:
    gp-premium / woocommerce / functions / functions.php
    on line 505 the WC_Widget_Cart class is called.

    I found this discussion about this: https://wpml.org/forums/topic/wpml-the_widgetwc_widget_cart/

    I don’t use wpml, so compatibility is not absolutely necessary.
    I would just like to find a way to modify the string and I hope this can help you understand it better.

    Thank you so much for your time.

    Sorry for my English.

    Andrea

    #983205
    David
    Staff
    Customer Support

    Hi there,

    the second option you tried ie this:

    https://generatepress.com/forums/topic/change-to-spanish-or-erase-titleview-your-shopping-cart/#post-912300

    Try changing this part of the code:

    if ( 'View your shopping cart'

    to:

    if ( 'View cart'

    #983436
    Andrea

    Hi David,
    thank you for your reply.
    It still does not work.
    I’m trying other ways. If I can solve it, I’ll write it below.

    #983461
    David
    Staff
    Customer Support

    Can you make sure that the string of text you’re looking to replace is exactly the same as what you see on the Button?

    So my button says ‘View cart’ – if you’re in a different language then make sure it says exactly what you see, making sure any capital letts or other characters are included.

    #985540
    Andrea

    Hi David,

    all the options described work correctly.
    I had no idea that the mini-cart is being cached somewhere.
    https://github.com/woocommerce/woocommerce/issues/15375

    Many thanks for support!

    Andrea

    #985593
    David
    Staff
    Customer Support

    Awesome – glad to be of help.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.