Title: Conditionally Hide Shipping method
Last modified: July 9, 2021

---

# Conditionally Hide Shipping method

 *  Resolved [shridharkagi](https://wordpress.org/support/users/shridharkagi/)
 * (@shridharkagi)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/conditionally-hide-shipping-method/)
 * Dear Forum,
 * Here is my query.
 * I have different shipping methods.
    Ex: 1. Shipping Using Customer A/C [Please
   enter your Fedex/ DHL /Other Courier Name and Account Number in the “Courier 
   Info” Box above.]
 * 2. Free Shipping in India
    3. International
 * Now all the above are showing for all countries.
 * When the Billing country is India and shipping country is India –> I want 2nd
   option. (Free Shipping in India)
 * When the Billing country and is not India and shipping country is any –> I want
   1st and 3rd Options.
 * (Screenshot Link: [https://ibb.co/v38z524](https://ibb.co/v38z524) )
 * Can you guide/ share me any hooks for the same which I can use in functions file.
 * Much appreciated.
 * Regards,
    Shridhar K
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fconditionally-hide-shipping-method%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Support [abwaita a11n](https://wordpress.org/support/users/abwaita/)
 * (@abwaita)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/conditionally-hide-shipping-method/#post-14642212)
 * Hi [@shridharkagi](https://wordpress.org/support/users/shridharkagi/),
 * Just to check, have you tried using Shipping Zones already? The conditions will
   check the shipping country, if that’s the main consideration here.
    - You can start by creating a shipping zone for India and then add the free 
      shipping method to it. Make sure that this shipping zone is the first one 
      on the list at **WooCommerce → Settings → Shipping**
    - You can then use the zone for everywhere else to add the courier/international
      shipping options. Note that the courier options will require you to add the
      plugins for the different carriers. You could check the ones available on 
      our marketplace: [https://woocommerce.com/product-category/woocommerce-extensions/shipping-methods/shipping-carriers/](https://woocommerce.com/product-category/woocommerce-extensions/shipping-methods/shipping-carriers/)
 * Hope this helps.
    Thanks.
 *  Thread Starter [shridharkagi](https://wordpress.org/support/users/shridharkagi/)
 * (@shridharkagi)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/conditionally-hide-shipping-method/#post-14642225)
 * thanks for this [@abwaita](https://wordpress.org/support/users/abwaita/).
 * I was using shipping zones before. I had created a shipping zone as India for
   free delivery.
 * In this case what happens is.
 * let say customer is form US (Billing) He wants to ship to India. Since India 
   comes under Free Delivery so for the US customer, shipping India will show him“
   Free Delivery”.
 * In my case I want to show International for him.
 * I want free delivery only when billing and shipping is in India. Hope you got
   my concern.
 * Thank you for your time.
 *  Plugin Support [abwaita a11n](https://wordpress.org/support/users/abwaita/)
 * (@abwaita)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/conditionally-hide-shipping-method/#post-14642402)
 * Thanks for your explanation.
 * Well, I can recommend the [Conditional Shipping and Payments](https://woocommerce.com/products/woocommerce-conditional-shipping-and-payments/)
   plugin, which has options for creating shipping [conditions based on billing and shipping country](https://docs.woocommerce.com/document/woocommerce-conditional-shipping-and-payments/#global-conditions).
 * You could check the [docs ](https://docs.woocommerce.com/document/woocommerce-conditional-shipping-and-payments/)
   or [create a ticket with us](https://woocommerce.com/my-account/create-a-ticket/?form=ticket)
   for additional info.
 * Otherwise, for the custom coding route, I would recommend consulting with the
   [WooCommerce Customizations Partners](https://woocommerce.com/customizations/).
 * I’ll also leave the thread open to invite anyone who can help with the custom
   code to post here.
 * Thanks.
 *  Thread Starter [shridharkagi](https://wordpress.org/support/users/shridharkagi/)
 * (@shridharkagi)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/conditionally-hide-shipping-method/#post-14643160)
 * Here is what I tried and it’s working.
 * add_filter( ‘woocommerce_package_rates’, ‘free_shipping_method_enable_only_india’,
   100, 2 );
    function free_shipping_method_enable_only_india( $rates, $package ){
   $country = WC()->customer->get_billing_country(); $condition = $country == “IN”;
 *  if ( $condition ){
    $targeted_rate_id = ‘free_shipping:4’; unset($rates[$targeted_rate_id]);
   unset($rates[‘table_rate_shipping_international-1-unit’]); //to unset international
   unset($rates[‘table_rate_shipping_international-2-units’]); unset($rates[‘table_rate_shipping_international-
   3-5-units’]); unset($rates[‘table_rate_shipping_international-6-10-units’]); 
   unset($rates[‘table_rate_shipping_international-11-20-units’]); unset($rates[‘
   table_rate_shipping_international-20-units’]);
 *  }
    else{
 *  unset($rates[‘free_shipping:16’]); //to unset free
 *  }
    //} return ! empty( $free ) && ! $condition ? $free : $rates; }`
 * Reference: [https://stackoverflow.com/questions/64678799/conditionally-hide-shipping-methods-in-woocommerce?answertab=votes#tab-top](https://stackoverflow.com/questions/64678799/conditionally-hide-shipping-methods-in-woocommerce?answertab=votes#tab-top)
 * Thank you.
 *  Plugin Support [abwaita a11n](https://wordpress.org/support/users/abwaita/)
 * (@abwaita)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/conditionally-hide-shipping-method/#post-14643354)
 * Glad to hear that you were able to find a solution – thanks for letting us know!
 * I’ll mark this thread as resolved now. If you have any further questions, you’re
   welcome to create a new thread.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Conditionally Hide Shipping method’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

## Tags

 * [shipping methods](https://wordpress.org/support/topic-tag/shipping-methods/)

 * 5 replies
 * 2 participants
 * Last reply from: [abwaita a11n](https://wordpress.org/support/users/abwaita/)
 * Last activity: [4 years, 10 months ago](https://wordpress.org/support/topic/conditionally-hide-shipping-method/#post-14643354)
 * Status: resolved