How to disable payment gateways according to the user profile

A possible very interesting personalization that does not come by default with the installation of WooCommerce is the possibility of power show or hide payment gateways according to the user profile .

This can be very useful in various situations such as private professional stores, subscriptions, memberships, etc.

Imagine, for example, that by default you want to inactivate the payment via Paypal for new customers (default profile customer ) but you want it to be active for regular customers (new custom profile good customer ) Can you think of other possible situations?

Let's see how to do it.

Find the slug of the user profile

You can use this trick with the default profiles but when it really makes sense is when you create custom client profiles .

For this you can use a plugin like Members . It will be, in passing, very useful for to easily identify the slug of the WordPress user profile for which you want to make the modification.

The plugin is very easy to use. Add a new link under menu Users> Profiles and include a utility to clone an existing profile.

In our case it is perfect to simply clone the client profile that WooCommerce creates by default ( customer ).

Then, in the list of profiles, you can see the slugs of the different WordPress user profiles and that other plugins have been adding.

Locate the ID of the payment gateway

The next thing is to know the ID of the payment gateway that you want to inactivate, and nothing easier. Just stop by WooCommerce> Settings> End purchase . Below you will find the list of installed payment gateways, with a column in which the ID of each one is displayed.

Create the function to deactivate payment gateways according to profile of user

Once we already know where to find the slugs of the user profiles and the IDs of the payment gateways we can already create our function which would be something like this:

As you will see in the code , we are deactivating the gateway with the ID paypal for the profile slug customer the default profile of WooCommerce.

This code must be added to the file functions.php of theme active (preferably a child theme) or your customizations plugin .

Note: Add this type of functions always to the end of the functions.php file

] Save the changes and you already have it. New customers ( customer ) will not be able to pay for Paypal. Once you have made your first purchase you can change profile to good customer and then you will see all the payment gateways, Paypal included.

Can it be done with plugins?

Of course. If you do not dare with the code, or want to access more customizations of all kinds, there are several plugins that will allow you to do this, at the click of a button, because someone has already programmed everything before us.

Role-Based Payment / Shipping Methods (49 $)

With this plugin from the creators of WooCommerce you can define which payment gateways, and also what shipping methods, will be available for the different existing user profiles.

Booster for WooCommerce ($ 39.99)

With the paid version of this plugin you can also specify which gateways payment profile will have available each user profile.

Yith Payment Method Restrictions for WooCommerce (56 $)

Restrict gateway by country

The most complete of these plugins not only allows you to restrict gateways of payment by user profile, without or that also you can create simple and complex (mixed) rules .

  • Create restriction rules for all installed gateways.
  • Establish one or more conditions for each rule (that the user has such a profile , also be from this country, etc)
  • Disable payment gateways if …
    • the user has a certain profile
    • the cart includes one or more products of those specified in the rule
    • the cart includes one or more products of specific categories or labels
    • if the amount of the cart is less, equal to or more than an amount specified in rule
    • the user is from one of the countries specified in rule

    ]

  • You can also change bank account according to a specific rule

As you have seen the possibility is there, and edes create custom rules to limit payment gateways according to the user profile for free with your own code or paying a bit for a plugin that offers this solution, and some more step, I'm sure some idea I've given you

Loading …

That may also help you:

99% of WordPress users do not know about WordPress and that's good • WordPress Help

After years of offering help, information, developments and WordPress services I have come to the (happy) conclusion that the vast majority of WordPress users do not know WordPress, and it's good news .

WordPress has become a commodity

This does not come but confirms that WordPress has become a commodity in consumer software that users use to create their websites, maintain them and publish content, without there really needing to know their ins and outs, and that is part of the success of WordPress in front of other CMS.

Every time I hear WordPress professionals regret that the average user does not know WordPress I recognize that I miss a little smile, at least when you do not enter the contempt of the average user, something very common in the world of

And it seems that some have not realized that, precisely for that reason, for that lack of knowledge, is why they can make a living as WordPress professionals ]

The computer and WordPress user

Just like a printer user does not have to know how a printer works internally, and vaguely knows how to configure the pages to print and sometimes to change the cartridges; just like the computer user knows how to open his text editor and create a document, but he does not have to know how to update or improve the operating system, the current WordPress user only knows how to use WordPress for his purposes, and curiously that it's good .

