Closed

Unset COD Payment Gateway on the Basis of Post Code in Woocommerce

I need to unset Cash on Delivery payment gateway on the basis of post code entered by the customer on checkout page. Currently, I have created a shipping zone with the list of pincoedes and I am using the following function to unset the gateway:

function conditionally_remove_payment_methods( $gateways ){

// Define Zone Check for Pincode

$targeted_zones_names = array('All','Zone 4','Zone 7');

$chosen_methods = WC()->session->get( 'chosen_shipping_methods' ); // The chosen shipping mehod

$chosen_method = explode(':', reset($chosen_methods) );

$shipping_zone = WC_Shipping_Zones::get_zone_by( 'instance_id', $chosen_method[1] );

$current_zone_name = $shipping_zone->get_zone_name();

if( in_array( $current_zone_name, $targeted_zones_names ) && WC()->customer->get_billing_postcode() <> ''){

unset( $gateways['cod'] );

}

return $gateways;

}

The number of pincodes entered in the shipping zone is around 15,000. This is causing the checkout page to load in 25 seconds or more. I need a way to accomplish this without slowing down the checkout page loading.

Skills: Javascript, PHP, WooCommerce, WordPress

See more: aspnet post payment gateway, payment gateway aspnet using code, php free payment gateway code, net payment gateway post, payment gateway integration php code, indian payment gateway free php code, data payment gateway api integration code, optimal payment gateway integration php code, php payment gateway mastercard page code, hdfc payment gateway integration php code, connect payment gateway asp net code, payment gateway server side code, online payment gateway integration sample code, payment gateway wtih qr code, woocommerce payment gateway post, payment gateway with qr code, shopify shipping zones by zip code

About the Employer:
( 5 reviews ) Delhi, India

Project ID: #19986925

5 freelancers are bidding on average ₹2730 for this job

rsen75

hi, 15+ years experience with strong knowledge of API / Payment Gateway integration and php with mysql, Plugin development and designing see my few portfolio **CSM and eCom** Magento / WordPress / zencart / More

₹8000 INR in 5 days
(195 Reviews)
7.1
shahajay6434

Hi, I can update your website. Can we have a short discussion? I can start immediately and can complete the task within a short time. I am a full stack developer with over 7+ years of experience dealing with HTML More

₹1300 INR in 1 day
(61 Reviews)
5.6
sonaphp247

Hello, Greetings, Top most Freelancer to work with and have great reviews too. We have read your project details and we are very much keen to work with you. We have the best developer and designer team having more than More

₹1450 INR in 7 days
(26 Reviews)
4.1
milindaudichya

Hello, I'm a freelancer with more than 5 years of work experience in designing websites in PHP, CakePHP, Wordpress, PHP, HTML/CSS/JAVASCRIPT, Wordpress Theme Integration, Woocommerce/E-commerce, Responsive Design. Coul More

₹900 INR in 7 days
(7 Reviews)
4.0
deepaksonidz

Hi, Greetings of the day!!! I carefully reviewed your requirement for quality services you can connect with me. I have more than 8 years of experience in Website & Mobile Application Designing & Development, HTML, More

₹2000 INR in 1 day
(1 Review)
1.9