WooCommerce: Add a WordPress Customizer Setting

If you’ve taken the ConfigureWoo online course, you’ll know that WooCommerce adds its own “WordPress Customizer” section called “WooCommerce”, indeed. From there you can manage some settings such as the store notice, product images, checkout fields and so on.

What if you want to add your own settings, and let yourself or your client toggle options or type input values, so that this can be applied to your current WooCommerce website? Well, that’s quite doable, so in this post we’ll see how they do it. Enjoy!

Continue reading WooCommerce: Add a WordPress Customizer Setting

WooCommerce: Update Order Field Value After a Successful Order

We’ve already seen how to update user meta after a successful order, but this time our goal is to “correct” or “edit” a checkout field value after the order is placed.

You could for example add a phone number prefix if it’s not there, and by doing so, correct the phone number before sending it to your courier. Likewise, you could remove punctuation, trim spaces, format accents, and do any manipulation you desire on whatever order field.

So, here’s how they do it. Enjoy!

Continue reading WooCommerce: Update Order Field Value After a Successful Order

WooCommerce: Checkout Test Automation 101

E2E Checkout Testing

Testing the WooCommerce checkout is extremely important for your ecommerce business.

Every time you install a new plugin or update WordPress you might run into issues: for example, the cart and payment pages could stop working until you fix the problem.

You donโ€™t want to lose sales and undermine your website reputation, do you? So you must test all the WooCommerce processes on a regular basis, also called “end to end” (E2E) testing.

But how can you do that without wasting too time?

Spoiler alert: simply create an automated test, and let the robot test your WooCommerce website on a regular basis, so that you never have to worry about doing it manually.

Luckily for you, there are some great tools – such as the two you will soon read about – and WooCommerce professionals that can do it for you on a daily or whatever basis.

Here’s your quick introduction to setting up your checkout test automation.

Cheers to a checkout page that works 365 days a year.

Continue reading WooCommerce: Checkout Test Automation 101

WooCommerce: Multiple Stripe Accounts (Solved)

The WooCommerce plugin fully integrates with the WooCommerce Stripe Payment Gateway plugin, developed by Automattic itself. With this free plugin, Stripe payment gateway can be enabled via the WooCommerce settings and once your Stripe “Live Publishable Key” and “Live Secret Key” are set, your WooCommerce shop is ready to take credit card payments powered by Stripe.

Now, there is some documentation online which explains, with a little bit of code, how to switch Stripe account programmatically and conditionally i.e. for a given product ID or product category slug – same as what we’ve seen recently with PayPal Standard (here’s the tutorial for using different PayPal accounts inside a single WooCommerce installation). For example, you may want to use a Stripe account for digital sales and a different one for physical products.

Unlike PayPal Standard, however, online documentation and snippets are quite out of date and require, often, to create a custom Class which is always a difficult task in PHP programming. Thankfully, there are new WooCommerce Stripe hooks and therefore it’s possible to use different / multiple Stripe accounts in a single WooCommerce installation.

Please read the disclaimer below and – only then – enjoy!

Continue reading WooCommerce: Multiple Stripe Accounts (Solved)

WooCommerce: Multiple PayPal Accounts (Solved)

The WooCommerce plugin comes with its own free version of PayPal Standard. PayPal can be enabled via the WooCommerce settings and once your PayPal email is entered your WooCommerce shop is ready to take PayPal payments.

Now, there is extensive documentation online which explains, with a little bit of code, how to switch PayPal account programmatically and conditionally i.e. for a given product ID or product category slug. For example, you may want to use a PayPal account for consulting services, another for online courses and another for physical products.

By adding this simple code and hooking into woocommerce_paypal_args is indeed possible to use different / multiple PayPal Standard accounts in a single WooCommerce installation.

However, there is an outstanding problem with “IPN Validation“: once you tell WooCommerce to use a different PayPal email account, the WooCommerce order is correctly placed, but its status goes “on hold” because IPN validation on the PayPal end fails (and that’s because you’re using a different PayPal account).

So, here’s the fully working version, included the IPN validation fix. Please read the disclaimer below and – only then – enjoy!

Continue reading WooCommerce: Multiple PayPal Accounts (Solved)

WooCommerce: Maxlength and Minlength for Checkout Fields

If you’re familiar with HTML, you can add “maxlength” and “minlength” attributes to an input field in order to force its value to be min X and max Y characters long. This is all good and easy, so we might as well see what happens on the WooCommerce Checkout page once we apply such attributes to a given custom field.

Spoiler alert: maxlength works, while minlength does not. Hence, forcing a given checkout field to have a minimum length is actually quite impossible, unless we validate the posted data (a field input value that is not long enough) once the checkout is submitted. That’s a bummer, and in this article I will also explain how to contact WooCommerce so they can improve a functionality / fix a bug.

Enjoy!

Continue reading WooCommerce: Maxlength and Minlength for Checkout Fields

WooCommerce: How to Customize Checkout For Conversions

I had the honor to speak at WCEU 2020 thanks to WooCommerce, who hosted me in their Sponsor track. It was a short and sweet lightning talk on the first day (Friday), called “Customizing The WooCommerce Checkout To Improve Conversions“, followed by a live coding session on Saturday.

