WooCommerce: Create Order From Contact Form Submission

So, I’ve built my own event management system for WooCommerce.

My objective was to embed a form on the event registration page, and then programmatically create a free WooCommerce order for that customer – so I can track the number of attendees (orders) and follow up with email automations (customers).

You can already see the system in action on the How to Contribute to WooCommerce Core” event page: you can clearly see an email input and a “Register Now” button inside the “You’re invited” section. That’s the form – actually a Fluent Forms plugin contact form.

And then there is a simple snippet that hooks into the Fluent Form submission, and conditionally generates a WooCommerce order.

In this post, you’ll learn about a quick way to create a Fluent Forms form on your WordPress site, about the “fluentform/validate_input_item_input_email” hook, and finally about the wc_create_order() WooCommerce function that, of course, let us generate an order automatically. Enjoy!

Continue reading WooCommerce: Create Order From Contact Form Submission

WooCommerce: Preparing Your Site for Black Friday / Cyber Monday

Black Friday and Cyber Monday (BFCM) are just around the corner. Is your WooCommerce site prepared? I hope so!

While time is running out, there are a number of things you can do to get ready. In this post, we’ll cover eight of the most important ones.

The potential of a Black Friday / Cyber Monday deal shouldn’t be underestimated. Indeed, many eCommerce sites report that a significant percentage of their annual revenue comes from sales during this brief period of time. 

Additionally, it’s important to remember that nearly all businesses run a BFCM sale, which means that anyone who doesn’t have an offer is missing out.

Before we jump into the eight important things you can do, a final note: failing to prepare may cost you a serious amount of missed revenue. Amazon, for example, stands to lose $13.22 million per hour of downtime! While that’s an extreme example, it is a reminder that downtime should be avoided as much as possible during once-a-year sales events.

Continue reading WooCommerce: Preparing Your Site for Black Friday / Cyber Monday

WooCommerce: Getting Started As An Expert – A Complete Guide

If you’re looking to start your own ecommerce store, no platform does it better than WooCommerce.

WooCommerce is your path to online selling success. It’s a flexible, open-source e-commerce plugin specifically built for WordPress websites. 

From setting up and customizing your shop, to mastering orders and sales tracking, this complete guide will walk you through becoming an accomplished WooCommerce expert.

Read on for all the info you need to get the ball rolling!

Continue reading WooCommerce: Getting Started As An Expert – A Complete Guide

WooCommerce: Switch User Role If Customer Spent More Than $

Many businesses allow their customers to unlock benefits and discounts once a certain spend amount is reached.

Think about a “VIP club“, where members can get an exclusive 20% discount once they reach $1,000 worth of store purchases.

Let’s also say that, when the threshold is reached, you want to promote users from the “customer” role to a custom “VIP customer” role, so that it’s easier to segment your email marketing and overall targeting.

Well, the snippet below will allow you to switch user role once a certain spend is reached. The function will trigger when a customer places an order, so that we can calculate the total spent, and possibly switch their role. Enjoy!

Continue reading WooCommerce: Switch User Role If Customer Spent More Than $

WooCommerce: 7 Different Ways to Run a Survey

Understanding your audience’s needs and preferences is a key component of any successful WooCommerce business.

Surveys are perfect tools for this, providing valuable insights that can improve your product, enhance customer service, and ultimately create a more effective eCommerce operation overall.

But what approach should you take to run these surveys? 

From traditional methods to modern tactics, there are numerous ways you can reach out to your customers for their opinions, but we’ll be focusing on online forms.

In this guide, we’ll explore these different methods individually to help you choose the best fit for your business needs.

Continue reading WooCommerce: 7 Different Ways to Run a Survey

Automatically created username problem

I’ve just spotted that when WooCommerce registers users by autocreating the username (and thus the nickname), sometimes randomly it uses all of the user’s email address in the username and nickname by setting the nickname to eg. first-lasthotmail-com. Most of the time it does the job properly but it’s actually quite a serious problem when using BuddyBoss because it leaks personal data since the nickname is pretty visible in BuddyBoss.

Has anyone else seen this and do you have better ideas of what to do about it? As a temporary measure I’ve had to turn off “When creating an account, automatically generate an account username for the customer based on their name, surname or email” so customers have to choose their own username. This is a little bit of friction I’d rather not have.

WooCommerce: Delete Customer After a Failed (Spam) Order

Once again, I’m trying to find WooCommerce anti-spam workarounds to avoid manual admin work like receiving hundreds of emails, deleting hundreds of fake orders and fake WordPress users.

In today’s “episode” I will try to clean the WordPress User database table after a failed order, because I’m really angry when “17PmU3MmKZS9ZAy7 17PmU3MmKZS9ZAy7” manages to register an account on Business Bloomer after a carding attack!

