WooCommerce: Set Min Purchase Amount for Specific Product

We already studied how to set min/max WooCommerce add to cart quantity programmatically. That was an easy one. This time, I want to expand on the topic, and define a “minimum order amount on a per-product basis”.

Which, translated in plain English, would be something along the lines of “set the minimum purchase amount for product XYZ to $50”. And once we do that, I expect that the add to cart quantity does non start from 1 – instead it defaults to “$50 divided by product price”. If product price is $10, I would want to set the minimum add to cart quantity to “5” on the single product and cart pages.

Makes sense? Great – here’s how it’s done.

Continue reading WooCommerce: Set Min Purchase Amount for Specific Product

WooCommerce: “Split” Cart Table With A>Z Headings

Because “split” might not be the correct term, let me explain this better.

Let’s imagine your WooCommerce cart table is sorted by A>Z (with my WooCommerce cart sorting snippet for example). If your business model and/or UX requires it, then you might need to add “a cart table heading” for each letter:

  • A
    • Item 1 Title: “AAA”
    • Item 2 Title: “ACC”
  • B
    • Item 3 Title: “BDD”
    • Item 4 Title: “BEE”

Once again, this might sound incomprehensible so you’d better look at the screenshot below. Enjoy!

Continue reading WooCommerce: “Split” Cart Table With A>Z Headings

WooCommerce: Remove Product From Cart Programmatically

We already saw how to add a product to cart automatically, for example if you visit a specific page or if there are no products in the cart – but today we want to find out how to do the opposite: if a certain condition is met, we want to remove a product ID from the cart.

This becomes a little complex – while adding an item to cart requires just its product ID, removing it from the cart forces you to know the “cart item key”. Japanese, I know, but just copy the snippet and you’re done!

Continue reading WooCommerce: Remove Product From Cart Programmatically

WooCommerce: Bulk Dynamic Pricing (Without Plugins)

In today’s competitive retail landscape, offering the right price at the right time is crucial for driving sales and maximizing profits. But what if your pricing strategy could adapt automatically, rewarding customers who buy in bulk?

Enter bulk dynamic pricing, a powerful tool that allows you to create tiered discounts based on quantity.

We’re here looking to assign different product prices based on the quantity added to Cart, for example from quantity 1-100 price is $5, from 101-1000 price is $4.90 and from 1001 the price becomes $4.75.

This blog post will be your one-stop guide to setting up bulk dynamic pricing for your WooCommerce store – enjoy!

Continue reading WooCommerce: Bulk Dynamic Pricing (Without Plugins)

WooCommerce: Edit “Continue Shopping” Link Redirect

“Continue Shopping” appears on the Cart page when an item is added to Cart and you have “Redirect to the cart page after successful addition” enabled via the WooCommerce settings.

By default, “Continue Shopping” button redirects to the previously visited page – sometimes this makes no sense and you might want to send them back to the main shop page instead (or a custom page).

Here’s a quick snippet to do just that. Enjoy!

Continue reading WooCommerce: Edit “Continue Shopping” Link Redirect

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: Add to Cart Quantity Plus & Minus Buttons

Here’s a quick snippet you can simply copy/paste or a mini-plugin you can install to show a “+” and a “-” on each side of the quantity number input on the WooCommerce single product page and Cart page.

The custom code 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 the code or install the lightweight plugin and see the magic happen.

Continue reading WooCommerce: Add to Cart Quantity Plus & Minus Buttons

WooCommerce: Move / Remove Coupon Form @ Cart & Checkout

Coupons: the good, the bad and the ugly. WooCommerce coupon codes are great to convert more sales – but sometimes they get users to pause / stop placing the order until they find a coupon code online (you did it too, I know).

One good workaround that the internet giants such as Amazon and eBay have implemented is to hide the coupon form until an email is entered, or alternatively to move the coupon code to the bottom of the Checkout page. This is a very smart move, and gets the user to concentrate on the Cart / Checkout details before entering or searching for a coupon.

So the question is – how to remove the coupon form in the Cart page and how to move the same to the bottom of the Checkout page? Well, as usual, a bit of PHP can help us. Here’s how it’s done!

Continue reading WooCommerce: Move / Remove Coupon Form @ Cart & Checkout

WooCommerce: Disable Theme’s WooCommerce Template Overrides

A client purchased a premium “WooCommerce-ready” WordPress theme. Unfortunately, this theme comes with a /woocommerce folder, which means theme developers completely override WooCommerce template files by copying them to the folder, and customizing each of them by hand to match their design and functionality needs.

As you know from my “How To Become an Advanced WooCommerce Developer?” article, however, themes should NOT come with a /woocommerce folder – instead they should use “hooks” (actions and filters) to amend default WooCommerce plugin layouts and behavior. This is a huge problem for best seller themes and their legacy coding – and also a reason most themes break when you update WooCommerce…

So the question I asked myself was: how can I disable the entire /woocommerce folder (i.e. ALL WooCommerce template overrides) in a given theme or a single template, so that I can use the default WooCommerce ones instead?

Continue reading WooCommerce: Disable Theme’s WooCommerce Template Overrides

WooCommerce: Cart and Checkout on the Same Page

This is your ultimate guide – complete with shortcodes, snippets and workarounds – to completely skip the Cart page and have both cart table and checkout form on the same (Checkout) page.

But first… why’d you want to do this? Well, if you sell high ticket products (i.e. on average, you sell no more than one product per order), if you want to save an additional step (two steps convert better than three: “Add to Cart” > “Cart Page” > “Checkout Page” – and this is not rocket science), if your custom workflow and ecommerce objectives require you to manage Cart and Checkout all together, well, this tutorial is for you.