Here’s the video recording of the lightning talk, as well as a few PHP and CSS snippets you can copy/paste to improve your WooCommerce Checkout and immediately expect an increase in conversion rate. So, enjoy the video and then go test the snippets you find below!

Continue reading WooCommerce: How to Customize Checkout For Conversions

WooCommerce: Show SKU @ Cart, Checkout, Order & Emails

When SKU matters to the end user, displaying it in the Cart page, Checkout page, Thank you page, My Account View Order page and Order Emails under the item name is a must.

Ideal for B2B businesses and international brands, this simple customization can help you learn how to add any sort of content under the Cart/Checkout/Order item names. Simply use the same hook and try “getting” something different than SKU with this guide. Enjoy!

Continue reading WooCommerce: Show SKU @ Cart, Checkout, Order & Emails

WooCommerce: Dynamically Hide / Show Checkout Field

We already saw a lot of examples e.g. hiding checkout fields if a product is virtual or hiding checkout fields if a checkbox is manually checked… but this time I want to hide a field dynamically – automatically – based on whether another checkout field is empty or has a specific value.

In this example, I will demonstrate how to hide the “billing phone” if “billing company” is empty or no information is entered. Of course, you also have to disable the mandatory attribute for the billing phone from the Customizer settings, otherwise checkout validation will fail. You can readapt this snippet to any other checkout field combo – just identify the input IDs and change jQuery accordingly. Enjoy!

Continue reading WooCommerce: Dynamically Hide / Show Checkout Field

WooCommerce: Move Order Notes @ Checkout

We already saw how to hide Order Notes on the WooCommerce checkout page. This time around, however, our goal is to “move” them – and specifically remove them from their default position (under the shipping form) and add them back under the billing form.

As you can imagine, this is a combo snippet: (1) we remove them (and we’ll use the snippet as per the link above) and (2) we create a new billing field. Finally, (3) we also need to “save” this new field value into the original order notes custom field meta.

If this is difficult to understand don’t worry – just copy/paste the snippet into your functions.php and see magic happen. Enjoy!

Continue reading WooCommerce: Move Order Notes @ Checkout

WooCommerce: Add Shipping Phone @ Checkout

I’m surprised WooCommerce doesn’t offer this field out of the box. Most ecommerce websites actually require a shipping phone to organize delivery and communicate with the end customer in case there are problems.

Thankfully, there is a hook (filter) for that. It’s called “woocommerce_checkout_fields” and can be used to remove, move or add checkout fields quickly. And here’s how to add, for example, a new shipping field called “shipping_phone”. Enjoy!

Continue reading WooCommerce: Add Shipping Phone @ Checkout

WooCommerce: Add Upsell Area @ Checkout Page

If you want to increase your AOV (Average Order Value), you can definitely start from the WooCommerce Checkout page.

A client asked me to place a “Donation Area” close to the “Place Order” button (so at the bottom of the page, once customers are ready to pay) to drive more awareness around this add-on. All I had to do was creating hidden products with a donation value, use my own “Custom Add to Cart URL” guide to create add to cart links and print an HTML box right above the checkout button by using my WooCommerce Visual Hook Guide for the Checkout Page. Enjoy!

Continue reading WooCommerce: Add Upsell Area @ Checkout Page

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: Display Required Field Errors “Inline” @ Checkout

If you’re familiar with the upcoming Gutenberg editor, you’ll know there have been a million doubts in regard to accessibility. So, accessibility matters – and WooCommerce has a few issues as well.

One interesting accessibility fix is the error notification system on the checkout page. Yes, the missing fields error show on top of the page when trying to place an order, but once you scroll down to fill them out again you might need a reminder of which field is missing without having to scroll back up to check the error.

This is quite difficult to explain, so take a look at the screenshot. The suggestion here is to also add “inline” error notifications (“XYZ is a required field“) right above each field, so that the user knows exactly what to do. So, let’s see how it’s done.

Continue reading WooCommerce: Display Required Field Errors “Inline” @ Checkout

WooCommerce: How to Blacklist Scammers, Emails, IP, Phones?

A WooCommerce email notifications pops up – yet another new order, money, revenue, happiness. However, hold on a second – money is not technically in your bank account until you’re forced to give a refund. Even worse, until you realize not only you had to give a refund, but also getting the item back costs you a fortune. And who knows how many times this is going to happen, mostly when you ship physical products.

Fortunately, there are ways in WooCommerce to blacklist customers, deny purchasing from specific countries, block certain IP addresses and do whatever you can to save money.

In the era of Amazon and online shopping we constantly hear of scams and frauds, so this is definitely a topic that shouldn’t be underestimated. A small plugin investment or a few lines of code could actually make a big difference.

Besides, choosing the correct online payment methods (which should give you some sort of anti-fraud out of the box) and avoiding offline payments (bank transfer, cash on delivery, check) are important measures you should already have in place.

So, moving beyond the actual online payments, there is something else we could do to stop scammers placing an order (yes, even before paying or trying to pay). Prevention is better (and more affordable) than cure, right?

I’ve put together a list of WooCommerce plugins and settings you should look into from today on. And sooner rather than later. Enjoy ๐Ÿ™‚ Continue reading WooCommerce: How to Blacklist Scammers, Emails, IP, Phones?

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