WooCommerce snippets

On this page we present you our constantly growing collection of WooCommerce snippets (code snippets) to expand your WooCommerce shop with useful functions without additional plugins. The integration is very simple, programming knowledge is not necessary. You can choose to integrate them into your functions.php of your themes / child themes, or you can use the plugin Code snippets for WordPress.

The installation of this snippet is at your own risk, we assume no liability for it. We definitely recommend that you create a backup beforehand. But it is best to test it first in a development environment, which you can do with a few clicks WP staging create.

Do you have any other optimization tips for WooCommerce? Feel free to leave a comment below.

Please note, this collection is free and will be expanded, but we cannot offer free support for WordPress or WooCommerce. Please use the appropriate forums for this. We would be happy to make you an offer for individual solutions. Just ask.

Front end

Adjust translations and texts

The German translation for WooCommerce is very professional, but every now and then it happens that you want individual words or sentences to be formulated differently or have not yet been translated. Without touching the translation files immediately, because these would probably be overwritten with the next update, this can be solved with a simple and permanent trick. Replace “Choose an option” with the phrase or term you want to change. Replace "Select" with your translation. If you want to do several translations, just copy the whole line and paste it again below.

Remove comment field on checkout page

This simple snippet hides the comment box on the checkout page. We use it in some of our shops because the ordering process and the processing of orders are automatic and the field is simply ignored. Customers often write notes on delivery that are not printed on a parcel label anyway, so we decided to remove the field.

Add an additional checkbox on the Cashier page
Checkout – Testshop

Reasons for additional checkboxes on the checkout page are as varied as there are shops. For example, one of our customers sells products that can only be purchased from the age of 16, so he wanted an additional checkbox in which the customer confirms that he is at least 16 years old. The order should not be sent without clicking the corresponding checkbox. If you try to send the order anyway, you will be notified accordingly.

Cross out the subtotal and show the new price in connection with a voucher
Warenkorb emoose GmbH

This snippet is used in conjunction with a voucher. The original subtotal in the shopping cart is crossed out and the new, discounted price is displayed. If desired, the line with the voucher can also be hidden with a little CSS.

Show amount € 0.00 with free shipping
Cart – Testshop

In previous versions of WooCommerce, the amount 0.00 € was displayed after the shipping method for free shipping. This small snippet can be used to undo or restore this

Hide prices for unregistered users
Preis für unregistrierte User ausblenden e1506453034423

One of our customers only sells his articles to B2B customers and they have to register beforehand in order to be able to shop. It was his wish to hide the product prices for unregistered users / visitors.

Display YouTube video as product image
Tasse – Testshop

One of our customers only sells his articles to B2B customers and they have to register beforehand in order to be able to shop. It was his wish to hide the product prices for unregistered users / visitors.

Include the product picture and article number in the order confirmation email
WooCommerce Auftragsbestätigung

The order confirmation by email is not only a legal acceptance of the order, but also an important tool to provide the customer with all possible information about his order. The more the customer feels, the more confident they are in their decision; they have a positive shopping experience and fewer questions. Unfortunately, the product images and the article numbers are not available in the WooCommerce order confirmation by default.

Number of keywords in tag cloud

At a WooCommerce store, we recently discovered that WordPress limits the number of keywords in the tag cloud widget to 45 by default. With this snippet you can adjust the number at "number" as you like.

Show category images in the template

Have you ever wondered that WoooCommerce can upload a picture for every category, but then asked yourself why the picture is not displayed? This function is not inherently integrated in WooCommerce and not every theme supports it, but there is a simple solution for this too.

Hide the note about the voucher on the checkout page

Again in tip in terms of user-friendliness. If you have activated the voucher function at WooCommerce, a note to enter the voucher code is displayed on the shopping cart and checkout page. However, if a customer has already entered and activated the voucher on the shopping cart page, such a note on the checkout page is superfluous.

Prices from instead of to for variants

Perhaps you are also one of those people who would rather have a price with the note “from” instead of the price display for variants “from to”.

Insert tab for every product with the same content

For WooCommerce there are also some plugins to add further tabs to products in addition to the tabs Description and Reviews. If you are looking for a slim way to insert a fixed tab for all products, then this code will help you. The number at Priority indicates the order of the tab. Depending on which numbers the other tabs have, this is inserted accordingly. The larger the number, the further to the right or below the tab.

Show number of sales for product
Anzahl Verkäufe

Ebay does it, other online shops do it too, they show the number of sales for each product. This not only creates transparency and shows how much a product is in demand, but above all it shows the customers' trust in the product.
You can adjust the text as you wish. You can vary the order or the placement of the line in the frontend with the number "11" in line 1.

Display the offer period for the product
Angebot WooCommerce

With WooCommerce you can set an offer price and a period from when to when the offer is valid for each item. But now there are always situations in which your customers ask themselves how long the offer is still valid. Save your customers from asking questions and you from answering by showing the end date of the offer for the product. If necessary, adapt the text and the output of the date to your wishes.

Minimum order value for the entire shop and display of a notice if the value falls below this

Sometimes you have to or want to set up a global minimum order value in your shop because it is not economically viable to allow and process orders beforehand. With this simple snippet you can implement this in your shop. Simply replace your minimum order value and adjust the note or error message if necessary.

Show savings in % at product

Here is another sales promotion measure. Make it easier for your customers and show them their savings in percent. This snippet automatically calculates the savings in % for an item with an offer price. The display takes place both on the product page and on the category page.

Show savings in € and % on product
Product with Sale Price – Testshop

Here is another sales promotion measure. Make it easier for your customers and show them their savings in € and percent. This snippet automatically calculates the savings on an item with an offer price. The display takes place on the product page and can be adapted using its own CSS class.

Show other shipping methods even if free is available
Warenkorb mit Versandarten

With the update to WooCommerce 2.6, the entire setting for shipping has changed positively, there are now many more options with regard to shipping zones and shipping settings.

Now we had the case for a customer who, like many other retailers, probably also offers standard shipping, wanted to offer free shipping above a certain amount and also wanted to offer express shipping. For this purpose, we have renamed the on-site pick-up to express delivery in the shipping settings, because on-site pick-up is not offered.

By default, however, all other shipping methods are hidden in WooCommerce as soon as free shipping is offered. Thus, in our case, the express shipping or the pick-up on site was of course hidden.

With this snippet, however, the problem can be solved.

Show product release date on product page
WooCommerce veröffentlicht am

Show your customers when you added the product to your catalog, the big players do it that way too.

Show category description below the products

The category description in WooCommerce is by default displayed above the products. But if you have now written a nice long SEO text, the customer has to scroll down before he can get to the actual products. In most cases the customer does not read the text anyway 🙂 With this small snippet you can display the text of the category description below the products.

Only add text after the price for certain products
Hinweis hinter Preis bei bestimmten Produkt IDs

Every now and then I would like to display additional information behind the price in WooCommerce. We now had the case for a customer who sold configurable products and the information "Base-graduated price" should be displayed behind the price. This small snippet can be used to enable this, depending on the product ID. This information is displayed on the product page and in the shop archive.

Hide the description of the shipping method in the shopping cart
Versandart im Warenkorb ausblenden

WooCommerce also shows the name of the shipping method in the shopping cart. In some cases it doesn't look very nice, because all other prices in the shopping cart are shown one below the other, just not the one for shipping. Anyone who can afford it, because they only have one shipping method and one shipping price, for example, can hide the shipping method with this small snippet. "Free delivery" and "On-site pickup" are not affected. This snippet only removes the display in the shopping cart, the shipping method is still displayed in the emails and the order details.

Add fee to cart and checkout
Gebühr hinzufügen

If you want to charge a fixed fee for your orders, there are many reasons for this, you can achieve this with a small snippet. Of course, the taxes for the fee are calculated accordingly and the fee is also displayed in the order details.

What is Remove PayPal from Payment Method on the Checkout page
was ist PayPal entfernen

Not everything makes sense and is also not so nice to look at. With this little snippet you can remove the link “What is PayPal” for the PayPal payment method on your checkout page.

Add your own text on the login page
eigener Text auf Anmeldeseite

Feed your customers with additional information on the login and registration page. For example about the advantages of registration or what the customer can expect when he is logged in. The possibilities are almost limitless with this snippet.

Move similar products to a new tab
Ähnliche Produkte in einem neuen Tab

If you want to move the "Similar Products" to a new tab for visual reasons, you can do that with this snippet.

Notification in the shopping cart when a certain product is in the shopping cart
Produkt im Warenkorb

If you want to notify your customers as soon as a certain product is in the shopping cart, you can do that with this snippet.

Telephone no mandatory field

If you want to prevent the Phone field from being a mandatory field on the Checkout page, you can use this snippet.

Automatically add a voucher to the shopping cart for sales promotions

The less work the customer has, the more conversions you can achieve. So why not activate a voucher automatically in the shopping cart, so the customer no longer has to enter it. With this snippet you can activate a voucher code of your choice in the shopping cart. However, the customer must call up the shopping cart page, otherwise the discount will not be applied.

Show savings in shopping cart and checkout
Ersparnis Snippet

Convincing a customer to buy on your side is hard enough. Why not help out with a little psychological trick? If the customer has products in the shopping cart that are on sale, the total savings are displayed on the shopping cart and checkouts page with the help of this snippet.

Additional information directly above the shopping cart
Zusätzliche Informationen direkt über Warenkorb emoose GmbH 1

The properties of products in WooCommerce are displayed in the "Additional information" tab. Is not necessarily logical now and can easily be overlooked. If you now display this information directly above the shopping cart button, it will certainly not be overlooked.

You can hide the superfluous tab with Custom CSS:
.product .woocommerce-tabs .tabs .additional_information_tab {display: none}

Check whether the house number was entered at the address
Hausnummer Prüfung

It is annoying when you receive an order but the customer forgot to include his house number with the address. This creates an additional effort for the demand.

This snippet solves the problem and checks address line 1, both the invoice and delivery address, for a number during the ordering process. If there is no number in the field, a corresponding error message is output.

Note on the cash register page depending on the country selected
WooCommerce Snippet emoose GmbH - note on checkout page depending on the country selected

Sometimes you need a solution to display a corresponding notice to buyers from abroad. We use the function, for example, for free returns through PayPal and recommend that buyers pay with PayPal.
This snippet is suitable for this, depending on the country of the billing address, there is a corresponding note.

WC 3.3 Hide category Uncategorized

With this small snippet you can hide the “Uncategorized” category, which has existed since WooCOmmerce 3.0, in the frontend.

Note Remove items placed in the shopping cart

With this small snippet you can hide the information that an item has been placed in the shopping cart. Very helpful if you have a shopping cart widget, for example, then the note is superfluous.

Empty shopping cart function
Warenkorb – Testshop

Why would you offer such a crazy feature? Quite simply, you should try everything to make life as easy as possible for your customers. So instead of deleting each item individually, you can now delete the entire shopping cart with a single click.

Note, order quickly now before sold out
Simple Product – Testshop

If you have activated the inventory management in WooCommerce and activated the threshold value for the low inventory, then this function is user-friendly and encourages buying.

As soon as the stock has reached or fallen below the threshold value, a freely definable message is displayed for the product in the front end.

Display shopping cart balance until free shipping
Anzeige Warenkorb Restbetrag bis kostenloser Versand

Encourage your customers to buy a little more! For example, with a note in the shopping cart which amount is still missing until shipping is free.

WooCommerce description of product category with text above and below
Kategorie bearbeiten ‹ Testshop — WordPress

Anyone running a shop should sooner or later deal with the topic of SEO. If that doesn't mean anything to you, you don't need to read any more from here.

To describe your product categories there is only one field to insert a description there. If the theme supports it, this is then displayed directly below the heading. (Please note, there is also a snippet above to display the description below).
The more text there is, the higher the probability that your users will not read it, and it doesn't look particularly nice either.

So why not add a short description at the top and a detailed description with a lot more information at the bottom? Not only Google is happy, but also your visitor.

You can do that with this snippet. Have fun

Mail to customer for canceled order

By default, only the admin receives an email when an order is canceled. The customer also receives a notification with this snippet.

Admin & backend

Disable WordPress Auto Update emails

With this snippet you deactivate the WordPress e-mail "Some plugins were updated automatically"

Enlarge product images in the backend
produktbilder vergrößern

The product images in the WooCommerce backend in the “Products” overview may be a bit small for some users, but that can be changed easily and that's why we love WooCommerce

Add link in WP Admin Toolbar
Link hinzufügen

As an admin of a WordPress site, you want to make life as easy as possible for yourself and your customers. We do that too Fulfillment for some of our customers and have an additional link built into the admin toolbar, so they can easily access the fulfillment statistics and do not have to save another bookmark. You probably have a lot of ideas for further links in the admin toolbar.

It's easy to do with this little snippet.

BCC completed order emails

WooCommerce sends an email to the customer when the order has been completed, but unfortunately not to you as the shop operator. With this simple snippet you will receive this mail in BCC. Just replace your name and email address.

BCC all WooCommerce emails

WooCommerce sends quite a few emails to the customer, but unfortunately not to you as the shop operator. With this simple snippet you will receive all WooCommerceMails in BCC. Just replace your email address.

Reply To function for e-mail order confirmation

