Payment-Gateways AJAX-Reload
-
Hey,
I need to disable all Payment-Gateways on a certain condition in the checkout, except one.
I used this method to hook intoadd_filter('woocommerce_available_payment_gateways', [$this, 'replaceWithRequestPaymentGateway']); /** * @param array $paymentGateways * @return WC_Payment_Gateway[] */ public function replaceWithRequestPaymentGateway(array $paymentGateways): array { $myFreeGateway = new PaymentGatewayFree(); // Replace all other Gateways with the custom one $paymentGateways = [$myFreeGateway->id => $myFreeGateway]; return $paymentGateways; }
That actually works pretty well. I just have the Problem, whenever the AJAX-Reload on the checkout page loads the Payment methods, it shows all default payment methods again.
I think I need to hook into the ajax request as well, but I didnt seem able to find it, do you have any hints were to look? (I may need to send a parameter via that ajax request, so i can use it to get the correct payment systems there as well)Thank you so much!
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Payment-Gateways AJAX-Reload’ is closed to new replies.