Closed gijshendriksen closed 4 years ago
@gijshendriksen You can filter the gateways by using the filter woocommerce_payment_gateways
.
Mollie has an hook for that add_filter( 'woocommerce_payment_gateways', array ( __CLASS__, 'addGateways' ) );
which the priority is 10.
You can create a new one with priority 11 so it's executed after the mollie filter and remove the gateways you don't want to allow in your project.
add_filter('woocommerce_payment_gateways', function(array $gateways) {
$index = array_search('Mollie_WC_Gateway_MisterCash', $gateways, true);
if ($index !== false) {
unset($gateways[$index]);
}
return $gateways;
});
I found various places where the gateway is removed. First of all it is removed from the admin settings (see https://github.com/mollie/WooCommerce/blob/master/mollie-payments-for-woocommerce/includes/mollie/wc/plugin.php#L400) then it is removed from the settings view (see https://github.com/mollie/WooCommerce/blob/master/mollie-payments-for-woocommerce/includes/mollie/wc/helper/settings.php#L240) and from the frontend checkout (see https://github.com/mollie/WooCommerce/blob/master/mollie-payments-for-woocommerce/includes/mollie/wc/plugin.php#L857).
I noticed also there's a line of code that remove the option from the bancontact (see https://github.com/mollie/WooCommerce/blob/master/mollie-payments-for-woocommerce/includes/mollie/wc/gateway/bancontact.php#L16-L20).
I don't know why was not removed entirely so I need to investigate and in case make sense to completely remove the gateway but we have to take into account BC changes.
Asking to @ndijkstra about Mister cash and he said the gateway was kept to be able to view order that were paid with that gateway.
I think we could add a conditional statement to remove it also in the frontend if we need it just to see the order paid with Mister cash.
Closed because of inactivity
The Mister Cash payment gateway is no longer in use, but the payment gateway still exists and has an enabled status of
'yes'
. However, as far as I can tell it's not really possible or easy to disable it somehow, as it is no longer listed in the payment settings and there is no entry for it in thewp_options
table either.This becomes an issue when one wants to make a list of all available and enabled payments in their shop. For instance, take the following code:
results in the following output (in one specific shop):
Maybe I'm missing or skipping a hook somewhere using which it is removed from the list of available gateways, but I couldn't really find any. So, is it possible/desirable to set the enabled status of Mister Cash to
'no'
by default? For instance by addingpublic $enabled = 'no';
toMollie_WC_Gateway_MisterCash
.I'd love to hear your thoughts on this!