• Resolved haidermaa

    (@haidermaa)


    Hello!

    I have an eCommerce website where i basically sell products to customers within United Arab Emirates.

    I would like to know how can i disable or hide the Cash on Delivery Payment Method for certain cities like Abu Dhabi & Al Ain.

    Looking forward to your reply!

    Sincerely,

    Hayder

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Mirko P.

    (@rainfallnixfig)

    Hi @haidermaa,

    There isn’t a built-in feature to achieve this but it looks like with this plugin you can enable restrictions for Cash on Delivery Gateway by city and postal code.

    https://www.ads-software.com/plugins/wc-smart-cod/

    Hope this helps!

    Add below function in your active child theme. Not sure but try once if that helps.

    add_filter( 'woocommerce_available_payment_gateways', 'ahir_payment_gateway_disable_country' );
      
    function ahir_payment_gateway_disable_country( $available_gateways ) {
        if ( is_admin() ) return $available_gateways;
        if ( isset( $available_gateways['cod'] ) && WC()->customer->get_billing_city() <> 'YOUR CITY CODE GOES TO HERE' ) {
            unset( $available_gateways['cod'] );
        }
        return $available_gateways;
    }

    ‘YOUR CITY CODE GOES TO HERE’ -> Please change this values as per woocommerce city code

    Thread Starter haidermaa

    (@haidermaa)

    Managed to solve the problem through the standard woocommerce settings.

    Thank you so much guys for your assistance!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How can i disable Cash on Delivery on Selected Cities?’ is closed to new replies.