Find Jobs
Hire Freelancers

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

₹600-1500 INR

Closed
Posted almost 5 years ago

₹600-1500 INR

Paid on delivery
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.
Project ID: 19986925

About the project

5 proposals
Remote project
Active 5 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs

About the client

Flag of INDIA
Delhi, India
5.0
5
Payment method verified
Member since Sep 10, 2015

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.