Title: Default shipping method checked
Last modified: November 12, 2021

---

# Default shipping method checked

 *  Resolved [nicetig](https://wordpress.org/support/users/nicetig/)
 * (@nicetig)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/default-shipping-method-checked/)
 * I’ve created only 1 shipping method with 1 flat rate option. how do i make it
   auto checked on my checkout page as it won’t allow me to select / click on the
   radio button.
    screenshot at [https://imgur.com/a/2ZqratB](https://imgur.com/a/2ZqratB)
 * Thanks in advance.

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

 *  [Ahir Hemant](https://wordpress.org/support/users/hemant-ahir/)
 * (@hemant-ahir)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/default-shipping-method-checked/#post-15062604)
 * Hi [@nicetig](https://wordpress.org/support/users/nicetig/)
 *     ```
       add_action( 'woocommerce_before_checkout_form', 'ahir_select_free_shipping_by_default' );
       function ahir_select_free_shipping_by_default() {
           if ( isset(WC()->session) && ! WC()->session->has_session() )
               WC()->session->set_customer_session_cookie( true );
   
           // Check if "free shipping" is already set
           if ( strpos( WC()->session->get('chosen_shipping_methods')[0], 'free_shipping' ) !== false )
               return;
   
           // Loop through shipping methods
           foreach( WC()->session->get('shipping_for_package_0')['rates'] as $key => $rate ){
               if( $rate->method_id === 'free_shipping' ){
                   // Set "Free shipping" method
                   WC()->session->set( 'chosen_shipping_methods', array($rate->id) );
                   return;
               }
           }
       }
       ```
   
 * Code goes in function.php file of your active child theme (or active theme). 
   tested and works.
 * Please change code based on your shipping method name.
 * Thanks
    Ahir Hemant
 *  Thread Starter [nicetig](https://wordpress.org/support/users/nicetig/)
 * (@nicetig)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/default-shipping-method-checked/#post-15063968)
 * thanks Ahir,
 * I’ve changed ‘free_shipping’ to ‘flat_rate1’ but still not able to get it to 
   work?
 *     ```
       add_action( 'woocommerce_before_checkout_form', 'ahir_select_free_shipping_by_default' );
       function ahir_select_free_shipping_by_default() {
           if ( isset(WC()->session) && ! WC()->session->has_session() )
               WC()->session->set_customer_session_cookie( true );
   
           // Check if "free shipping" is already set
           if ( strpos( WC()->session->get('chosen_shipping_methods')[0], 'flat_rate1' ) !== false )
               return;
   
           // Loop through shipping methods
           foreach( WC()->session->get('shipping_for_package_0')['rates'] as $key => $rate ){
               if( $rate->method_id === 'flat_rate1' ){
                   // Set "Free shipping" method
                   WC()->session->set( 'chosen_shipping_methods', array($rate->id) );
                   return;
               }
           }
       }
       ```
   
 * `
 *  [Igor H](https://wordpress.org/support/users/ihereira/)
 * (@ihereira)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/default-shipping-method-checked/#post-15064660)
 * Hello there,
 * Can you please share with us the website URL when the issue is present?
 * Also, please provide screenshots of shipping zones, their methods, and shipping
   rates so that we can check this further for you much better.
 * For screenshots you can use [https://snipboard.io](https://snipboard.io) – please
   follow the instructions on the page, then paste the URL in this chat. It works
   with Chrome, Firefox, Safari, and Edge.
 *  Thread Starter [nicetig](https://wordpress.org/support/users/nicetig/)
 * (@nicetig)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/default-shipping-method-checked/#post-15069325)
 * Hi Igor,
 * Thanks, link to the site [https://bit.ly/3Cc0qJO](https://bit.ly/3Cc0qJO) and
   screenshots below.
 * [https://snipboard.io/La1ViE.jpg](https://snipboard.io/La1ViE.jpg)
    [https://snipboard.io/sv7cbR.jpg](https://snipboard.io/sv7cbR.jpg)
   [https://snipboard.io/Uzx1ah.jpg](https://snipboard.io/Uzx1ah.jpg)
 *  [Rashed Ripon (a11n)](https://wordpress.org/support/users/rur165/)
 * (@rur165)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/default-shipping-method-checked/#post-15141432)
 * Hello [@nicetig](https://wordpress.org/support/users/nicetig/) ,
 * Thanks for the link to your site.
 * I can see that the “Flat-rate” shipping method can’t be selected.
 * Have you tried with a default theme like Storefront to see if the problem is 
   with your current theme?
 * You can try after enabling troubleshoot mode using the Health Check: [https://wordpress.org/plugins/health-check/](https://wordpress.org/plugins/health-check/)
   plugin to safely enable troubleshooting mode and deactivate plugins, themes without
   affecting how your site is available to the visitors. See Troubleshooting using
   Health Check: [https://docs.woocommerce.com/document/troubleshooting-using-health-check/](https://docs.woocommerce.com/document/troubleshooting-using-health-check/)
   for more details.
 * For more detailed instructions on conflict test, check out How to test for plugin
   and theme conflicts: [https://docs.woocommerce.com/document/how-to-test-for-conflicts/](https://docs.woocommerce.com/document/how-to-test-for-conflicts/)
 * Let us know how the test goes.
 *  [Mirko P.](https://wordpress.org/support/users/rainfallnixfig/)
 * (@rainfallnixfig)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/default-shipping-method-checked/#post-15164370)
 * Hi there,
 * It’s been a while since we last heard back from you. I’m going to mark this thread
   as resolved.
 * Hopefully, you were able to find a way forward with the issue – we’ll be here
   if and/or when you are ready to continue.

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

The topic ‘Default shipping method checked’ 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

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

 * 6 replies
 * 5 participants
 * Last reply from: [Mirko P.](https://wordpress.org/support/users/rainfallnixfig/)
 * Last activity: [4 years, 3 months ago](https://wordpress.org/support/topic/default-shipping-method-checked/#post-15164370)
 * Status: resolved