Here is a collection of tips, snippets, customizations and how-to tutorials to answer your biggest WooCommerce questions, curated by Rodolfo Melogli.
Please remember feedback is vital and that your social media shares, blog comments and WooWeekly newsletter sign ups help me understand which WooCommerce content works and which not, so that I can fine-tune my writing :)
Thank you in advance and enjoy!

Here’s another little WooCommerce tweak for your website user experience: let’s add some text in front of the Add to Cart button that says “Quantity: “.
As usual, we go looking for the right “hook”… the WooCommerce plugin is full of them and adding some custom content in the exact position we want is very easy. Enjoy!
Continue reading WooCommerce: Add “Quantity” Label in front of Add to Cart Button

Another interesting snippet that could come very handy. How do we show the product dimensions (height, width, length) in the shop / category / tag / loop pages? This could be a handy trick for shops that calculate shipping rates based on volume, or when the volume is a vital piece of data customers need to know before proceeding further. Either way, enjoy!
Continue reading WooCommerce: Display Height, Length, Width @ Shop Page

If you don’t want to assign the WooCommerce user role “customer” to new… customers, there is simple PHP that can be added to your functions.php to achieve this. Enjoy!
Continue reading WooCommerce: Change User Role for New Customers

Here’s yet another useful PHP snippet – and a mini-plugin alternative with super simple settings – that adds the Billing First Name and Billing Last Name to the Registration Form on the WooCommerce My Account page.
By default, the WooCommerce customer Registration Form only displays the email, username, and password fields (unless username and password are set to “automatically generate“, in which case only the email input field will be visible); by adding more billing and/or shipping fields to the form we can of course capture more information about each customer, so that you can do your background checks or allow them to save time at their next purchase.
Either way, enjoy!
Continue reading WooCommerce: Add First & Last Name to My Account Register Form

When an order is placed in WooCommerce, you might want to change/add something in the User Meta programmatically.
For example, you could “check” a custom checkbox in the User Profile. Or maybe assign the User Twitter username. And so on 🙂
Continue reading WooCommerce: Update User Meta After a Successful Order

This snippet could come really handy for several reasons. When you’ll need to do advanced customization of the checkout and its fields, hopefully you’ll thank me then 🙂
In today’s snippet, we will add a new checkbox and another new “hidden” field – then, if the checkbox is ticked, the field will show, otherwise it will disappear again.
Continue reading WooCommerce: Checkbox to Hide/Show Custom Checkout Field

So many times I needed to “play” with Cart contents in order to modify the default behaviour (such as removing a columns, hide the sale price to prices, hide an item, etc.).
There is a great PHP function that always helps – it’s called print_r and you can use this to “see” what’s inside the cart array, so that you can return certain information in a message for example.
A bit advanced, but as you grow your WooCommerce coding skills, you will use this a lot 🙂 Continue reading WooCommerce: See What’s Inside the Cart Array (print_r)

While working on a workaround for a client, I had to hide a hidden product from the cart, checkout, order received and emails. Hidden products already don’t show on the shop and category pages, but they do show on the cart if they’re added to cart “programmatically”.
A tough task, but as usual here I come with the solution 🙂
Continue reading WooCommerce: Hide Hidden Products From Cart, Order, Emails

There is a nice WooCommerce function you can use to exempt someone from Tax/VAT calculations. You could, for example, enable exemption once they enter a Tax/VAT number, or maybe if they specify a given ZIP code.
Such function is called set_is_vat_exempt(), and together with a little trick to “get” a checkout field on the go, the snippet is pretty simple to build and test. Enjoy!
Continue reading WooCommerce: Tax Exempt User Based on Checkout Field Value

When coding in PHP for WooCommerce, sometimes you’ll need to know what’s inside the “Order Array”, so that you can use its elements to print some custom message on the thank you page, or maybe modify its default behaviour.
There is a great PHP function that helps a lot – it’s called print_r() and you can use this to “see” what’s inside the order array 🙂 Continue reading WooCommerce: See What’s Inside the Order Array (print_r)

When you enable the Jetpack plugin and its “Publicize” module, WordPress posts get automatically shared to the social media you pick.
This, of course, includes also WooCommerce posts -> “products”. Well, what if you want to deactivate this function? Continue reading WooCommerce: Disable Jetpack Publicize for Products

A few snippets ago we introduced the magic WooCommerce inbuilt function “wc_customer_bought_product” – automatically, with a single line of PHP, you can find out if the user has already purchased a product ID.
But when building my new #BloomerArmada section, I had to know if a user purchased a product ID in the last 365 days… so I rewrote the function, changed its name and added a little edit to it – easy peasy!
Continue reading WooCommerce: Check if User Has Bought Product in the Last 365 Days

Following up from the other day’s snippet (deny checkout based on cart weight), you might want to show what is the current Total Weight on the cart and checkout page in case this is useful to your customers.
Of course, in order for this snippet to work, all your products must have a weight, otherwise the total will always be equal to 0. So here you go – enjoy!
Continue reading WooCommerce: Display Total Weight @ Cart & Checkout

Case scenario: if you add a product ID to cart with a specific, you want another product automatically added to cart (Buy One Get One, or “BOGO”).
This second product should have price = 0 if you wish to completely give it away, or maybe a set sale price. It should also be set to “hidden” because maybe you want to hide this free product from the shop and only gift it when the first one is added to Cart.
Also, if you remove product 1, the gifted product should go away from the Cart too. So here follows the PHP snippet of course!
Continue reading WooCommerce: “Buy One Get One” (BOGO)

A WooCommerce fan asked me: “How do you deny checkout if the cart weight is above a certain threshold?“.
Well, this is straight forward thanks to a WooCommerce core function called “cart_contents_weight” which allows you to get the total weight of your cart, and then the “wc_add_notice” function which shows a notification error.
Enjoy!
Continue reading WooCommerce: Deny Checkout Based on Cart Weight