WooCommerce: Remove “Create shipping label” Ad @ Single Order Admin Page

Here we go again. It feels like the WooCommerce plugin has become the same as some of those free extensions you get from the repo that fill up the WordPress dashboard with ads, notices and banners.

This time around, let’s get rid of the “Print discounted shipping labels with a click. By clicking “Create shipping label”, WooCommerce Shipping will be installed and you agree to its Terms of Service. Create shipping label” banner that displays at the top (!) of the single order admin page when the status is processing or completed and shipping is required (see screenshot below).

Long live a world without ads!

Continue reading WooCommerce: Remove “Create shipping label” Ad @ Single Order Admin Page

WooCommerce: Prevent Orders From Blacklisted Email Addresses

In some cases, you may need to block certain customers from completing orders on your WooCommerce store.

This could be due to fraud prevention, policy violations, or simply wanting to prevent repeat offenders from making purchases. Thankfully, WooCommerce provides the flexibility to implement an email blacklist with just a few lines of code.

In this tutorial, I’ll show you how to add a simple email blacklist using a custom function that checks the customer’s email at checkout. By adding these 8 lines of PHP to your theme’s functions.php file, you’ll be able to prevent orders from specific email addresses efficiently. Enjoy!

Continue reading WooCommerce: Prevent Orders From Blacklisted Email Addresses

WooCommerce: Sale End Date Countdown Timer

Are you tired of the same old “Sale!” badge on your WooCommerce products? Want to create a more engaging and dynamic shopping experience for your customers?

In this blog post, we’ll guide you through a simple PHP/JS customization that replaces the static “Sale!” badge on the WooCommerce Single Product page with a captivating countdown timer. This will not only add excitement to your product page but also encourage customers to make a purchase before the sale ends.

Get ready to elevate your WooCommerce store and boost your sales with this effective customization. Enjoy!

Continue reading WooCommerce: Sale End Date Countdown Timer

WooCommerce: Fit All Settings In One Page

In the world of WooCommerce, customization is crucial for creating a unique online store. However, juggling numerous WooCommerce settings across multiple pages can be tedious.

Imagine a solution that simplifies this process by consolidating all your WooCommerce options into a single, easy-to-use interface.

This tutorial will give you a possible approach and try to fit all WooCommerce Settings into a single screen (so, on the same page, you can edit the general, products, shipping, payments, advanced, etc. options).

Enjoy!

Continue reading WooCommerce: Fit All Settings In One Page

WooCommerce: Custom “Empty Cart” Button

A dedicated “Empty Cart” button can significantly streamline the customer journey on your WooCommerce website.

Yes, you can manually change the product quantities to 0 on the cart page, or click on the “remove item” icon for each product… but having a button that can do all that could be a time saver, especially for B2B WooCommerce customers.

This post will guide you through creating a custom empty cart button. We’ll cover a code-based solution that uses jQuery to listen to button clicks and Ajax to trigger the empty cart function.

Enjoy!

Continue reading WooCommerce: Custom “Empty Cart” Button

WooCommerce: Add Checkout Fee Based On Shipping Class

Whether you’re dealing with bulky items, fragile goods, or specific shipping items, you can leverage WooCommerce’s flexibility and implement a fee structure that accurately reflects shipping complexities, improves profit margins, and enhances overall order management.

This tutorial gives you a practical solution – dynamically adding checkout fees based on whether a given shipping class is in the cart.

Enjoy!

Continue reading WooCommerce: Add Checkout Fee Based On Shipping Class

WooCommerce: Hide Free Products [Code Snippet]

Are free products cluttering your WooCommerce store? Or are they so many, that you have no intention of manually setting them to “catalog visibility: hidden” one by one and need a proper shortcut?

Well, this guide will walk you through effective methods to conceal them, enhancing your store’s overall aesthetic and user experience.

Discover how to strategically hide $0 products from the shop / category / archive pages using WooCommerce custom code or dedicated plugins – enjoy!

Continue reading WooCommerce: Hide Free Products [Code Snippet]

WooCommerce: Edit Custom Field @ Order Admin

Adding a custom field to your WooCommerce checkout is a breeze. It’s a fantastic way to collect extra information from your customers. It could be a custom Billing field, a Shipping field, or a completely unrelated custom field.