There is a mix of shortcodes, settings and PHP snippets you can use to make this work out of the box. And trust me, this is easier than you think.

While many developers decide to turn the checkout process into a “Multi-Step Checkout” (ehm, not sure why – the more steps the more likely it is to have a cart abandonment), in here we’ll see the exact opposite.

So, how do they do it?

Here’s the complete, easy, step by step guide to put Cart & Checkout on the same page. Give it a go, do some WooCommerce testing and tracking, and see if it converts better ๐Ÿ™‚

Continue reading WooCommerce: Cart and Checkout on the Same Page

WooCommerce: Exclude Hidden Products from Mini-Cart Counter

When you add a hidden product to Cart, either manually or programmatically, this will be displayed in the Cart, Checkout and Order details pages (I’m not sure why a hidden product behaves like that… but thankfully you can hide hidden products from the Cart/Checkout/Order page with this snippet).

Problem is, even if you hide hidden products from the Cart page, the “Mini-Cart” product counter icon or text (it depends on your theme) will still count them as products (see the screenshot below). So the question is: in conjunction with the snippet aforementioned, how do I exclude hidden products from being counted in the “menu cart” (also called Mini-Cart Widget)? Continue reading WooCommerce: Exclude Hidden Products from Mini-Cart Counter

WooCommerce: Hide Checkout Fields if Virtual Product @ Cart

If you sell downloadable/virtual products and need to simplify your WooCommerce checkout when such product type is in the Cart, you’ve come to the right place!

Here’s a simple snippet, as well as a handy mini-plugin, that checks if there are only “virtual” products in the Cart and hides all the billing fields and order notes (except name and email).

The mini-plugin also allows you to enable this for free virtual orders only, and to move the relevant billing fields under a toggle instead of removing them all together.

Enjoy!

Continue reading WooCommerce: Hide Checkout Fields if Virtual Product @ Cart

WooCommerce: Remove Mini-Cart Widget Dropdown

Less is more (sometimes). On this same website, I’m already forcing max 1 product in the Cart and automatically redirecting users to Checkout upon add to Cart. On top of that, I’ve disabled WooCommerce cart fragments for performance reasons.

As a result, I definitely don’t need the whole “Mini-Cart Widget Dropdown Content”. To test, try to “hover” onto the shopping cart icon on the top right, and you’ll notice there is no cart dropdown.

Well, this is how it’s done – I love when a complex thing is fixed with one simple line of PHP!

Continue reading WooCommerce: Remove Mini-Cart Widget Dropdown

WooCommerce: Add Product to Cart When Visiting a Specific Page

We’ve already seen how to add a product to cart automatically when a user enters your website. However, I needed a different functionality on this same website, and specifically I wanted a product added to cart only when a user like you visits a specific WordPress page ID.

If you wish to test, go to my free video tutorial page called “How to Customize the WooCommerce Single Product Page“. As soon as the page loads a product is magically added to cart, so that the WooCommerce Checkout on that same page is populated with the hidden item. If you go to my Cart page right after visiting that landing page, you can verify there is a product in there.

So, how did I do it? Continue reading WooCommerce: Add Product to Cart When Visiting a Specific Page

WooCommerce: How to Hide “Shipping Calculator” Fields @ Cart

The “Shipping Calculator” can be enabled via the WooCommerce settings in order to give the user a way to calculate their shipping fees before getting to the Checkout Page. Usually they fill out the country, state, city and postcode form fields and click on “Update Totals” in order to calculate the shipping.

However, what if you only calculate shipping based on country? Or what if you only charge by zip code / postcode? In this case, you will need to hide the input fields you don’t need, and make UX better.

Well, here are some WooCommerce filters you can use from WooCommerce version 3.4 onwards to hide the fields you like (apart from country, which is mandatory).

Continue reading WooCommerce: How to Hide “Shipping Calculator” Fields @ Cart

WooCommerce: Sort Cart Items Alphabetically A>Z

Your WooCommerce shopping cart might look messy when it contains many products. Your specific business, besides, might require you buy “Part 1” first and “Part 2” after.

A way to tidy up the WooCommerce shopping basket is – for example – to sort products based on their title, from A to Z. As usual, this can be done with a few lines of PHP, even if you have no clue about coding… feel free to copy, paste, and enjoy the snippet ๐Ÿ™‚

Continue reading WooCommerce: Sort Cart Items Alphabetically A>Z

WooCommerce: Automatically Update Cart on Quantity Change

There is a lot of literature online that solves this UX problem – so in this article let’s see if I can give you a simplified, working, updated version.

So, do you hate the “Update Cart” button too? Yes, the one you have to click after you update the quantity of a product in the cart…

Well, you’re in the right place: a simple PHP function, two lines of JQuery, one line of CSS (or a mini-plugin) and the result is pretty straight forward!

Continue reading WooCommerce: Automatically Update Cart on Quantity Change

WooCommerce: How to Edit Product Prices in Bulk?

I’m pretty sure that during one of those Black Friday sales all you wanted to do was to apply a bulk discount to your WooCommerce products without having to generate a coupon code.

Let’s not forget that despite coupons are trackable and you can assess your marketing efforts with their usage statistics, requiring the user to take one additional step at checkout (entering the correct coupon code) reduces your sales conversion rate (the same applies with useless checkout fields by the way – less work to do, higher conversion rate).

In today’s post, we’ll see what are the 3 options I recommend in order to apply bulk store discounts. It pretty much depends on your product types (simple vs variable for example) and whether you want to do this via the settings or with a little bit of PHP.

Continue reading WooCommerce: How to Edit Product Prices in Bulk?