Please test this snippet on a dev/staging environment and not directly on the live site. Deleting a WordPress user is never a good idea, so you need to make sure everything is working as it should. Enjoy!

Continue reading WooCommerce: Delete Customer After a Failed (Spam) Order

WooCommerce: Limit Daily Sales For Cheap Products (Anti-Spam)

We could call this the “WooCommerce Anti-Spam Without a Plugin” series, while I attempt to fight against bad humans and very bad bots who love attacking the Business Bloomer checkout page with spam orders and fake user registrations.

My first attempts were (1) My Account registration anti-spam honeypot, (2) Checkout anti-carding-attack honeypot, and (3) Reducing the number of admin emails, but I can tell that (2) didn’t work, and I got another carding attack on a $9 product last weekend. Bots are smart.

Today, I’d like to share another anti-spam snippet that I’m currently testing on Business Bloomer. Most carding attacks, in fact, end up with the purchase of a single product in the $1-$9 range – which means that limiting the daily sales for specific, inexpensive, products may do the trick.

My code counts the times each product has been purchased during the day – and if a carding attack occurs, the product won’t be purchasable any longer until the end of the day. Because we’re talking about cheap products, it’s no problem for me to disallow legit sales as well for 24 hours. Use at your own risk, of course.

We already covered how to “Limit Sales Of A Product Per Day“, but this time I’d like to apply that to an array of products – and specifically all those that are under $10. Enjoy!

Continue reading WooCommerce: Limit Daily Sales For Cheap Products (Anti-Spam)

WooCommerce: Anonymize All Users & Orders

Especially when you need to let other people (such as developers) log in to your WooCommerce website, you may want to protect the identity of your customers and your order details.

Of course, anonymizing your WooCommerce backend requires a complete database override – this change is 100% irreversible! Only run this code if you know what you’re doing.

The ideal workflow is the following: you give developers access to a staging/clone website version, you run this custom code to anonymize customers and orders, and have them do the changes. This is good for GDPR, CRPA and PIPEDA as well: third party people won’t see sensitive data.

One more note: I haven’t tested the code with thousands of customers and orders – feel free to leave a comment in case your (staging) website crashes. Enjoy!

Continue reading WooCommerce: Anonymize All Users & Orders

WooCommerce: Disable Checkout Field Autocomplete

By default, WooCommerce adds the “autocomplete” attribute to almost all checkout fields. For example, “billing_phone” has “autocomplete=tel”, “billing_country” has “autocomplete=country” and so on.

When logged out or if the logged in user has never done a purchase before, the WooCommerce Checkout page fields are possibly autofilled by the browser based on saved data / addresses.

Today, we’ll take a look at how to disable this autofill behavior, so that the customer is forced to enter data inside an empty input, and maybe in this way you can apply your custom validation or pattern, such as a specific phone number format. Enjoy!

Continue reading WooCommerce: Disable Checkout Field Autocomplete

WooCommerce: Fix Google Search Console “No global identifier provided” Error

If you registered your WooCommerce website on Google Search Console for monitoring your SEO efforts and search appearance errors, you probably got this “No global identifier provided (e.g. gtin, brand)” email notification at some stage. I got it too.

Search Console optionally requests you set a unique product GTIN structured data for all your products – I believe in case you wish to sell on Google Shopping – and therefore sends you this error notification whenever a product is missing this.

You could use a WooCommerce GTIN plugin from the WP repo, yes. Or you could be smart, and programmatically set the GTIN to the same value of the product SKU, as long as all your products have a unique SKU value. Today, we will cover the latter. Enjoy!

Continue reading WooCommerce: Fix Google Search Console “No global identifier provided” Error

WooCommerce: Get Draft Product URL

Now, this is a bit of a niche tutorial, but it may come useful you need to get a product permalink when it’s still a draft. As you can see from the screenshot below, this is helpful when the product URL is very long – in such a case WordPress truncates the “Permalink” string and you can’t really copy/paste.

For example, you may need the product URL for a scheduled blog post, a future newsletter, an email; in whatever case, this is a cool way to “get” the product URL and print it in the “Publish” meta box of the single product edit page. Enjoy!

Continue reading WooCommerce: Get Draft Product URL

WooCommerce: Change Address Format For a Specific Country

We’ve already covered a little about address formats when we added a custom House Number field to the WooCommerce Checkout page.

Address formats define the way Billing and Shipping addresses are formatted for the end user. Addresses show on the order received / thank you page, on transactional emails and on some My Account pages, and look like this:

