Skip to content
Advertisement

How to Assign a Gateway Fee in WooCommerce to Multiple User Roles?

I’ve built an online shop on WooCommerce that sells retail as well as wholesale. But credit card fees are so damn expensive. I’m happy to pay the credit card fees for my retail customers but I want to charge my resellers if they choose to pay by credit card.

I managed to come up with the following code that works really well. But I have two different types of resellers so I need to expand the code and I’m not sure how to go about it.

I’m trying to expand this bit of code to include three different user roles:

Role 1: wholesaler-non-vat-registered Role 2: default_wholesaler Role 3: administrator

Any idea how to go about it?

JavaScript

This code works too, but it adds the credit card fee to logged in Customers too. So the code works for Guests, but as soon as the customer signs into their account they get charged a credit card fee.

JavaScript

Here’s the solution thanks to Sara McMahon. Works like a charm!

JavaScript

Advertisement

Answer

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement