WooCommerce: Add Custom Field to “Bulk Actions” > “Edit”

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”

WooCommerce: Checkbox to Disable Related Products Conditionally

Here’s how you can display a “checkbox” in the product edit page in order to hide the Related Products section in case this is checked. This is something you can also reuse to hide other sections in the same way – for example you might need to hide product tabs or featured image in certain cases.

I’ve coded this in 15 minutes for a client so why not sharing it with you too? Here’s the full snippet, enjoy!

Continue reading WooCommerce: Checkbox to Disable Related Products Conditionally

WooCommerce: Product Add-Ons (Without a Plugin!)

WooCommerce product add-ons are custom input fields that show on the single product page. They’re called “add-ons” as you can add a product personalization or an upsell (at a cost of course).

For example, you can display a text input to print something on the product. Or radio buttons to select different kinds of product upgrades. Or a checkbox to upsell gift wrapping.

Either way, and of course, there are plugins for that. But first, I want to give you a tutorial to code this by yourself (case study: global custom input text field and no surcharge), so that you can learn something new. Enjoy!

Continue reading WooCommerce: Product Add-Ons (Without a Plugin!)

WooCommerce: Add Second Description @ Product Category Pages

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

WooCommerce: Show Empty Product Categories

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

WooCommerce: Add Custom Page @ WordPress Admin Dashboard

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 “sidebar link” to the WordPress Admin Dashboard.

This is a very interesting topic and in the same way you can hide elements such as metaboxes, 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 Custom Page @ WordPress Admin Dashboard

WooCommerce: Flat Rate Calculation Based on Weight (Without a Plugin!)

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!)

WooCommerce: Hide “No products were found matching your selection”

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 or when you decide to completely hide the shop page products for some reason, especially for custom built layouts.

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”

WooCommerce: 10 Easy Snippets to Increase Your Sales

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: Hide “Thanks for shopping with us” @ Emails

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, you should have the freedom to remove or edit them.

So, you have two choices: doing that via the email settings, or by “translating” those strings via PHP. Enjoy!

Continue reading WooCommerce: Hide “Thanks for shopping with us” @ Emails

WooCommerce: Remove “Metaboxes” @ Product Edit Admin Page

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

WooCommerce: Set Default Dashboard Login Page to “Products”

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”

WooCommerce: Send Email to Admin Every 3 Hours (Cron Job)

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)

WooCommerce: Disable Update Notifications @ WordPress Dashboard

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

WooCommerce: Always Show Single Variation Price @ Single Product

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 Show Single Variation Price @ Single Product

WooCommerce: Rename Product Description Tab Label @ Single Product Page

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