By default, empty WooCommerce product categories (i.e. categories which have no published products) will not display on your Shop page.
This makes a lot of sense and avoids that customers land on empty pages… BUT sometimes you might have different needs and require that users still see these categories when the shop display is set to “Show Categories”.
Thankfully there is a quick one-line fix that you can copy / paste in your functions.php to show empty categories… enjoy! Continue reading WooCommerce: Show Empty Product Categories
When you work with WooCommerce PHP snippets, you often need to “get” stuff off your WooCommerce database in order to make some calculations and return the result on the screen. And if there is something I often google is “How do I get all my store’s product IDs?“.
Thankfully the get_posts WordPress function gives us the answer. In the next weeks we’ll also see how we can get other information, such as all SKUs, all product categories, etc.
So, here’s the quick snippet to return all product IDs on the Cart page (“woocommerce_before_cart” hook) – you can change that if you want to use them somewhere else. Enjoy 🙂 Continue reading WooCommerce: Get & Return All Product IDs
If you’re developing custom WooCommerce documentation, reporting or functionalities for your clients, you probably also need to add a new “page” and a new “submenu link” to the WordPress Admin Dashboard.
This is a very interesting topic and in the same way you can hide elements, you can also add new ones. In my case, I had to implement a custom, admin-only form to enable product recommendations. Enjoy 🙂 Continue reading WooCommerce: Add New Subpage @ WordPress Admin Dashboard
We already talked about weight based shipping and in this post we found out how to charge different flat rates based on shipping weight thresholds.
But now I want to show you how you can use the default “Flat Rate” to calculate shipping costs based on cart weight, thanks to a multiplier. For example, your shipping rate might be “$5 for each Kg” – as you know the default “Flat Rate” only allows you to define one rate e.g. $10.
So, what if you want to calculate shipping charges by weight? Well, here’s a simple workaround for you. Continue reading WooCommerce: Flat Rate Calculation Based on Weight (Without a Plugin!)
When your WooCommerce store has no published products the shop page will not display anything. A message “No products were found matching your selection” will show instead. The same applies to empty categories.
So, how do we hide this notice? Thankfully, and once again, one line of PHP is sufficient to achieve the result! Enjoy 🙂 Continue reading WooCommerce: Hide “No products were found matching your selection”
I had the pleasure to speak at WordCamp Prague 2019. I spoke about “10 PHP Snippets to Increase WooCommerce Sales” and managed to show some simple coding to the audience. Trust me – increasing your WooCommerce sales can also be done with a free, short, easy PHP snippet.
So, given that I want to share all the snippets I talked about, this is a quick recap. Copy them, test them (a must!) and then use them. And let me know if your conversion rate and/or AOV (average order value) increased!
At the bottom of the page you also find my talk slides. Enjoy:) Continue reading WooCommerce: 10 Easy Snippets to Increase Your Sales
WooCommerce emails come with the following hard-coded (argh!) greetings: ‘Thanks for shopping with us.‘, ‘Thanks for reading.‘, ‘We look forward to seeing you soon.‘, ‘We look forward to fulfilling your order soon.‘, ‘Thanks!‘, ‘We hope to see you again soon.‘ based on the specific email.
While having these greetings in the WooCommerce customer email footer may look nice and friendly, it is unlike WooCommerce to present them without the possibility to “filter” them out (i.e. removing them if you don’t want them).
So, a workaround is necessary. And it’s pretty simple: we just tell WooCommerce to “translate” those strings into empty strings, so that they don’t show. Enjoy! Continue reading WooCommerce: Hide “Thanks for shopping with us” etc. @ Emails
Let’s say you disabled product tags in your shop. Or maybe your store set up requires no short description. Or even, you want to hide a custom “metabox” (e.g. one of those widgets that appear on the Edit Product page). Either way, removing metaboxes and making the Edit Product page much cleaner is quite easy.
You just need the “ID” of the metabox and its position (‘normal’ or ‘side’, depending on whether it’s in the sidebar or not), and then this little PHP snippet. Enjoy! Continue reading WooCommerce: Remove “Metaboxes” @ Product Edit Admin Page
There are times when you need to send logged out customers to a Login page and unregistered customers to a distinct Register page.
As you know, the WooCommerce My Account page, which contains the [woocommerce_my_account] shortcode, has both Login and Registration forms. But this is not always a good idea, mostly when you use landing pages or sales pages with a specific goal e.g. user registration.
Clearly, when this happens, you don’t want to have a login form there as well. My solution provides two new shortcodes, one for the login form and one for the register form.
Please be aware both shortcodes’ content is copied from WooCommerce template files – if WooCommerce releases an update or makes a change to these files, you need to change the shortcode coding too.
Give it a go, feedback is much appreciated 🙂 Continue reading WooCommerce: Separate Login and Registration Pages
Here’s a quick snippet to disable those (annoying) Jetpack ads and upsells that show in the WordPress dashboard if WooCommerce is active. Thankfully, Jetpack provides us with a filter, and hiding those banners is quite easy. Pity there is no option in the settings (as of now).
Here’s the 1-line PHP snippet for you – add it to your websites and avoid annoying banners for all users. Enjoy! Continue reading WooCommerce: Remove Jetpack Ads @ WP Dashboard
When you log in to the WordPress dashboard and WooCommerce is active, you might want to be redirected to a different page rather than the default “Dashboard” one.
For example, you might want to go directly to the “Products” admin page, or maybe to the “WooCommerce > Orders” page. Or, if you are like me on my development website, you want to go straight to the WordPress editor’s functions.php file 😀
Either way, saving time on login is what we’re chasing here. Pick your default login page, and then use the two snippets below to target actual logins and direct accesses to wp-admin. Enjoy! Continue reading WooCommerce: Set Default Dashboard Login Page to “Products”
This snippet consists of many WooCommerce tasks: setting up a “WordPress Cron Job” (i.e. schedule a hook that runs on a specific time interval), getting the WooCommerce completed orders from the database, and finally sending a simple email to the store admin.
Complex, but as usual you can simply copy/paste and re-adapt it to your unique specifications. For example, I’m using it to send a survey email to each customer who has placed an order. There are thousands of applications, so this is just the start. Enjoy! Continue reading WooCommerce: Send Email to Admin Every 3 Hours (Cron Job)
We talked a lot about safely updating WooCommerce. The same applies to WordPress core, other plugins, themes… WordPress is such a delicate piece of software that you should ALWAYS know what to do before actually doing it 🙂
Sometimes, website managers feel great about clicking on that “Update Now” link in their WordPress dashboard. It seems – and it is – so easy. Problem is, they’ll likely break the website.
The best way of doing this properly is to run the updates (as well as custom code, plugin tests, design changes) on a “staging environment“, which should be provided by your hosting company.
Either way, those “Update Now” links are too dangerous. Only you (the developer) need to know that – while it’d be better if the other users who have access to the dashboard didn’t see anything and concentrated on WooCommerce orders or WordPress post and content editing.
Clearly, there is a way to disable the update notifications on a per-user basis or, even easier, to only have 1 user (possibly you) see these. The snippet is a little complex, but there is a lot of literature online – this is the one that worked for me! Continue reading WooCommerce: Disable Update Notifications @ WordPress Dashboard
On the admin side, you might need to display WooCommerce information inside the users table (WordPress Dashboard > Users). For example, their billing country. Or maybe some custom calculation e.g. the number of completed orders.
Either way, this is super easy. First, we add a new column – second, we tell what content should go inside it. Enjoy 🙂 Continue reading WooCommerce: Add Column to Users Dashboard Table
When a variable product has the same price for all variations, a unique price is shown to website users i.e. the one at the top of the page. However, this behaves differently when each variation has its own unique price – in this case the single variation price shows after a variation is selected.
Now, this can be good or this can be bad – it depends. So in this snippet we’ll see a quick fix to make this behavior consistent i.e. showing the variation price after selection every time, no matter the conditions.
Thankfully, it’s literally one line of PHP. Enjoy! Continue reading WooCommerce: Always Display Single Variation Price
Product tabs show on the single product page, right below the image gallery. Tab labels are “Description”, “Additional Information”, “Reviews” by default – but what if you wish to rename them into something more relevant to your users?
Here’s a simple PHP snippet you can copy/paste into your child theme’s functions.php file to immediately change the “Description” tab name – enjoy 🙂 Continue reading WooCommerce: Rename Product Description Tab Label @ Single Product Page
When you are on the single product page, and you have a non-empty product long description, a “Description” tab appears below the product images. Unfortunately, not only the tab label is “Description”, but also the tab H2 heading. This sounds and looks horrible, so here’s a way to completely remove it.
Alternatively, you can use this other snippet in order to rename it: https://businessbloomer.com/woocommerce-rename-product-description-single-product-page/ Continue reading WooCommerce: Remove “Description” Heading @ Single Product Tabs
If you use custom WooCommerce order statuses, or wish to target an order status transition that is not default (e.g. when order goes from “Processing” to “Completed”, the Completed email triggers – but what if you want to target a transition from “Processing” to “Custom Status”?), sending custom emails is quite complex.
First of all, they won’t show under WooCommerce > Settings > Emails (unless you code it, true) – second, no email will trigger. So, how do they do it? Continue reading WooCommerce: Send a Custom Email on Order Status Change
How can WooCommerce customers edit an order they just placed and paid for? I swear I looked on search engine results and other places before coming to the conclusion I needed to code this myself.
For example, a user might want to change the delivery date (if you provide this on the checkout page). Or maybe they need to change size, or make up their mind about a given product in the order.
Either way it’s shocking to me this functionality is not in a plugin – as usual if you’re interested in customizing this snippet/plugin for your specific needs feel free to get in touch.
So, let’s see how it’s done! Continue reading WooCommerce: Allow Users to Edit Processing Orders
Here’s a quick snippet you can simply copy/paste to show a “+” and a “-” on each side of the quantity number input on the WooCommerce single product page.
This snippet comes with a jQuery script as well, as we need to detect whether the plus or minus are clicked and consequently update the quantity input. jQuery might look difficult to many, but the beauty of this is that you don’t need to have a degree in jQuery – just copy/paste and see the magic happen.
Note: you will probably also require some additional CSS, as your theme might give a “float” to the quantity DIV while by default HTML buttons take inline-block. I’ve added some CSS valid for the Storefront theme below. Continue reading WooCommerce: Add Plus & Minus Buttons To Add to Cart Quantity Input