{"id":605,"date":"2019-12-03T03:38:31","date_gmt":"2019-12-03T03:38:31","guid":{"rendered":"http:\/\/shaplakanon.com\/wpsupport\/?p=605"},"modified":"2019-12-03T03:38:34","modified_gmt":"2019-12-03T03:38:34","slug":"how-to-hide-shipping-methods-for-specific-shipping-class-in-woocommerce","status":"publish","type":"post","link":"https:\/\/shaplakanon.com\/wpsupport\/how-to-hide-shipping-methods-for-specific-shipping-class-in-woocommerce\/","title":{"rendered":"How to hide shipping methods for specific shipping class in WooCommerce"},"content":{"rendered":"\n
\n
\n

Are you finding ways to hide shipping methods when Free Shipping is enabled? Trying to hide shipping methods for Shipping Classes ?<\/p>\n\n\n\n

There are many plugins for this which will cost you $$$.<\/p>\n\n\n\n

Here we will discuss, how you can do it free.<\/p>\n<\/div>\n\n\n\n

\n

References<\/h2>\n\n\n\n

https:\/\/stackoverflow.com\/questions\/47718180\/hide-shipping-methods-for-specific-shipping-class-in-woocommerce<\/a><\/p>\n\n\n\n

Need Help? Contact us at fb.me\/getwpsupport<\/strong> <\/p>\n<\/div>\n<\/div>\n\n\n\n

Open your themes functions.php file and insert the below code<\/p>\n\n\n\n

add_filter( 'woocommerce_package_rates', 'hide_shipping_method_based_on_shipping_class', 10, 2 );\nfunction hide_shipping_method_based_on_shipping_class( $rates, $package )\n{\n    if ( is_admin() && ! defined( 'DOING_AJAX' ) )\n        return;\n\n    \/\/ HERE define your shipping class to find\n    $class = 100;\n\n    \/\/ HERE define the shipping methods you want to hide\n    $method_key_ids = array('flat_rate:7', 'local_pickup:3');\n\n    \/\/ Checking in cart items\n    foreach( $package['contents'] as $item ) {\n        \/\/ If we find the shipping class\n        if( $item['data']->get_shipping_class_id() == $class ){\n            foreach( $method_key_ids as $method_key_id ){\n                unset($rates[$method_key_id]); \/\/ Remove the targeted methods\n            }\n            break; \/\/ Stop the loop\n        }\n    }\n    return $rates;\n}<\/pre>\n\n\n\n

Replace 100 with your original class id<\/p>\n\n\n\n

Finding the shipping class ID.<\/strong><\/p>\n\n\n\n

1) In the database under wp_terms<\/code> table:<\/p>\n\n\n\n

Search for a term name or a term slug and you will get the term ID (the shipping class ID).<\/p>\n\n\n\n

Replace flat_rate:7, local_pickup:3 with your shipping methods name that you would like to hide.<\/p>\n\n\n\n

To get the related\u00a0shipping methods rate IDs<\/strong>, something like\u00a0flat_rate:<\/code><\/strong>7, inspect with your browser code inspector each related radio button attribute\u00a0name<\/code><\/strong>\u00a0like:<\/p>\n\n\n\n

\"enter<\/a><\/figure>\n","protected":false},"excerpt":{"rendered":"

Are you finding ways to hide shipping methods when Free Shipping is enabled? Trying to hide shipping methods for Shipping<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[176],"tags":[185,98],"class_list":["post-605","post","type-post","status-publish","format-standard","hentry","category-woocommerce","tag-shipping-class","tag-woocommerce"],"yoast_head":"\nHow to hide shipping methods for specific shipping class in WooCommerce - WordPress Support<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/shaplakanon.com\/wpsupport\/how-to-hide-shipping-methods-for-specific-shipping-class-in-woocommerce\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to hide shipping methods for specific shipping class in WooCommerce - WordPress Support\" \/>\n<meta property=\"og:description\" content=\"Are you finding ways to hide shipping methods when Free Shipping is enabled? Trying to hide shipping methods for Shipping\" \/>\n<meta property=\"og:url\" content=\"https:\/\/shaplakanon.com\/wpsupport\/how-to-hide-shipping-methods-for-specific-shipping-class-in-woocommerce\/\" \/>\n<meta property=\"og:site_name\" content=\"WordPress Support\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/facebook.com\/getwpsupport\/\" \/>\n<meta property=\"article:published_time\" content=\"2019-12-03T03:38:31+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-12-03T03:38:34+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/i.stack.imgur.com\/AlATr.png\" \/>\n<meta name=\"author\" content=\"Ruhul Amin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@ruhul24\" \/>\n<meta name=\"twitter:site\" content=\"@ruhul24\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ruhul Amin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/how-to-hide-shipping-methods-for-specific-shipping-class-in-woocommerce\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/how-to-hide-shipping-methods-for-specific-shipping-class-in-woocommerce\/\"},\"author\":{\"name\":\"Ruhul Amin\",\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/#\/schema\/person\/f5f224239283c27426dadc2e4cc9a825\"},\"headline\":\"How to hide shipping methods for specific shipping class in WooCommerce\",\"datePublished\":\"2019-12-03T03:38:31+00:00\",\"dateModified\":\"2019-12-03T03:38:34+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/how-to-hide-shipping-methods-for-specific-shipping-class-in-woocommerce\/\"},\"wordCount\":153,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/#organization\"},\"image\":{\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/how-to-hide-shipping-methods-for-specific-shipping-class-in-woocommerce\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i.stack.imgur.com\/AlATr.png\",\"keywords\":[\"shipping class\",\"woocommerce\"],\"articleSection\":[\"Woocommerce\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/shaplakanon.com\/wpsupport\/how-to-hide-shipping-methods-for-specific-shipping-class-in-woocommerce\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/how-to-hide-shipping-methods-for-specific-shipping-class-in-woocommerce\/\",\"url\":\"https:\/\/shaplakanon.com\/wpsupport\/how-to-hide-shipping-methods-for-specific-shipping-class-in-woocommerce\/\",\"name\":\"How to hide shipping methods for specific shipping class in WooCommerce - WordPress Support\",\"isPartOf\":{\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/how-to-hide-shipping-methods-for-specific-shipping-class-in-woocommerce\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/how-to-hide-shipping-methods-for-specific-shipping-class-in-woocommerce\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i.stack.imgur.com\/AlATr.png\",\"datePublished\":\"2019-12-03T03:38:31+00:00\",\"dateModified\":\"2019-12-03T03:38:34+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/how-to-hide-shipping-methods-for-specific-shipping-class-in-woocommerce\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/shaplakanon.com\/wpsupport\/how-to-hide-shipping-methods-for-specific-shipping-class-in-woocommerce\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/how-to-hide-shipping-methods-for-specific-shipping-class-in-woocommerce\/#primaryimage\",\"url\":\"https:\/\/i.stack.imgur.com\/AlATr.png\",\"contentUrl\":\"https:\/\/i.stack.imgur.com\/AlATr.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/how-to-hide-shipping-methods-for-specific-shipping-class-in-woocommerce\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/shaplakanon.com\/wpsupport\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to hide shipping methods for specific shipping class in WooCommerce\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/#website\",\"url\":\"https:\/\/shaplakanon.com\/wpsupport\/\",\"name\":\"WordPress Support\",\"description\":\"Wordpress Repair, migration, speed optimization\",\"publisher\":{\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/shaplakanon.com\/wpsupport\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/#organization\",\"name\":\"WordPress Support\",\"url\":\"https:\/\/shaplakanon.com\/wpsupport\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/shaplakanon.com\/wpsupport\/wp-content\/uploads\/sites\/2\/2022\/05\/cropped-logo-9674824.png\",\"contentUrl\":\"https:\/\/shaplakanon.com\/wpsupport\/wp-content\/uploads\/sites\/2\/2022\/05\/cropped-logo-9674824.png\",\"width\":274,\"height\":55,\"caption\":\"WordPress Support\"},\"image\":{\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/facebook.com\/getwpsupport\/\",\"https:\/\/x.com\/ruhul24\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/#\/schema\/person\/f5f224239283c27426dadc2e4cc9a825\",\"name\":\"Ruhul Amin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/shaplakanon.com\/wpsupport\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/28178d347289d520b52ece250f7042df?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/28178d347289d520b52ece250f7042df?s=96&d=mm&r=g\",\"caption\":\"Ruhul Amin\"},\"sameAs\":[\"https:\/\/shaplakanon.com\/wdc\/\"],\"url\":\"https:\/\/shaplakanon.com\/wpsupport\/author\/sabahat\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to hide shipping methods for specific shipping class in WooCommerce - WordPress Support","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/shaplakanon.com\/wpsupport\/how-to-hide-shipping-methods-for-specific-shipping-class-in-woocommerce\/","og_locale":"en_US","og_type":"article","og_title":"How to hide shipping methods for specific shipping class in WooCommerce - WordPress Support","og_description":"Are you finding ways to hide shipping methods when Free Shipping is enabled? Trying to hide shipping methods for Shipping","og_url":"https:\/\/shaplakanon.com\/wpsupport\/how-to-hide-shipping-methods-for-specific-shipping-class-in-woocommerce\/","og_site_name":"WordPress Support","article_publisher":"https:\/\/facebook.com\/getwpsupport\/","article_published_time":"2019-12-03T03:38:31+00:00","article_modified_time":"2019-12-03T03:38:34+00:00","og_image":[{"url":"https:\/\/i.stack.imgur.com\/AlATr.png"}],"author":"Ruhul Amin","twitter_card":"summary_large_image","twitter_creator":"@ruhul24","twitter_site":"@ruhul24","twitter_misc":{"Written by":"Ruhul Amin","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/shaplakanon.com\/wpsupport\/how-to-hide-shipping-methods-for-specific-shipping-class-in-woocommerce\/#article","isPartOf":{"@id":"https:\/\/shaplakanon.com\/wpsupport\/how-to-hide-shipping-methods-for-specific-shipping-class-in-woocommerce\/"},"author":{"name":"Ruhul Amin","@id":"https:\/\/shaplakanon.com\/wpsupport\/#\/schema\/person\/f5f224239283c27426dadc2e4cc9a825"},"headline":"How to hide shipping methods for specific shipping class in WooCommerce","datePublished":"2019-12-03T03:38:31+00:00","dateModified":"2019-12-03T03:38:34+00:00","mainEntityOfPage":{"@id":"https:\/\/shaplakanon.com\/wpsupport\/how-to-hide-shipping-methods-for-specific-shipping-class-in-woocommerce\/"},"wordCount":153,"commentCount":0,"publisher":{"@id":"https:\/\/shaplakanon.com\/wpsupport\/#organization"},"image":{"@id":"https:\/\/shaplakanon.com\/wpsupport\/how-to-hide-shipping-methods-for-specific-shipping-class-in-woocommerce\/#primaryimage"},"thumbnailUrl":"https:\/\/i.stack.imgur.com\/AlATr.png","keywords":["shipping class","woocommerce"],"articleSection":["Woocommerce"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/shaplakanon.com\/wpsupport\/how-to-hide-shipping-methods-for-specific-shipping-class-in-woocommerce\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/shaplakanon.com\/wpsupport\/how-to-hide-shipping-methods-for-specific-shipping-class-in-woocommerce\/","url":"https:\/\/shaplakanon.com\/wpsupport\/how-to-hide-shipping-methods-for-specific-shipping-class-in-woocommerce\/","name":"How to hide shipping methods for specific shipping class in WooCommerce - WordPress Support","isPartOf":{"@id":"https:\/\/shaplakanon.com\/wpsupport\/#website"},"primaryImageOfPage":{"@id":"https:\/\/shaplakanon.com\/wpsupport\/how-to-hide-shipping-methods-for-specific-shipping-class-in-woocommerce\/#primaryimage"},"image":{"@id":"https:\/\/shaplakanon.com\/wpsupport\/how-to-hide-shipping-methods-for-specific-shipping-class-in-woocommerce\/#primaryimage"},"thumbnailUrl":"https:\/\/i.stack.imgur.com\/AlATr.png","datePublished":"2019-12-03T03:38:31+00:00","dateModified":"2019-12-03T03:38:34+00:00","breadcrumb":{"@id":"https:\/\/shaplakanon.com\/wpsupport\/how-to-hide-shipping-methods-for-specific-shipping-class-in-woocommerce\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/shaplakanon.com\/wpsupport\/how-to-hide-shipping-methods-for-specific-shipping-class-in-woocommerce\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/shaplakanon.com\/wpsupport\/how-to-hide-shipping-methods-for-specific-shipping-class-in-woocommerce\/#primaryimage","url":"https:\/\/i.stack.imgur.com\/AlATr.png","contentUrl":"https:\/\/i.stack.imgur.com\/AlATr.png"},{"@type":"BreadcrumbList","@id":"https:\/\/shaplakanon.com\/wpsupport\/how-to-hide-shipping-methods-for-specific-shipping-class-in-woocommerce\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/shaplakanon.com\/wpsupport\/"},{"@type":"ListItem","position":2,"name":"How to hide shipping methods for specific shipping class in WooCommerce"}]},{"@type":"WebSite","@id":"https:\/\/shaplakanon.com\/wpsupport\/#website","url":"https:\/\/shaplakanon.com\/wpsupport\/","name":"WordPress Support","description":"Wordpress Repair, migration, speed optimization","publisher":{"@id":"https:\/\/shaplakanon.com\/wpsupport\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/shaplakanon.com\/wpsupport\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/shaplakanon.com\/wpsupport\/#organization","name":"WordPress Support","url":"https:\/\/shaplakanon.com\/wpsupport\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/shaplakanon.com\/wpsupport\/#\/schema\/logo\/image\/","url":"https:\/\/shaplakanon.com\/wpsupport\/wp-content\/uploads\/sites\/2\/2022\/05\/cropped-logo-9674824.png","contentUrl":"https:\/\/shaplakanon.com\/wpsupport\/wp-content\/uploads\/sites\/2\/2022\/05\/cropped-logo-9674824.png","width":274,"height":55,"caption":"WordPress Support"},"image":{"@id":"https:\/\/shaplakanon.com\/wpsupport\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/facebook.com\/getwpsupport\/","https:\/\/x.com\/ruhul24"]},{"@type":"Person","@id":"https:\/\/shaplakanon.com\/wpsupport\/#\/schema\/person\/f5f224239283c27426dadc2e4cc9a825","name":"Ruhul Amin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/shaplakanon.com\/wpsupport\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/28178d347289d520b52ece250f7042df?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/28178d347289d520b52ece250f7042df?s=96&d=mm&r=g","caption":"Ruhul Amin"},"sameAs":["https:\/\/shaplakanon.com\/wdc\/"],"url":"https:\/\/shaplakanon.com\/wpsupport\/author\/sabahat\/"}]}},"_links":{"self":[{"href":"https:\/\/shaplakanon.com\/wpsupport\/wp-json\/wp\/v2\/posts\/605"}],"collection":[{"href":"https:\/\/shaplakanon.com\/wpsupport\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/shaplakanon.com\/wpsupport\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/shaplakanon.com\/wpsupport\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/shaplakanon.com\/wpsupport\/wp-json\/wp\/v2\/comments?post=605"}],"version-history":[{"count":0,"href":"https:\/\/shaplakanon.com\/wpsupport\/wp-json\/wp\/v2\/posts\/605\/revisions"}],"wp:attachment":[{"href":"https:\/\/shaplakanon.com\/wpsupport\/wp-json\/wp\/v2\/media?parent=605"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/shaplakanon.com\/wpsupport\/wp-json\/wp\/v2\/categories?post=605"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/shaplakanon.com\/wpsupport\/wp-json\/wp\/v2\/tags?post=605"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}