But while you can easily view the custom field data in the backend, editing it directly from the order admin is a frustratingly locked feature. This presents a significant challenge for businesses needing to modify order details post-purchase.

Luckily, a bit of custom code can fix this, giving you the flexibility and control you need to manage your orders effectively.

Let’s dive in and explore how to overcome this hurdle. Enjoy!

Continue reading WooCommerce: Edit Custom Field @ Order Admin

WooCommerce: Get Customer ID From An Email Address

Customizing your WooCommerce store via PHP can involve a variety of tasks, from personalizing orders to managing customer interactions. Often, you might need to find a specific customer’s information, but all you have is their email address.

For example, on this same website, I have custom contact forms that give me a name and an email address upon submit. What if I need to check if the email address is an existing WooCommerce customer who has placed some orders?

Well, the PHP below will give you a quick way to “calculate” the customer ID if you only have an email address. It’s then easy to use the result in a custom calculation or core function, such as wc_get_orders().

Enjoy!

Continue reading WooCommerce: Get Customer ID From An Email Address

WooCommerce: Notify Admin For Product Reviews But Not For WordPress Comments

WooCommerce product reviews are, actually, WordPress comments.

When you install WordPress, comment notifications for admins are turned on. You can choose to receive emails for all new comments, or only for comments that require moderation (haven’t been approved yet).

The problem is that if your site gets a lot of spam comments, you might be bombarded with emails. Even with legitimate comments, constant notifications can be overwhelming.

So what if we disable WordPress comment notifications all together, while we keep them enabled for WooCommerce product reviews only?

This is what we’ll code today – enjoy!

Continue reading WooCommerce: Notify Admin For Product Reviews But Not For WordPress Comments

WooCommerce Visual Hook Guide: Cart Page (Block Version)

I’ve put together a visual hook guide for the WooCommerce Cart Block (you can find the legacy shortcode version here).

Please note – as of the date above, you can’t really customize the Cart Block via PHP (unless you use the workaround below).

If you need to personalize the Cart page, move elements around, hide default elements, add custom content, you can play on the Edit Page and do the usual manual work with blocks: you can move them (e.g. you can move the coupon form to the bottom), remove them (e.g. you can remove the cross-sells block), place blocks in between default blocks (e.g. you can add some text above and below the “Place Order” button), etc.

But if you wish to do that via code (custom plugin, snippet, child theme), then you must revert to the shortcode version – unless, once again, you get to understand my workaround as per the below visual hook guide.

So, at least for now and until WooCommerce decides to release actions and filters for us developers, let’s see how to find WooCommerce Cart Block hooks quickly and easily by seeing their actual location.

Once you’ve picked your hook, all you need to do in your custom code is “add_action(‘hook_name’,’custom_function’);” and you can place your personalized content in that exact position within the WooCommerce Cart Block.

Enjoy!

Continue reading WooCommerce Visual Hook Guide: Cart Page (Block Version)

WooCommerce: Set Product Upsells Programmatically

Looking to boost your WooCommerce store’s average order value?

Upsells are a powerful tool, but manually entering them via the Edit Product page can be tedious.

This tutorial dives into the world of programmatic WooCommerce product upsells, empowering you to leverage code for a dynamic and data-driven upsell strategy.

In under 5 lines of PHP, we’ll guide you through the process of setting up upsells using code, unlocking greater control and personalization for a seamless customer experience that maximizes your sales potential. Enjoy!

Continue reading WooCommerce: Set Product Upsells Programmatically

WooCommerce: Remove Second Item When Item Removed From Cart

This approach might be relevant for specific promotional offers (e.g. BOGO) or custom coded product bundles. In this case, you may want to remove a second item from the cart – programmatically – once a product is removed.

Of course, a relationship is needed between the two cart items via custom cart item meta data (for example, the “bundled” item will need to specify the ID of the “base” product in the cart within some custom cart item meta, so that we can “listen” to its removal).

Alternatively, you can check if a pair of product IDs are in the cart, and if one of them is removed, we’ll automatically remove the other – this is the case study we’ll go through today as it’s much easier.

Enjoy!

Continue reading WooCommerce: Remove Second Item When Item Removed From Cart