Jump to content

Restrict payment method for one customer group


brnsk

Recommended Posts

Hi!

I'm running PS 1.6.18 and have many customer  groups in my shop. What I need to do is to disable a specific payment method (it's a separate module) for a specific customer group while this payment method stays available for all other customers (also not registered).

 

It needs to work like that: if a customer belongs to XXX group >>> do not show  YYY payment method.

 

Standard customer group module availability tool doesn't help here. Any tips how to solve this problem?

 

Cheers!

Link to comment
Share on other sites

  • 2 weeks later...

@jetway It doesn't work like this unfortunately. Let me explain that with an example. Let's say I have a 'NoCreditCard' customer group in my shop for customers that I don't want to to pay with credit cards. Yet these customers belong also to the default 'Customer' group. And what I want to achieve is to make credit card payment available for all customers besides these that belong to 'NoCreditCard' group. If I make credit card payment unavailable for 'NoCreditCard' group in payment preferences, customers that belong to this group still get this payment option because they also belong to the default 'Customer' group (and I don't want to kick them out of the default group because then many features stop working as they should).

 

I'd be grateful for a suggestion where in the code should I apply a rule like: if a customer belongs to XXX group >>> do not show  YYY payment method

Edited by brnsk (see edit history)
Link to comment
Share on other sites

  • 2 years later...

Hello,

I would like to resume this discussion because I have the same problem too (Prestashop 1.7.4.3):

the problem is that, just like @brnsk wrote, Prestashop restriction of the payment method works based on all groups to which the user belongs, and this causes the restriction not to work properly.

The restriction should work based only on the DEFAULT customer group.

Anyone knows how to do it?

Thank you. 

Edited by Gianluca-Lorenz (see edit history)
Link to comment
Share on other sites

For restricting the specific Group from the credit card payment, kindly try by adding the below code in the main file of the credit card payment module, 

 

Function hookPaymentOptions($params)

=>First Fetch the group using the below code

 $customer_id = context::getContext()->customer->id;

$group_ids = Customer::getGroupsStatic((int)$customer_id);

=>Then check whether the group belongs to the "NoCreditCard" Group, if yes then use the below code

return;

The above code will check whether the group of the customer is belong to the "NoCreditCard" Group , if yes then that payment method is not available on the front for that customer, otherwise the payment method is available.

Link to comment
Share on other sites

Hello @Knowband Plugins 

thank you for your answer but, what about the issue related to the Prestashop core payment's restriction feature (Improve > Payment > Setting > Group limitations) ?

How can we correct the default Prestashop behaviour to tell the system to take in consideration ONLY the default customer group and not all the groups to which the customer belongs?

Thanks again.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...