0

In the checkout of woocommerce I want to hide the payment method "cheque" if the checkout field "billing_company" is empty.

When the page is loaded the first time, as the field "billing_company" is empty, the payment method should already be hidden. Once the visitor enters and leaves the field "billing_company" the order-summary should be updated.

Thank you for your help.

I tried with the following code but it didn't work:

add_filter('woocommerce_available_payment_gateways', 'filter_gateways', 1);
function filter_gateways($gateways){

    if ( empty('#billing_company')) {
        unset($gateways['cheque']);
  } 
  
     return $gateways;
}

  • Check this - https://stackoverflow.com/questions/53565775/show-hide-payment-gateways-based-on-checkout-fields-in-woocommerce – Snuffy Oct 27 '22 at 13:49

0 Answers0