If the order has the Pending payment status, then the user can pay for it on the account page. This displays all available payment options. How to hide all payment methods except checks? I did it with CSS, but I would like to do it with a hook.
CodePudding user response:
disable the other payment methods from woo-commerce<<settings<<payment
CodePudding user response:
add_filter('woocommerce_available_payment_gateways', 'custom_available_payment_gateways');
function custom_available_payment_gateways($available_gateways) {
$payment_ids = array('paypal'); // Here define the allowed payment methods ids to keep ( cod, stripe ... )
// For Order pay
if (is_wc_endpoint_url('order-pay')) {
foreach ($available_gateways as $payment_id => $available_gateway) {
if (!in_array($payment_id, $payment_ids)) {
unset($available_gateways[$payment_id]);
}
}
}
return $available_gateways;
}