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!
PHP Snippet: Maybe Switch User Role When Customer Spends More Than $$$ (Lifetime)
Note: of course you first need to create your custom user role (‘vip-customer’ in the example below, but you can name it as you wish as long as you change the code accordingly). You can use the free User Role Editor WordPress plugin if you wish.
This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101
WooCommerce: Disable Payment Gateway for Specific User Role You may want to disable payment gateways depending on the logged in user role. For example, you may want to disable PayPal for user role “subscriber” or enable a specific gateway for user role “customer”. All you need is to paste the following code in your functions.php or to install a super simple plugin. Enjoy!
WooCommerce: Login Redirect by User Role @ My Account There are times when you don’t want customers to login and be redirected to the default “My Account” dashboard. Maybe because you have a membership site and you want them to go to a custom “Welcome” page, or maybe you wish to send them straight to their “My Account” > “Downloads” subsection. No matter the […]
WooCommerce B2B: How to Set Up a Wholesale Store The ecommerce sector is seeing incredible growth, year after year, with no foreseeable end in sight. The same is true for B2B ecommerce, yet there aren’t many good platform choices available for small-to-medium businesses that want to sell wholesale. There are several SaaS solutions on the market, but these are costly, closed-source, and mostly oriented […]
WooCommerce Wholesale: All-In-One Plugin Solutions While WooCommerce is one of the most powerful and flexible ecommerce platforms on the market today, it was built for retail, and therefore it’s missing many important features for business buyers. If you are setting up a wholesale store with WooCommerce, you will find many of these features fulfilled by small individual plugins. However, that […]
Business Bloomer Founder
Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli