Here’s yet another snippet I use on A Piece of Sicily, my Sicilian marketplace, to make sure vendors can only select one product category for a given product. This is to make sure they make the best possible choice and also to avoid confusion and multiple listing.
Of course, the same can be used on your own WooCommerce install, in case you wish to limit the number of categories that can be assigned to each product (inside the snippet, you can even change “1” to “whatever number” and therefore define your own “max” e.g. max 2 categories).
This time I can’t make you “see” the customization as we’re in the backend, so please take a look at the screenshot below. Enjoy!
Continue reading WooCommerce: Force Max 1 Category Per Product
If your shipping rates depend on product weight, it is very likely you’ve forgotten to add weight to ALL your products. In this way, some shipping rates may be underestimated on the WooCommerce Checkout page.
So, here’s how to print a notice on the WordPress Dashboard > Products screen with a list of products that have no weight, together with the links to edit them quickly.
This is a handy snippet you can reuse for other case scenarios such as easily finding products with no dimensions, no prices, no images, no custom field value, or even a specific weight or given price. Enjoy!
Continue reading WooCommerce: Find Products With No Weight @ WP Admin
The default WooCommerce Dashboard Products page (/wp-admin/edit.php?post_type=product page) shows the list of products in a table. Default fields are: Image, SKU, Stock, Price, Categories, Tags, Featured and Date.
Sometimes, these columns are not enough and you need more. For example, you might want to quickly take a look at a product custom field, such as “visibility” (whether the product is hidden or not).
So, here’s the snippet for that. Of course, you can adapt it to show your own custom field, an ACF field or whatever product-related information you require.
Continue reading WooCommerce: Add Product Table Columns @ Admin
As you know, one of the product bulk edit methods comes with WooCommerce out of the box. It can be found under “WP Dashboard” > “Products” > “Bulk Actions” > “Edit”. For example, you can decrease all prices by 10%, or bulk assign a new product category.
However, if you added a custom product field such as RRP, this won’t show automatically there in the bulk edit form – you’ll therefore need to add it via code. Thankfully, WooCommerce gives us a “hook” we can use to display the input in the bulk edit form. After that, another PHP function will be used to save and store the value.
Easy as pie! Just copy & paste into your functions.php. Enjoy 🙂
Continue reading WooCommerce: Add Custom Field to “Bulk Actions” > “Edit”
In terms of SEO, if you’re trying to rank your product category pages, you really need to make the most of the default WooCommerce product category “description” and “thumbnail”. Most themes, if compatible with WooCommerce, will show this content right below the product category name and above products.
Nothing new so far. But what if you want to add another piece of content below the category products while also keeping the default description? Well, we’d need to customize the edit category page and display a new text editor field, save it, and finally display it where we want. So, here’s how they do it!
Continue reading WooCommerce: Add Second Description @ Product Category Pages
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
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
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”
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
The WooCommerce Orders Table, which can be found under WP Dashboard > WooCommerce > Orders, provides us with 7 default columns: Order – Date – Status – Billing – Ship to – Total – Actions. This is used by shop managers to have an overview of all orders, before eventually clicking on a specific one.
So the question is: how can we display additional columns to that same orders table, so that we can immediately visualize an order custom field, a specific product contained in the order, or anything order-related that can be “calculated” once we have access to the $order variable? Continue reading WooCommerce: Add Column to Orders Table @ WP Dashboard
If you go to WordPress Dashboard > Products you will find default product admin filters such as “Select a category”, “Filter by product type”, “Filter by stock status”. What if you want to add more custom filters to let your shop managers find products easily?
For example, you could add “Filter by product tag” (“product tags” are one of the two default WooCommerce “taxonomies” together with “product categories”). Or, if you use custom taxonomies such as product brands, you could add a “Filter by product brand” dropdown.
Thankfully this is super easy – and here comes the proof 🙂 Continue reading WooCommerce: Display Custom Filters @ WP Dashboard > Products
You want your website visitors to checkout fast, pay you faster and receive their item quickly. However, speed matters for us WooCommerce store owners as well.
By looking at this year’s time-sheets for my own business, about 50% of the time was spent between marketing and admin – and the “admin” part is the one we’re tackling today.
If you run a busy WooCommerce shop with hundreds of products, you probably noticed how annoying it is to edit products one by one.
Yes, the WooCommerce admin dashboard allows us to do certain bulk edits a la WordPress, however you must play with the “screen options” and also the filtering is not good enough.
On the other end, as WooCommerce managers we’re probably more familiar with Excel-alike spreadsheets where all our products are editable with a single click in a specific cell.
Good news is there are plugins that can make your life easier, your admin time more efficient and your product management simpler. And today we’re taking a look at the best options. Continue reading WooCommerce: How to Bulk Edit Products?
Ever wondered how you could add a new product type to WooCommerce admin (on top of the default Simple, Variable, Grouped and External)?
Well, while I was coding this for a client I found a lot of literature online – but nothing really worked for the latest WooCommerce release.
So, here’s the working fix!
Continue reading WooCommerce: How to Create a Custom Product Type
You’re filling out your tax reports… and then find out WooCommerce doesn’t give you this calculation by default!
Don’t cry 🙂 Today I’ll show you a quick snippet to calculate that in a second. Feel free to change the year, the country and the states in the snippet. Continue reading WooCommerce: Calculate Sales by State
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
It’s pretty easy to add another custom menu to your WooCommerce pages via PHP. For example, you might want to add a list of Product Category links, and manage this through the default “Appearance > Menu” in the WordPress dashboard. Continue reading WooCommerce: Add WP Menu to WC Pages via PHP
In previous WooCommerce versions, new customers could access the WP Admin black bar after purchase. Now this seems fixed.
Still, what about other user roles, and what if you want to override this default behavior? Well, here’s a quick snippet for you – feel free to use it in your own WooCommerce site. Enjoy!
Continue reading WooCommerce: Hide/Show The WP Admin Bar
Hello WooCommerce Customizers!
Today is episode #18 of my “18 snippets in 18 days” challenge… yes, I’ve made it! In the last 18 days I’ve added a good amount of WooCommerce code tutorials and I hope you appreciate the effort!
If you haven’t shared on social media or left a comment yet, it is time to spread the word and share the WooLove right now 🙂
Today’s goal is quite atypical, but I love that. A client needed to see on the frontend, almost in real time, who bought which product and their names. The sell Yoga classes via WooCommerce and simply needed to make sure who’s on what class! Continue reading WooCommerce: Display Sales to Admin @ FrontEnd