WooCommerce: Change Add to Cart Quantity into a Select Drop-down

The default WooCommerce Add to Cart “Quantity Input” is a simple input field where you can enter the number of items or click on the “+” and “-” to increase/reduce the quantity.

A freelance client hired me to turn that input into a “Select” drop-down. For their audience and UX requirements, it makes sense to let their customers choose the quantity from a drop-down instead of having to manually input the number.

Online there are complex snippets, but I decided to make things easier. The WooCommerce function responsible to generate the quantity input is called “woocommerce_quantity_input“.

Luckily, it’s a pluggable function – which means we can simply add this exact same function name to our child theme’s functions.php to completely override it. Enjoy!

Continue reading WooCommerce: Change Add to Cart Quantity into a Select Drop-down

WooCommerce: Check if Product ID is in the Cart

Here’s the story: I’m working with one of my freelance clients and I need to show certain content in the Checkout (a product-specific “Terms and Conditions”) if such product is in the Cart.

Now, I’ve always looked for products in the Cart by “looping” through the Cart with a foreach (here, for example: Apply a Coupon Programmatically if a Product is in the Cart). But as I said, after some random research, I found out about another magic WooCommerce function: “find_product_in_cart()“. Which means finding a product in the Cart doesn’t require custom loops or complex PHP… it’s just a “one liner”. Enjoy!

Continue reading WooCommerce: Check if Product ID is in the Cart

WooCommerce: Force Cart to Specific Amount (Deposit)

Here’s a very simple snippet that achieves a very complex task – what if you wanted to force your Cart to charge a deposit or a fixed fee, no matter the cart total?

Well, thankfully WooCommerce is pretty flexible and a lot of workarounds can be found.

In this case, we will study two possible solutions: (1) a negative “cart fee” to make the total become e.g. $100 and (2) a filter to completely override the calculated cart total e.g. $100.

Sounds like Japanese? Great – here’s why you’re on Business Bloomer. Copy the snippet, apply it to your test WooCommerce site and see the magic happen – without knowing anything about coding!

Continue reading WooCommerce: Force Cart to Specific Amount (Deposit)

WooCommerce: Add “Confirm Email Address” Field @ Checkout

A correct email address is worth a thousand dollars, some ecommerce expert would say 🙂 So, you don’t want your WooCommerce checkout visitors to mess up with that, do you?

What about adding an “Email Verification” field? In this way, we can make sure they double check their entry – and also show an error message in case they don’t match!

Let’s see how I implemented this for a freelancing client of mine – I’m sure you will be grateful!

Continue reading WooCommerce: Add “Confirm Email Address” Field @ Checkout

WooCommerce: Edit Add to Cart Default, Min, Max & Step Product Quantity

Yes, there are many plugins that already achieve this. But my goal at Business Bloomer is to save you from plugin conflicts, delicate updates and to make you learn some PHP.

So, here’s how you can add, with a few lines of PHP, a minimum, maximum, increment and default value to your Add to Cart quantity input field on the single product and cart pages. Who knew it was this easy?

Continue reading WooCommerce: Edit Add to Cart Default, Min, Max & Step Product Quantity

WooCommerce: Change No. of Thumbnails per Row @ Product Gallery

WooCommerce 3.0 completely revolutionized the single product page featured and product gallery images, including their PHP. If, in the past, a simple filter from WooCommerce was enough to change the number of thumbnails per row (https://docs.woocommerce.com/document/change-number-of-thumbnails-per-row-in-product-galleries/), this does not exists anymore 🙁

So, let’s see how we can achieve this in WooCommerce 3.0 and above. For this example we’ll use two themes – in fact some theme-specific CSS is also needed together with the PHP.

Continue reading WooCommerce: Change No. of Thumbnails per Row @ Product Gallery

WooCommerce: Product List View @ Shop

Interesting, isn’t it? This has been on my to-write list for ages, so today I want to show you my first attempt at turning the Shop page into a list/table of products as opposed to the default grid.

This is especially suitable to B2B WooCommerce shops, or for those websites where customers don’t really need to see huge product images and are used to order “from a product form”.

Let’s see how I did this – I will try to comment my PHP as much as possible so you can understand my strategy. Enjoy!

Continue reading WooCommerce: Product List View @ Shop