Changing the WooCommerce Cart Item Count Text


If you setup a WooCommerce store on the Divi Theme, the header will display a count of the items in the user's cart. The text for this will be of the form "2 Items". If you’d like to change this text, e.g. to translate it into another language, you can use the following PHP code:

add_filter('ngettext_with_context', 'dbc_change_woocommerce_item_text', 20, 6);

function dbc_change_woocommerce_item_text($translation, $single, $plural, $number, $context, $domain ) {
    if ($domain == 'Divi') {
		if ($translation == '%1$s Item') { return '%1$s Article'; }
		if ($translation == '%1$s Items') { return '%1$s Articles'; }
    return $translation;
The code above example replaces the English text (both singular and plural forms) with the French equivalent (I hope – please correct me if I have mistranslated). The %1$s in the above is a placeholder which will be replaced with the actual number of items when Divi outputs the page.


  1. I just wanted to stop in to let you know how much I absolutely love your content. Your guides and plugins have not only saved me so much time and frustration, but have directly improved my quality of life. I use your plugins on every single one of my websites, and they are numerous. I hope you keep doing what you do. Thank you!

    • You’re very kind, Abigail. Thanks to you too :)

      I’m glad the guides and plugins have been helping. If there’s ever anything you’re trying to do that you don’t see covered anywhere, just let me know. Cheers!

  2. Thanks! But in which PHP file should I add this code?


Submit a Comment

Comments are manually moderated and approved at the time they are answered. A preview is shown while pending but may disappear if your are cookies cleared - don't worry though, the comment is still in the queue.

Your email address will not be published. Required fields are marked *.

We may earn a commission when you visit links on our website.