{name}\n{company}\n{address_1}\n{address_2}\n{city}\n{state}\n{postcode}\n{country}

Now, what if you wanted to move the “company” before the customer name, or maybe have “address 1” and “address 2” on the same line, or move “postcode” to the last line? Well, thankfully there is a neat WooCommerce filter called “woocommerce_localisation_address_formats” that allows us to do just that – reformat any address for any country we wish. Enjoy!

Continue reading WooCommerce: Change Address Format For a Specific Country

WooCommerce: Refresh Checkout Upon Any Input Field Change

You may be aware that the WooCommerce Checkout page “order review” section reloads/refreshes every time there is a change of address – in this way shipping, taxes and optional fees are properly recalculated and customers are returned with the correct total.

But in case you add custom checkout fields that may cause a difference in pricing, or you want to keep the checkout UX consistent, or you have some other kinds of logic, it may be useful to refresh the order review section after a change on any checkout field. Enjoy!

Continue reading WooCommerce: Refresh Checkout Upon Any Input Field Change

WooCommerce: Get Order Fees Total

It’s official – there is no way to get the fees total from an order with a simple PHP getter (not sure why – you can get lots of values such as totals, addresses, dates, URLs with one line of code except for this basic thing!).

So, we’ve got to fix this. Let’s say you have access to the $order object (on the thank you page, in the WordPress dashboard, inside an order email, etc.); here’s a few lines of PHP you can use to calculate the total amount of order fees. Enjoy!

Well, there is actually one line of PHP you can use to calculate the order total fees (despite I didn’t think so while I was writing this post) – I’ve now added it to the list of order “getters” here (where you can get lots of order values such as totals, addresses, dates, URLs with one liners).

So, in order not to waste this post, you still find below the original way to calculate order total fees (by looping through all order fees and adding up totals), as well as the one liner that can help you save time. Enjoy!

Continue reading WooCommerce: Get Order Fees Total

WooCommerce: 4 Ways to Grow Your Sales With Omni-Channel Marketing

The goal of marketing automation is to help you save on effort. However, sometimes it comes at the price of poorly targeted campaigns and half-baked marketing content, which can be outright damaging to your business.

The other problem with most of WooCommerce marketing automation tools is that they have a one-off approach to marketing that aims to get as much as possible from one user interaction – during checkout, for example – without providing for loyalty or retention. This goes against the golden rule of marketing, where your biggest asset is your leads and customers and your biggest mission is to retain them.

The solution is to use a omni-channel marketing approach, where a central tool collects and enriches user behavior and history in a unified profile and then uses that profile to deliver relevant campaigns across all user touchpoints. 

This ensures more harmonized marketing, a seamless experience for your users and eventually more trust and engagement with your brand. These are all the ingredients you need to increase the loyalty lifetime value of your users and customers. 

Continue reading WooCommerce: 4 Ways to Grow Your Sales With Omni-Channel Marketing

WooCommerce: Additional “Store Address” @ General Settings

So, we all know that the “Store Address” fields under WooCommerce > Settings > General are used by other WooCommerce functions such as the initial setup wizard, currency switchers, language plugins as well as taxes and shipping calculations. Also, it may display on PDF invoices, WooCommerce emails and static pages.

This is all good and easy, but as usual businesses are not made equal. It could be that you need to show an additional address; for example, the “Warehouse Address”.

In this tutorial, we will add a new “Warehouse Address” section and address fields under the “Store Address” settings, and also see how we can easily retrieve this custom address so that you can display it anywhere. Enjoy!

Continue reading WooCommerce: Additional “Store Address” @ General Settings

WooCommerce: Why Variable Products Are Too Limited (and How Add-Ons Can Help)

WooCommerce is rich with customization options for different kinds of eCommerce businesses. However, it’s quite limited when it comes to certain shopping solutions your online business may need – such as displaying product variations.

For instance, a customer may need to choose RAM size, storage size, and device color before buying a mobile phone. In this case, using the default WooCommerce variations will require you to create a variable product with hundreds if not thousands of attribute combinations.

This can be exhausting, and despite all that work, the result is often a slow and difficult to manage product backend due to a huge number of variations . Besides, your customers would have a hard time finding the exact variation when the only option they have are dropdowns with dozens of options.

The best way to give your customers a seamless user experience is to allow them to customize their products on the same page without using variations. Now, you can’t do that with WooCommerce alone. This is where WooCommerce product add-ons plugins come in.

In this article, we’ll show you the easiest way to create and sell variable WooCommerce products using WooCommerce Product Options. But before that, let’s talk about why you need additional product options in your store.

Continue reading WooCommerce: Why Variable Products Are Too Limited (and How Add-Ons Can Help)