Affiliate Disclosure: Some links on this website are affiliate links. We make commissions for purchases made through those links.
We only recommend items/tools that we've personally used and like.
We recently needed to change the labels for our WooCommerce cart, but were unable to find any resources on line (even in the official WooCommerce documentation) on how to do that. In this article, we're going to go over a quick and easy way to change the labels on the WooCommerce cart table.
The default WooCommerce cart table has four specific labels. These include the product, price, quantity, and total. In many situations, this is perfect. If you're selling physical products with WooCommerce, there's no need to change the labels of the table.
However, WooCommerce has expanded from selling physical products to digital items, services, bookings, and more.
There are many use cases when it would be a good idea to change the default cart labels from in WooCommerce.
For example, what if you are selling bookings? Instead of “product”, a better label would be “room number/house”. “Quantity” could be changed to “nights”.
If you sell services through WooCommerce, chances are you don't want the default labels of product, and quantity. Instead, you could say “Agent Name” and “billable hours”.
The list for potential use cases where you would want to change the default WooCommerce card labels can go on and on. Surprisingly, there's no easy and simple way to do this.
From our research, we were unable to find any plugins that made it easy to replace the default cart table labels in WooCommerce. That means that we need to figure out how to do it ourselves. When checking the WooCommerce documentation, or the Internet for any code snippets, these are also very difficult to come by. it took us a few hours to come up with the solution Displayed below.
For one of our clients, we wanted to change the label “product” to “tutor”, as each product in the WooCommerce system was actually a tutor name.
To do this, you need to edit one of the core file templates in WooCommerce. If this sounds scary or confusing to you, don't worry, it's very simple to do. You don't even need to log into FTP to get it done.
Of course, this is a fairly quick and dirty way to do things. When editing these files, the WooCommerce plugin should be disabled. Also, whenever WooCommerce updates, you will need to re make these changes (though there's a work around which we will discuss at a later date).
This specific file within the WooCommerce plugin that we will be editing is called “Cart.PHP”. this contains all of the code that makes up the structure of the cart page on the front end.
To edit it, you can use the core WordPress plugin editor. This is accessed by going to Plugins, Plugin Editor.
Then, in the upper right hand corner select WooCommerce as the plugin to edit.
As you can see, making changes to active plugins is not recommended, so you should deactivate WooCommerce before doing anything.
We then need to find the Cart.php file, which contains the code that dictates the titles of the labels in the front end card page of WooCommerce. Changing these labels in that PHP file is the quickest way to add custom card labels to WooCommerce.
This file is located within templates, cart, cart.PHP. Use the plugin files navigation utility on the right of the screen to load the cart template PHP file for WooCommerce.
Once this file is loaded, we now have two choices. We can either create a new copy of this file and override the default template, or we can change the default cart labels within this template. Method one takes a little bit more work, but won't be overwritten when WooCommerce updates. Method two is instant, but will be overwritten when WooCommerce updates.
Here is the guidance that is given to you by the WooCommerce development team within the cart.PHP file:
This template can be overridden by copying it to yourtheme/woocommerce/cart/cart.php. * HOWEVER, on occasion WooCommerce will need to update template files and you (the theme developer) will need to copy the new files to your theme to maintain compatibility. We try to do this as little as possible, but it does happen. When this occurs the version of the template file will be bumped and the readme will list any important changes.
Note that you need to occasionally copy files and do some manual work to ensure compatibility if going with the more permanent route two. Whichever route you choose, the edits will be the same.
The cart labels show up in two instances within this file. First, you have your general cart labels which are contained at the top of the code. By default, they will read products, price, quantity, and subtotal.
Found on lines 30-33 of Cart.php:
<th class="product-name">'Product', 'woocommerce' ); esc_html_e( </th> <th class="product-price">'Price', 'woocommerce' ); esc_html_e( </th> <th class="product-quantity">'Quantity', 'woocommerce' ); esc_html_e( </th> <th class="product-subtotal">'Subtotal', 'woocommerce' ); esc_html_e( </th>
Make the necessary changes to the first string within the PHP to edit the cart label. As an example, this changes "product" to "tutor""
<th class="product-name"><?php esc_html_e( 'Tutor', 'woocommerce' ); ?></th>
Then, within the PHP code that makes up the cart table, you will find another instance of the same label. To change the default cart labels in WooCommerce, all you need to do is change the code.
This is the code that actually makes up the structure and content of the cart table in WooCommerce. On line 77, there is PHP that specifies the header label. Changing it from the default of “product” to “tutor”, will change the cart label for product on the front end as well.
You can simply CTRL+F to find all instances of the label that you want to change, and then replace the default one with your new label.
Once you've made the changes to the code, update the file, and check the front end. You should now have custom cart labels on WooCommerce.
This article should have showed you a quick and dirty way to change the cart labels on WooCommerce. As far as we can tell, there are no plugins that allow you to easily do this, and this method is one of the quickest and simplest ways to get it done. If you have any other methods of changing the cart labels, or have any questions leave them in the comment section below.
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.