It's good, because that's a sign that WordPress implementation is so broad, it's so consolidated and so easy to use, that the average user does not require advanced knowledge to create their web including an online store, with WordPress, and most of the time without the help of any WordPress professional.

Since most of the serious hosting companies offer installation packages for WordPress with a click, since the customizer exists and, above all, thanks to the plugins and themes, any user without computer knowledge is able to have his space in the network, boost his business, without having to invest thousands of euros in custom programming .

If we add the ease of customization and use that have introduced the visual formatters like Divi Elementor or WPBakery Page Builder we have a situation in which the presence on the web has been democratized to levels a few years ago unimaginable, and this is thanks to WordPress .

Today's user can be the professional of tomorrow

It is not a free statement, I know many, myself, who got bitten by the bug and wanted to know more, learn the ins and outs of that they use every day, and little by little they went deeper.

I know great WordPress professionals who a few years ago had not programmed a line of code, who had never created a website, and today they earn life honestly, and well as freelances or hired in large companies, which increasingly require professionals specialized in WordPress.

The next one can be you, why not? … or your client.

What this madness of evolution of the web is that you can not stand still, you have to be willing to constantly learn, to reinvent yourself even, to continue being an Internet professional (always) and WordPress (hopefully for many years). [19659005] At the moment, you can celebrate that the vast majority of WordPress users neither know nor want to know about WordPress because just like you require the services of a plumber because your time you must use it in what pays you the invoices, so your client will pay you for your knowledge and value, so that he can continue to dedicate himself to his business.

The new paradigm of the professional WordPress

Therefore , the professional WordPress, the developer, the designer, should not be threatened, simply changed the business model .

A few years ago, to have a website, before WordPress, you had to invest thousands of dollars. euros in custom programming (or something similar) and have a absolute dependency on the developer for any change no matter how small, and that was an effect lock-in .

] Currently, only for the cost of domain and hosting, thanks to WordPress and its entire ecosystem, any entrepreneur, even unemployed or retired, can have a website and be free to publish its contents, without needing technical training , knowledge of web programming, and not even basic knowledge of how WordPres works s.

It is clear that it never hurts to know what you have in hand, and be more consistent and aware with the tool you use iar, but there are a good amount of blogs like this one, and forums in which there are users who selflessly help the average user on a daily basis to correct those little problems of each .

There are even some who spend some time on carrying WordPress even to those who can not afford even the most basic .

But this is not the end of the world for the developer simply your mission has changed it is no longer creating that first website, but to create more advanced applications, redesign websites when the business grows, improve the performance or security of the websites of its customers, solve errors when they arise, offer maintenance and updates, even create custom websites when the user's business requires it or can afford it.

Years ago the business of the programmer it is not create frameworks or bespoke web developments, which you can hardly sell to 3 or 4 clients a year that can afford them because for ordinary mortals it is inexpensive economically, but offer global solutions in the form of plugins or themes, for a small fee, but millionaires when they reach the world scale.

Here I always like to comment the example of YITH which was born from the hand of Nando Pappalardo , programmer, and his wife, designer, when they created a custom-made theme for their clients, who were selling as best they could.

When it seemed that they could no longer milk that cow at the rate of a few thousand euros per customer, they decided sell the theme in ThemeForest at a reasonable price of $ 60 and, look at you where, went from entering a few tens of euros a year, to earn figures of 6 numbers . [19659005] It's just an example, but it shows c How to evolve to adapt to the current market of web creation, in which loyalty, service, is the product, not the property of the software. We are in a world of free software, of releasing the code.

Another good example is that of Pippins Plugins one of the most solid creators of WordPress plugins, that does not sell plugins, sells service, updates, support, you can download the code freely, without paying something that for the old programmer sounds like the manifestation of La Parca when in fact it is the model that allows growth exponential, and commercial success now.

The current programmer should not sell software but become a provider of services and knowledge precisely for that vast majority of WordPress users who do not know WordPress, but later or early they will need a WordPress professional to help them repair / improve something on their website; Like the buyer of a computer sooner or later will need the computer to solve their daily problems.

Congratulations, congratulations for being a professional WordPress with a great present and future then 99% of WordPress users who need you or will need you soon .

Change the chip. Do not criticize them for using visual maquedores or for not having knowledge of computer security or SEO, encourage them to use WordPress, because it will offer creative freedom, and when you need help there you will be to offer your professional WordPress services . [19659038] Loading …

That may also help you: