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 include them in your functions.php of your theme / child theme, 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 just a few clicks WP staging create.

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

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


Adapt translations and texts

The German translation for WooCommerce is very professional, but every now and then it happens that individual words or sentences still want to be phrased differently or have not yet been translated. Without touching the translation files right away, because these would probably be overwritten in the next update, this can be solved with a simple and permanent trick. Replace "Choose an option" with the phrase or phrase you want to change. Replace "Select" with your translation. If you would like to make several translations, simply copy the entire line and paste it under it again.

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 the orders run automatically 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 checkout page
Checkout – Testshop

There are as many reasons for additional checkboxes on the till side as there are shops. One of our customers, for example, sells products that can only be purchased from 16, so he wanted an additional checkbox in which the customer confirmed that he was 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 informed accordingly.

Cross out the subtotal and display the new price in conjunction 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 then 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 behind the shipping method for free shipping. With this little snippet you can undo or restore it

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 shop. His wish was to hide the product prices for unregistered users / visitors.

Show YouTube video as a product image
Tasse – Testshop

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

Insert the product image and article number in the email order confirmation
WooCommerce Auftragsbestätigung

The order confirmation by email is not only a legal acceptance of the order, but also an important instrument to provide the customer with all possible information about his order. The more, the more secure the customer feels in his decision, he has a positive shopping experience and fewer questions. Unfortunately, the product pictures and the article numbers are not available in the WooCommerce order confirmation as standard.

Number of keywords in the tag cloud

At a WooCommerce shop, we recently found 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 pictures in the template

Have you ever wondered that WoooCommerce can upload an image for every category, but then asked you why the image is not displayed? This function is not built into WooCommerce and not every theme supports it, but there is also a simple solution for this.

Hide information about the voucher on the checkout page

Again in tip in terms of usability. If you have activated the voucher function at WooCommerce, a note about entering 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 notification on the checkout page is superfluous.

Prices from instead of to for variants

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

Insert tab for each product with the same content

For WooCommerce there are also some plugins to add further tabs for products in addition to the tabs Description and Reviews. If you are looking for a lean way to insert a fixed tab for all products, this code will help you. The number in 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 is 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 it also shows above all the trust of customers in the product.
You can adjust the text as you like. You can vary the order or placement of the line in the frontend with the number "11" in line 1.

Show offer period for the product
Angebot WooCommerce

With WooCommerce you can set an offer price and a period of time for each item from when to when the offer is valid. Now there are always situations in which your customers ask themselves how long the offer is still valid. Save your customers from asking and 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 notification if the value is undershot

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

Show savings in % for product

Here is another sales promotion. Make it easier for your customer 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 on the product page as well as on the category page.

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

Here is another sales promotion. Make it easier for your customer and show them their savings in € and percent. This snippet automatically calculates the savings on an item with an offer price. The display is on the product page and can be customized using a separate CSS class.

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

With the update to WooCommerce 2.6, the complete setting for shipping has also 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 from a certain amount and also express shipping. We have renamed the pickup on site in the shipping settings to express shipping, because pickup on site is not offered.

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

With this snippet the problem can be solved.

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

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

Display the category description below the products

By default, the category description in WooCommerce is shown above the products. If you have now written a nice long SEO text, the customer must first scroll before he gets 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 behind the price for certain products
Hinweis hinter Preis bei bestimmten Produkt IDs

Every now and then would like to display additional information behind the price in WooCommerce. We now had the case for a customer who sold configurable products and behind the price the information "basic scale price" should be displayed. With this small snippet you can do this depending on the product ID. This information is displayed on the product page and in the shop archive.

Hide the name 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, this does not look very nice, since all other prices in the shopping cart are displayed one below the other, just not the one for shipping. If you can afford it now, for example because you only have one shipping method and one shipping price, you can use this small snippet to hide the shipping method. "Free delivery" and "On-site pickup" are not affected. This snippet only removes the display in the shopping cart, in the mails and the order details the shipping method is still displayed.

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 shown in the order details.

What is Paypal remove in the payment method on the checkout page
was ist PayPal entfernen

Not everything makes sense and is also not visually attractive. With this small snippet you can remove the link "What is PayPal" from the payment method PayPal 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 has 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" into a new tab for optical reasons, you can do this with this snippet.

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

If you want to let your customers see a notification as soon as a certain product is in the shopping cart, you can do so with this snippet.

Telephone is not a required field

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

Automatically add voucher in the shopping cart for sale campaigns

The less work the customer has, the more conversions you can achieve. So why not automatically activate a voucher 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 go to the shopping cart page, otherwise the discount will not be applied.

Show savings in shopping cart and checkout
Ersparnis Snippet

To convince a customer to buy on your site is difficult enough. Why not help out with a little psychological trick? If the customer has products in the shopping cart that are on offer, the total saving is shown on the shopping cart and checkout page using this snippet.

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

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

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

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

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

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

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

Sometimes you need a solution to display a note 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 that has been around since WooCOmmerce 3.0 in the frontend.

Note Remove items placed in the shopping cart

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

Empty shopping cart function
Warenkorb – Testshop

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

Order now quickly before sold out
Simple Product – Testshop

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

As soon as the inventory reaches or falls below the threshold, a freely definable message is issued in the front end of the product.

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

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

WooCommerce Description Product category with text above and below
Kategorie bearbeiten ‹ Testshop — WordPress

Anyone who runs a shop should sooner or later also deal with the topic of SEO. If that doesn't mean anything, you don't need to read on 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 above and a detailed description below with much more information? Not only Google is happy, but also your visitor.

You can implement this with this snippet. Have fun

Mail to customer when order is canceled

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

Admin & backend

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 this can be changed easily and that's why we love WooCommerce

Add link in the 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 also do that Fulfillment for some of our customers and have an additional link built into the admin toolbar, so they can simply access the fulfillment statistics and do not have to save another bookmark. You also have a lot of ideas for further links in the admin toolbar.

This small snippet makes it easy to do.

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 some 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 email order confirmation

As a shop owner, 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 an info, you practically send this mail yourself, because you answer the sender of the shop. This snippet automatically enters the customer's email address when replying.

Add prefix / suffix to order number
Prefix Suffix bei Bestellnummer

Whether for optical 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 an additional order status is simply required, there can be many reasons for this. We have, for example, a new order status "In Backorder"
inserted because we allow an order for some products despite the stock being sold out. So that we do not lose the overview, we simply put the order in 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. It is a daily ritual for many of you. Log in to WordPress and then to the WooCommerce order overview to process the orders. With this snippet you will be automatically forwarded to the order overview after logging in.

191 thoughts on “WooCommerce Snippets

  1. 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 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!

  2. 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 add 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';

  3. 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 added the product page to the website, so you have the direct product.

        Kind regards


  4. Chris says:

    Is there a way to print 4 shipping labels on 1 DIN4 sheet? There are forms to glue on for this. Right now I am using paper unnecessarily because I use 1 DIN4 sheet for 1 shipping label.

  5. Andreas says:

    Unfortunately, the snippet does not work, checking the house number when ordering. Anyone have any idea or does 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.

  6. Dominik says:

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

    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 *