WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
update cart button (16 posts)

  1. timiswright
    Member
    Posted 1 year ago #

    Could someone please tell me if there is a filter to rename the text on the update cart button?

    I have changed the single_add_to_cart_text filter to 'Add to Basket' but now on the summary page I need to keep it consistant and change 'Update Cart' to 'Update Basket'

    Thanks

    http://wordpress.org/extend/plugins/woocommerce/

  2. jugglingtoad
    Member
    Posted 1 year ago #

    Having similar fun and games changing cart to basket to un-americanism my site - dont know if you've sorted already but I found this on woocommerce?

  3. touteptite
    Member
    Posted 1 year ago #

    Just modify the .po file (woocommerce-en_GB.po).
    Via ftp you will find it in Plugins/Woocommerce/Languages.
    Search for the expression "update cart" or "cart" and you will me able to change all the terms, sentences, expressions you want to change...

  4. vikkiranag
    Member
    Posted 1 year ago #

    Dear touteptite,

    i did the same u said buut nothing changed on the front end what exactly is the text to be replaced i have the same issue as timiswright

  5. Coen Jacobs
    Member
    Plugin Author

    Posted 1 year ago #

    For all these issues, please read our documentation on translating WooCommerce, which explains the full process of how to make your own translation, or customise an existing translation using the Codestyling Localization plugin.

  6. crdunst
    Member
    Posted 1 year ago #

    Just to add to this, rather than installing the Codestyling Localization plugin as per the documentation, many of the translations you need for cart -> basket are already built in.

    It's easy, just do the following:

    1. Ensure the language of your site is defined in your wp-config .php file. It should look like this: define ('WPLANG', 'en_GB');
    2. In your wp-content directory, create a new directory called 'languages', and within that, create a directory called 'woocommerce'
    3. Copy the 'woocommerce-en_GB.mo' file from within /plugins/woocommerce/i18n/languages into the /wp-content/languages/woocommerce directory you created

    The above should pick up most text strings such as 'add to basket' and 'x item has been added to your basket' etc etc.

    If you need to make further modifications to the text strings, then follow the advice in the link Coen provided above, using the Codestyling Localization plugin.

    As a bonus, here's a snippet to include in your functions.php if you just want to change the 'add to cart/basket' button text to something generic such as 'buy now':

    add_filter('single_add_to_cart_text', 'woo_custom_cart_button_text');
    add_filter('add_to_cart_text', 'woo_custom_cart_button_text');
    function woo_custom_cart_button_text() {
    	return __('Buy Now', 'woocommerce');
    }
  7. bheadrick
    Member
    Posted 11 months ago #

    If anyone is interested in changing the add to cart text on a per product basis, there's this: WooCommerce Benefit Buttons

  8. LimegreenOffice
    Member
    Posted 10 months ago #

    Hi Crdunst,

    I tried your method, and whilst some of the text changed from 'Cart' to 'Basket', some of it didn't either.

    Not sure what I'm doing wrong? Could it be anything to do with the Theme I'm using? (Avada....like the rest of the world, lol).

    It's not a live site yet, so I'm not in an urgent panic but would like to tick it off the list.

    The main area it's not picking up the changes is the small basket that pops up when I hover over the basket icon (it says 'view cart' & 'checkout' as the 2 options), and then everything on the 'cart/basket' page refers to cart.

    Here's a couple of screenshots to show what I mean: Screenshots

    Thanks in advance

    M.

  9. crdunst
    Member
    Posted 10 months ago #

    Hi LimegreenOffice,

    If some translations worked for you, it suggests you have implemented the woocommerce mo file correctly.

    The remaining translations however probably don't have translations in the woocommerce mo file, so you will need something like the Codestyling Localisation plugin as highlighted by Coen to add the translations in.

    The other possibility is the theme authors haven't wrapped those snippets of text in _e() functions in order to have them use the gettext system. I'd say this is unlikely though - looking at your theme on themeforest it's well used, so this would surely have been fixed before now.

    As an aside, I did notice that the Codestyling Localisation plugin doesn't handle 2 character language codes such as cy (Welsh), it only handles the 5 char format such as en_GB. I've recently therefore had to use an alternative plugin called Quick Localization on a multilingual site, and it has been working well.

    I'd try picking out the remaining translations using Codestyling Localisation first if I were you, and if those snippets aren't available to translate using it, contact the theme author and check the theme is set up correctly.

    Good luck!

  10. kylen20
    Member
    Posted 8 months ago #

    Thanks crdunst! Your suggestion worked for me! Much appreciated :)

  11. daniel22222
    Member
    Posted 8 months ago #

    In the woocommerce artificer theme the cart button at the top says My Basket and most other locations say Cart. How do I get the "My Basket" text to be My Cart? I tried the method of adding the en_GB file to wp_config/languages/woocommerce but that just changed all the places where cart was turn into basket. I then tried the codestyling plugin and deleted all the translations, but that didnt work. I also went into the actual function woocommerce_cart_link() under the artificer/includes/theme-woocommerce.php and changed the "My Basket" text to "My Cart", but the text still showed up as "My Basket". I then tried to test and the "My Basket" button came up even if I deleted everything in the function except

    a href="" class="cart-button " /a

    and the "My Basket" button still came up. When I delete the text class="cart-button " then finally the button does not show up. This is very confusing, please point me in the right direction.

  12. crdunst
    Member
    Posted 8 months ago #

    Hi daniel22222, I just had a look at the demo theme http://demo2.woothemes.com/artificer/

    Using Chrome dev tools I removed the class you mentioned - it doesn't remove the button, but the button container loses its styles, so it floats over to the left.

    I wouldn't edit the core files either, otherwise on updating the theme your changes would be overwritten. When you look at the function that generates the link though, is it wrapped in an _e() function? I presume so as that's a Woo theme, and I can't imagine that would slip through the net.

    In which case you just need to figure out what's going on with your localisation. You mentioned you added your .mo file, and that changed the references elsewhere from 'cart' to 'basket', so the mo file was obviously being picked up, and your config language definition seems to be correct.

    With the codestyling localisation plugin then, instead of using that to clear out the 'basket' references, simply overwrite them with the word 'cart'. If you clear them out they will revert to whatever is defined in the _e() function.

    So to recap - ensure your mo file is in there, then give the plugin another go but overwrite them with the word 'cart' or whatever you want it to be.

    Hope that helps.

  13. daniel22222
    Member
    Posted 8 months ago #

    I do all my editing of functions in a child theme, so I am ok with changing the functions, just gotta figure out how they work first haha. Here are the 2 functions so you dont have to download the theme:

    <?php
    // Handle cart in header fragment for ajax add to cart
    add_filter('add_to_cart_fragments', 'header_add_to_cart_fragment');
    function header_add_to_cart_fragment( $fragments ) {
    	global $woocommerce;
    	ob_start();
    	woocommerce_cart_link();
    	$fragments['a.cart-button'] = ob_get_clean();
    	return $fragments;
    }
    function woocommerce_cart_link() {
    	global $woocommerce;
    	?>
    	<a href="<?php echo $woocommerce->cart->get_cart_url(); ?>" title="<?php echo sprintf(_n('%d item', '%d items', $woocommerce->cart->cart_contents_count, 'woothemes'), $woocommerce->cart->cart_contents_count);?> <?php _e('in your shopping cart', 'woothemes'); ?>" class="cart-button ">
    	<span class="label"><?php _e('My Basket:', 'woothemes'); ?></span>
    	<?php echo $woocommerce->cart->get_cart_total();  ?>
    	<span class="items"><?php echo sprintf(_n('%d item', '%d items', $woocommerce->cart->cart_contents_count, 'woothemes'), $woocommerce->cart->cart_contents_count); ?></span>
    	</a>
    	<?php
    }
    ?>

    I didnt see a way to create another rule within the localization pluggin. On the left side there are original statements from which to translate that I cant seem to change or add any new statements so there is no basket on the left side for me to give the translation of cart.

  14. daniel22222
    Member
    Posted 8 months ago #

    Your a genius, I am still new to wordpress and woocommerce so I am learning the ridiculous amount of functions that lie within. I did not realize that _e ran the text through some sort of translation process. I took that function out and put in the straight text "My Cart" and it worked like a charm.

  15. daniel22222
    Member
    Posted 8 months ago #

    May have found an even more proper way to do it:

    function wpa_change_my_basket_text( $translated_text, $text, $domain ){
        if( $domain == 'woothemes' && $translated_text == 'My Basket:' )
            $translated_text = 'My Cart:';
    
        return $translated_text;
    }
    add_filter( 'gettext', 'wpa_change_my_basket_text', 10, 3 );
  16. Internauticos
    Member
    Posted 8 months ago #

    Grettings! I'm new here,
    Guys, i have one question, how i can put one button into the cart or dow of the product for remove the item. I try with all but doesn't work.? Somebody know about that?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic