WooCommerce: How to Stop Spam Orders on Free Products

I’ve been hit once again by a bot attack.

This time, I woke up to dozens of fake orders for my best-selling free mini plugin: the WooCommerce Autocomplete Orders Mini-Plugin. All of them placed overnight, all using obviously fake email addresses, and all totally useless.

Besides clogging up my order list and analytics, these spam orders also triggered multiple admin emails and slowed down my workflow.

Free products are a great way to provide value and attract users — but they also open the door to abuse.

That’s why I decided to implement a simple solution: limit how many times each free product can be ordered per day. Once the daily limit is hit, the product becomes temporarily unavailable with a “come back tomorrow” message.

In this post (and the video below), I’ll show you exactly how I did it, with a custom snippet that targets all free products in a specific category.

Continue reading WooCommerce: How to Stop Spam Orders on Free Products

WooCommerce: Building Customer Profiles for Tailored Recommendations

apparel, boutique, bags

Understanding your customers’ preferences is key to enhancing their shopping experience and boosting sales. In WooCommerce, building a customer profile based on past purchases and viewed products can help you create personalized product recommendations. This approach is particularly useful for businesses selling products with specific attributes, such as drinks with distinct flavors, colors, or origins. By analyzing customer behavior and preferences, you can highlight products that align with their tastes, encouraging repeat purchases and increasing engagement.

Creating a recommendation engine requires a combination of retrieving customer purchase history, identifying product attributes, and using that data to suggest similar items. While there are plugins available for automating this process, a custom-coded solution offers flexibility and precision. Let’s dive into how you can achieve this by leveraging WooCommerce’s tools and some programming, allowing you to build a dynamic and effective customer profile for personalized shopping experiences.

Continue reading WooCommerce: Building Customer Profiles for Tailored Recommendations

Optimizing WooCommerce Customer Purchases Checks

In a recent Business Bloomer Club discussion, a member explored an efficient way to validate customer memberships for accessing restricted pages in WooCommerce.

The challenge was ensuring quick performance when checking if customers have purchased any one of a series of products upon login. Typically, using the wc_customer_bought_product function works well for single product checks, but this case involved verifying around 10-15 products.

Running such multiple checks, especially on member-only pages, risks slowing down the user experience.

Continue reading Optimizing WooCommerce Customer Purchases Checks

WooCommerce: Conditionally Display Content to Customers [Shortcode]

Today’s customization will feature a custom shortcode that you can use to display content only to logged in customers: [customers-only]content for customers here e.g. video iframe[/customers-only]

This is perfect for membership sites, LMS platforms, paywalled content.

In my case, only premium Club members with a ‘CLASS’ pass can watch upcoming WooCommerce masterclasses and past recordings, so I needed the shortcode to hide the video to logged out users or logged in customers without a pass.

By wrapping the video iframe HTML inside the shortcode, I can show the video to logged in customers who purchased a given product ID, or alternatively show an error message, which you can see in action here, in the “The recording is now available!” section: https://www.businessbloomer.com/class/behind-the-scenes-how-i-run-business-bloomer/

So, how did I do it? Find out below, and hope you can use it too!

Continue reading WooCommerce: Conditionally Display Content to Customers [Shortcode]

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: User Can Only Purchase A Product Once

In the era of online courses, subscriptions, custom-made products and product personalization, it may happen that you need to limit a specific WooCommerce product sales. For example – users may only purchase a trial product once in their lifetime.

In this short tutorial, we will see how this is done. Clearly, the user must be logged in in order for the code to trigger, so this applies to stores that require checkout login before proceeding with the order.

Enjoy!

Continue reading WooCommerce: User Can Only Purchase A Product Once

WooCommerce: Get List of Users Who Purchased a Product ID

This time around we’ll take a look at some SQL. As you know, WooCommerce orders (same as WooCommerce products) are stored in the WordPress database.

Instead of using complex PHP loops and conditionals, sometimes knowing a bit of database “reading” can help. I took some inspiration (because I don’t know everything by heart) from the wc_customer_bought_product() WooCommerce function, which contains some SQL to check if a user has purchased a given product.

I’ve played a little with the same SQL SELECT call, and managed to return the list of user email addresses who have purchased a specific product ID. If you’re ever going to need this, enjoy!

Continue reading WooCommerce: Get List of Users Who Purchased a Product ID