As a shop operator, you can have an email sent to you for a new customer order. If you then click on reply in your mail program because you might want to send the customer some information, you practically send this mail yourself because you answer the shop's sender. With this snippet, the customer's email address is automatically entered when responding.

Add prefix / suffix to order number
Prefix Suffix bei Bestellnummer

Whether for visual or organizational reasons, with this small snippet you can add a prefix and a suffix to your order numbers in WooCommerce.

WooCommerce new order status

Sometimes you just need another order status, there can be many reasons for this. For example, we have a new order status "In delivery backlog"
inserted because we allow an order for some products even though the stock is sold out. So that we don't lose track of things, we simply put the order into the new order backlog.

Show total number of sales in product overview

With this small snippet you can add a column with the number of units sold in the product overview in the backend.

WooCommerce automatic forwarding to order overview after login

If you can simplify your life, you should do it too. For many of you it is a daily ritual. Log in to WordPress and then to the WooCommerce order overview to process the orders. With this snippet you will automatically be redirected to the order overview after logging in.

Filters for payment types

Sometimes you want to filter your orders in the backend according to the payment methods, this snippet makes it possible. To do this, a new dropdown is added to the order overview in the backend and then the payment method is selected.

Display of number of customer orders in WC order details
Screenshot 2021 06 15 12.08.23

With this snippet you can see how often a customer has already ordered in the order details. We will check this on the basis of the e-mail address

203 thoughts on “WooCommerce Snippets

  1. Max says:


    great post that is very helpful.

    Can you also provide a snippet that prevents vouchers from being applied to certain variants of a variable product?

    For example: product property color with red and blue. The voucher should only be used on blue and not on red.

  2. Patrick says:

    I sell products with different shipping costs. Unfortunately it has not been possible for me to set this up so that, for example, only Deutsche Post or only DHL is displayed. So that both are not always displayed, I only have standard shipping there. The setting “Per order: shipping costs according to the most expensive shipping class of the order” did not help either. If someone had a solution or a snippet for it *. *

  3. Maja says:

    It would be great if you also had a solution on how to hide the number, especially on the product page (possibly also in the shopping cart or checkout) next to the 'Add to shopping cart' button - and only for variable products (with the option of choosing different individual prices depending on the number selected in the variant selection box), not with the simple products that will also be available in the shop?
    Thank you very much!

  4. CAC says:

    Hello and thank you for the many small but very useful snippets,

    I have two questions:

    1. at the price from instead of to for variants,
    Is there a possibility with variable prices (created as a selection menu) the selected price is also displayed directly on the product page?
    By default, the lowest price is always displayed. But I want the customer to see the current price immediately after making a selection, not in the shopping cart.

    2. Is there a snippet somewhere with which I can also insert a text under the price / shopping cart button?

    Thank you very much and have a nice weekend

    • emoose says:

      1. is actually standard, if this is not the case with you, you have a bug somewhere.
      2. yes herewith:

      add_action ('woocommerce_after_add_to_cart_button', 'misha_after_add_to_cart_btn');

      function misha_after_add_to_cart_btn () {
      echo 'this is where the text goes';

  5. Finn says:

    Hello, when you are on a product page, there is a button on the right where it says reset selection, how can I remove it? is there a snippet for it?

      • Finn says:

        Good Morning,

        thanks for the quick answer, but unfortunately this code doesn't work for me, I tried it in CSS, in the customizer and in a snippet tool.

        Do you have an answer to that?

        here is a screenshot:

        I have added the product page to the website, so you have the direct product.

        Kind regards


  6. Chris says:

    Is there a possibility to print 4 shipping labels on 1 DIN4 sheet? There are forms to stick on for this. Currently I am using paper unnecessarily because I use 1 DIN4 sheet for 1 shipping label.

  7. Andreas says:

    Unfortunately, the snippet does not work, checking the house number when ordering. Anyone have any idea or does it not belong in the function.php? Lg

    • emoose says:

      The snippet works, I just tested it with a current WordPress, WooCommerce and the Storefront theme. The snippet belongs in functions.php.

  8. Dominik says:

    Hello emoose team,
    maybe you have a snippet to activate the "Send delivery to a different address?" option, if you chose to collect it yourself for the shipping method. I've already tried it myself but somehow it doesn't work or I'm on the hose.

    add_filter ('woocommerce_checkout_fields', 'hide_address');
    function hide_address ($shipping_address) {
    if ($shipping_method == 'local_pickup') {
    $shipping_address = false;
    return $shipping_address;

Leave a Reply

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