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!
The default WooCommerce Add to Cart “Quantity Input” is a simple input field where you can enter the number of items or click on the “+” and “-” to increase/reduce the quantity.
A freelance client hired me to turn that input into a “Select” drop-down. For their audience and UX requirements, it makes sense to let their customers choose the quantity from a drop-down instead of having to manually input the number.
Online there are complex snippets, but I decided to make things easier. The WooCommerce function responsible to generate the quantity input is called “woocommerce_quantity_input“.
Luckily, it’s a pluggable function – which means we can simply add this exact same function name to our child theme’s functions.php to completely override it. Enjoy!
Continue reading WooCommerce: Change Add to Cart Quantity into a Select Drop-down
Here’s the story: I’m working with one of my freelance clients and I need to show certain content in the Checkout (a product-specific “Terms and Conditions”) if such product is in the Cart.
Now, I’ve always looked for products in the Cart by “looping” through the Cart with a foreach (here, for example: Apply a Coupon Programmatically if a Product is in the Cart). But as I said, after some random research, I found out about another magic WooCommerce function: “find_product_in_cart()“. Which means finding a product in the Cart doesn’t require custom loops or complex PHP… it’s just a “one liner”. Enjoy!
Continue reading WooCommerce: Check if Product ID is in the Cart
This week’s snippet is a very easy – yet helpful – one. Many ecommerce entrepreneurs prefer to display a YouTube video instead of a static, boring, featured image and product gallery.
Of course, not all products are created equal. So, let’s see how to make this work for a specific product ID only. Enjoy!
Continue reading WooCommerce: Show Video Instead of Product Images
Let’s talk about checkout UX: if a user is willing to pick up the item in store, why should there be a shipping form on the checkout?
Well, let’s see how we can hide this dynamically with a bit of PHP and JS!
Continue reading WooCommerce: Hide Shipping If Local Pickup Is Selected
Here’s a very simple snippet that achieves a very complex task – what if you wanted to force your Cart to charge a deposit or a fixed fee, no matter the cart total?
Well, thankfully WooCommerce is pretty flexible and a lot of workarounds can be found.
In this case, we will study two possible solutions: (1) a negative “cart fee” to make the total become e.g. $100 and (2) a filter to completely override the calculated cart total e.g. $100.
Sounds like Japanese? Great – here’s why you’re on Business Bloomer. Copy the snippet, apply it to your test WooCommerce site and see the magic happen – without knowing anything about coding!
Continue reading WooCommerce: Force Cart to Specific Amount (Deposit)
A correct email address is worth a thousand dollars, some ecommerce expert would say 🙂 So, you don’t want your WooCommerce checkout visitors to mess up with that, do you?
What about adding an “Email Verification” field? In this way, we can make sure they double check their entry – and also show an error message in case they don’t match!
Let’s see how I implemented this for a freelancing client of mine – I’m sure you will be grateful!
Continue reading WooCommerce: Add “Confirm Email Address” Field @ Checkout
A BloomerArmada fan had a nice challenge with a client – how to display the total amount of sales generated by a given coupon code?
So I managed to create this snippet, which adds a brand new column to the WooCommerce Coupon table view with “total sales” value in it for each coupon code – enjoy!
Continue reading WooCommerce: Calculate Sales by Coupon Code
Quite an interesting snippet this is! A client needed to show EACH quantity of the SAME product as separate lines (cart items) in the WooCommerce Cart & Checkout page.
At some stage, you might need that too – for different reasons maybe. So, let’s see how this is coded 🙂 Continue reading WooCommerce: Split Cart Items When Product Quantity > 1
Yes, there are many plugins that already achieve this. But my goal at Business Bloomer is to save you from plugin conflicts, delicate updates and to make you learn some PHP.
So, here’s how you can add, with a few lines of PHP, a minimum, maximum, increment and default value to your Add to Cart quantity input field on the single product and cart pages. Who knew it was this easy?
Continue reading WooCommerce: Edit Add to Cart Default, Min, Max & Step Product Quantity
We’ve already seen how to add First & Last Name to the “My Account” register form. Today, I want to expand a bit and show you how to add and save a select box.
Continue reading WooCommerce: Add Select Field to “My Account” Register Form
WooCommerce 3.0 completely revolutionized the single product page featured and product gallery images, including their PHP. If, in the past, a simple filter from WooCommerce was enough to change the number of thumbnails per row (https://docs.woocommerce.com/document/change-number-of-thumbnails-per-row-in-product-galleries/), this does not exists anymore 🙁
So, let’s see how we can achieve this in WooCommerce 3.0 and above. For this example we’ll use two themes – in fact some theme-specific CSS is also needed together with the PHP.
Continue reading WooCommerce: Change No. of Thumbnails per Row @ Product Gallery
As WooCommerce snippet requests by Business Bloomer Club members keep coming to our private Slack channel, it’s time to publish a very useful customization.
Today, we’ll see how to deny purchasing to a given billing email address, if such a customer happens to have a pending order already!
Continue reading WooCommerce: Deny Checkout if User Has Pending Orders
Interesting, isn’t it? This has been on my to-write list for ages, so today I want to show you my first attempt at turning the Shop page into a list/table of products as opposed to the default grid.
This is especially suitable to B2B WooCommerce shops, or for those websites where customers don’t really need to see huge product images and are used to order “from a product form”.
Let’s see how I did this – I will try to comment my PHP as much as possible so you can understand my strategy. Enjoy!
Continue reading WooCommerce: Product List View @ Shop
You may want to disable the Grouped product price range on the Shop and Single Product page. This usually looks like $100-$999. With this snippet you will be able to display “From: ” in front of the minimum price, or otherwise completely hide it 🙂
Continue reading WooCommerce: Disable Grouped Product Price Range $$$-$$$
You might want to show a “POA” price and/or a “Call for Price” button when you have a product with an empty price.
Many businesses require this, mostly real estate and wholesalers. So let’s see how it’s done 🙂
Continue reading WooCommerce: POA / Call for Price @ Single Product