1

With the code bellow, the customer needs to select a shipping method in order to update and change the payment methods (COD will hide the other payment methods):

add_filter('woocommerce_available_payment_gateways', 'my_custom_available_payment_gateways');
function my_custom_available_payment_gateways($gateways) {
    $shipping_method ='flat_rate:8'; //2-7
    $shipping_method2 ='flat_rate:9';
    global $woocommerce;
    $chosen_methods = WC()->session->get( 'chosen_shipping_methods' );
    $chosen_shipping = $chosen_methods[0];

    if ($chosen_shipping == $shipping_method || $chosen_shipping == $shipping_method2) {
        unset( $gateways['easypay_mb'] );
        unset( $gateways['easypay_mbway'] );
        unset( $gateways['easypay_cc'] );
        unset( $gateways['paypal'] );
        unset( $gateways['bacs'] );
    }
    return $gateways;
}

BUT I need something different and I'm not finding anything related to that.

I would like that each available payment method will enable one pre-defined shipping method at the time, without allowing customer to change of shipping method (so without displaying shipping method radio buttons options choice).

Is it possible? Can someone point me to the right direction?

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
FilipeOS
  • 801
  • 1
  • 11
  • 42

0 Answers0