Splitting 'Default Payment Gateway' & 'other payment gateway' based on user group?
Permalink Browser Info Environment
Hi there, I'm trying to work out a way to split the payment gateway based on user group. If a member has an 'invoice-based' agreement with the client, they access the default gateway and the invoice is handled seperately, whereas other customers pay in the usual fashion...
method.php is where this happens:
but I'm unsure about how I can proceed from here. Any pointers would be a real help
Thanks in advance for any help :)
method.php is where this happens:
Loader::packageElement('checkout/payment/method','core_commerce', array('action' => $action, 'o'=>$order,'form'=>$form,'form_attribute'=>$form_attribute, 'akHandles'=>$akHandles));
but I'm unsure about how I can proceed from here. Any pointers would be a real help
Thanks in advance for any help :)
Type: | Discussion |
---|---|
Status: | In Progress |
Hi Korvin, thanks for your reply. I am stumped with this one... I haven't really delved into the 'hook events' side of things - just can't get my head 'round it
Is there any chance you could give me an example of how to go about it? I'm sure that once I begin to understand hooking events, it will open a whole new world of Concrete5 development...
Cheers mate
Rob
Is there any chance you could give me an example of how to go about it? I'm sure that once I begin to understand hooking events, it will open a whole new world of Concrete5 development...
Cheers mate
Rob
Hi there all, can anyone point me in the right direction with this? I just can't get my head 'round the whole 'hooking' element in Concrete5. I've searched everywhere, but I'm not really coming up with anything that works...
Any help would really be appreciated.
Cheers
Rob
Any help would really be appreciated.
Cheers
Rob
Here's a working example:
class MyEventHandler { public function handle($order, $methods) { $user = new User(); $group = Group::getByName('Testers'); if ($user->inGroup($group)) { // Return the paypal gateway for users in group "Testers" return array(CoreCommercePaymentMethod::getByHandle('paypal_website_payments_standard')); } // Return just the default gateway for everyone else return array(CoreCommercePaymentMethod::getByHandle('default')); } } Events::extend('core_commerce_on_get_payment_methods', 'MyEventHandler', 'handle');
This is brilliant Korvin, thanks very much. Works like a charm. This has been doing my head in for weeks now!
One quick question. I have SagePay as a payment method option. How do I get PayPal and SagePay up as options if the user is in the group?
...if you get what I mean...
You have made my day now that this is almost 100% there. Cheers mate!
One quick question. I have SagePay as a payment method option. How do I get PayPal and SagePay up as options if the user is in the group?
...if you get what I mean...
You have made my day now that this is almost 100% there. Cheers mate!
Hi Korvin, I'm still struggling to get multiple payment systems to show up... Is there a way of doing this?
I really hope so. Thanks in advance for your help
Rob
I really hope so. Thanks in advance for your help
Rob
##- Please type your reply above this line -##
Your request (24) has been received and is being reviewed by our support
staff.
To add additional comments, reply to this email.
[image: concrete5]
*concrete5 Community*
Nov 14, 02:25
Your request (24) has been received and is being reviewed by our support
staff.
To add additional comments, reply to this email.
[image: concrete5]
*concrete5 Community*
Nov 14, 02:25
Hi Rob,
In PHP you can only return from a function once. However since we're returning an array, we can simply add the payment method there:
In PHP you can only return from a function once. However since we're returning an array, we can simply add the payment method there:
// Return just the default gateway for everyone else return array( CoreCommercePaymentMethod::getByHandle('sagepay_form'), CoreCommercePaymentMethod::getByHandle('paypal_website_payments_standard') );
##- Please type your reply above this line -##
Your request (46) has been received and is being reviewed by our support
staff.
To add additional comments, reply to this email.
[image: concrete5]
*concrete5 Community*
Nov 17, 09:43
Your request (46) has been received and is being reviewed by our support
staff.
To add additional comments, reply to this email.
[image: concrete5]
*concrete5 Community*
Nov 17, 09:43
doh! The answer was staring me in the face all the time!
Thanks Korvin, that's brilliant
Thanks Korvin, that's brilliant
##- Please type your reply above this line -##
Your request (117) has been received and is being reviewed by our support
staff.
To add additional comments, reply to this email.
[image: concrete5]
*concrete5 Community*
Nov 22, 03:37
Your request (117) has been received and is being reviewed by our support
staff.
To add additional comments, reply to this email.
[image: concrete5]
*concrete5 Community*
Nov 22, 03:37
It looks like you can simply tie into the "core_commerce_on_get_payment_methods" event and return an array with the only item being the payment method you want to be used.
Check out this guide for more info: https://www.concrete5.org/documentation/developers/5.6/system/events...