Thread Starter
alx359
(@alx359)
The only way I’ve yet come across is using an unassigned one-off object like:
if( (new WC_Gateway_Braintree_AngellEYE)->is_available() )
{// do my stuff}
but still, instantiating an almost 2k lines class with a lot of stuff going on feels overkill and might have unwanted ramifications. Way better if the given method was just static:
WC_Gateway_Braintree_AngellEYE::is_available()
Please advise.
Hi @alx359, Sorry for the delay in response. Please allow me some time to get some more relevant information from our developer.
@angelleye can you please look into this one?
Thanks!
Thread Starter
alx359
(@alx359)
Hey, Angell! It isn’t critical, but would be really enlightening to learn there’s an advance (to me) technique to properly access your implicit WC_Gateway_Braintree_AngellEYE class object. Thanks!
@angelleyesupport, We need to get our lead dev’s feedback on this. Please speak to @kcppdevelopers about it and create any necessary tickets in the system so we can get this taken care of.
@alx359 @angelleyesupport @angelleye
Here is the code for check specific gateway is enable or not : https://pastebin.com/SBNKtPtJ
Thanks
Thread Starter
alx359
(@alx359)
Thanks, kcppdevelopers!
I was aware of WC()->payment_gateways->get_available_payment_gateways() before, but wasn’t using it properly. Actually, $available_payment_gateways['braintree'] array points to the WC_Gateway_Braintree_AngellEYE instance e.g. $available_payment_gateways['braintree']->is_available(), but from your example it also becomes apparent when is_available() == false the whole $available_payment_gateways['braintree'] array ceases to exist.
Thanks again, and sorry for the hassle!
Thread Starter
alx359
(@alx359)
After some more tinkering, I now see a reason for my previous confusion.
$available_gateways = WC()->payment_gateways->get_available_payment_gateways() doesn’t work for ‘paypal_express’ ! Oddly enough, checking enabled=yes in the UI just returns an empty array for PPE. Don’t know why PPE is singled out that way?
On the other hand, WC()->payment_gateways->payment_gateways() does return an array with all installed (i.e. enabled and disabled) gateways, from where one could figure out easily which ones are enabled, like this:
$available_gateways = WC()->payment_gateways->payment_gateways();
$is_enabled_ppe = $available_gateways['paypal_express']->get_option('enabled');
$is_enabled_bt = $available_gateways['braintree']->get_option('enabled');
Thanks for the pointing me out to the right direction!
@alx359 Happy to help you. Feel free to write here again if you need any further assistance.
Also, we would love to know what you think of our product and customer support. If you have a moment to [leave a review ] it would be greatly appreciated..
Thanks!
Thread Starter
alx359
(@alx359)
Oliver, look at who wrote the very last one 😉
Thanks for your positive vibe, Much appreciated!
Cheers!