Title: Shipping method problem
Last modified: March 12, 2020

---

# Shipping method problem

 *  Resolved [Webcrashpilot](https://wordpress.org/support/users/webcrashpilot/)
 * (@webcrashpilot)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/shipping-method-problem-2/)
 * After update to woocommerce 4.00 the shipping method for Switzerland is missing
   unless a canton (state) is set. For other countries like Germany and Austria 
   it is not necessary to set a state, only for Switzerland. Before the update it
   was not necessary for Switzerland too.
 * Does this have something to do with the following update?
 * “Tweak – Update ‚Country‘ to ‚Country / Region‘ label. #25530”
 * If yes, how can I solve the problem?

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

 *  Thread Starter [Webcrashpilot](https://wordpress.org/support/users/webcrashpilot/)
 * (@webcrashpilot)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/shipping-method-problem-2/#post-12540726)
 * The problem is still unsolved. The problems occurs in the cart and the checkout
   page. Swiss customers need to select a state (canton). Otherwise the shipping
   method is not selected.
 * This problem only occurs for customers with country “Switzerland” all other customers
   in all other countries do not need to choose a state. The shipping method is 
   selected also without a state selected.
 * How can I solve this problem? I didn’t have this problem before the update to
   woocommrece 4.0.
 *  [anone](https://wordpress.org/support/users/anone/)
 * (@anone)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/shipping-method-problem-2/#post-12541455)
 * I can confirm this issue for Australia and USA as well.
 *  [flatee](https://wordpress.org/support/users/flatee/)
 * (@flatee)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/shipping-method-problem-2/#post-12541930)
 * Same here.
 *  [flatee](https://wordpress.org/support/users/flatee/)
 * (@flatee)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/shipping-method-problem-2/#post-12541998)
 * [https://wordpress.org/support/topic/no-shipping-method-chosen-after-4-0-update/](https://wordpress.org/support/topic/no-shipping-method-chosen-after-4-0-update/)
 *  [flatee](https://wordpress.org/support/users/flatee/)
 * (@flatee)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/shipping-method-problem-2/#post-12542002)
 * the workaround with the filter worked for me in Switzerland – thanks [@anone](https://wordpress.org/support/users/anone/)
 * looking forward to update to 4.0.1
 *  Thread Starter [Webcrashpilot](https://wordpress.org/support/users/webcrashpilot/)
 * (@webcrashpilot)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/shipping-method-problem-2/#post-12542165)
 * I found a topic about this problem of last year.
    [https://wordpress.org/support/topic/woocommerce-checkout-hidden-state-field/](https://wordpress.org/support/topic/woocommerce-checkout-hidden-state-field/)
 * They say if the following code is put in the functions.php of the theme it works.
   `
   add_filter( 'woocommerce_states', 'xa_filter_woocommerce_states', 10, 1 );`
 * I use the storefront theme. It doesnt’ work for me. I get the following error:
 * `Warning: call_user_func_array() expects parameter 1 to be a valid callback, 
   function 'xa_filter_woocommerce_states' not found or invalid function name in`
 *  Thread Starter [Webcrashpilot](https://wordpress.org/support/users/webcrashpilot/)
 * (@webcrashpilot)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/shipping-method-problem-2/#post-12543344)
 * If you use storefront theme you cannot just put the code
 * `add_filter( 'woocommerce_states', 'xa_filter_woocommerce_states', 10, 1 );`
 * directly in the themes functions.php. It will create the following warning:
 * `Warning: call_user_func_array() expects parameter 1 to be a valid callback, 
   function 'xa_filter_woocommerce_states' not found or invalid function name in`
 * I have tried to put the code into:
 * functions.php
    storefront-woocommerce-functions.php storefront-woocoomerce-template-
   functions.php storefront-woocoomerce-template-hooks.php
 * The code works but I always get a warning and customers can see the warning in
   cart and checkout.
    -  This reply was modified 6 years, 2 months ago by [Webcrashpilot](https://wordpress.org/support/users/webcrashpilot/).
 *  Plugin Support [Kel C. a11n](https://wordpress.org/support/users/kellymetal/)
 * (@kellymetal)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/shipping-method-problem-2/#post-12555013)
 * Hi there [@webcrashpilot](https://wordpress.org/support/users/webcrashpilot/),
 * I see you had also opened a bug report in the GitHub repository for the WooCommerce
   plugin:
    [https://github.com/woocommerce/woocommerce/issues/25912](https://github.com/woocommerce/woocommerce/issues/25912)
 * There have been replies there from the developers and it looks like a fix has
   been prepared that should be released in the next version of WooCommerce in the
   coming days. Please keep an eye out for that release and update when you have
   a chance. As always, please make sure to take a full backup of your site prior
   to running updates.
 * Also, regarding your last questions about that snippet/error: the old post looks
   to be about the state field being hidden at Checkout, which would be different
   from this situation (where shipping methods don’t show unless a state is selected).
   Also, the error you are getting appears to be caused by not including the `xa_filter_woocommerce_states`
   function that was mentioned earlier in that thread.
 * For now, please watch for that new version of the plugin, which should include
   the fix from the developers.
    Thank you!
 *  [myBuzz](https://wordpress.org/support/users/mybuzz/)
 * (@mybuzz)
 * [6 years ago](https://wordpress.org/support/topic/shipping-method-problem-2/#post-12884291)
 * Webcrashpilot,
 * my config : wp 5.4.1 , wc 4.1.1 , storefront theme 2.5.6
 * I have still the same problem (Switzerland – French part) with my config and 
   I resolve this right now before a new update of woocommerce :
 * 1. I installed the plugin : WooCommerce Checkout Field Editor and add a new <
   select> with state ( with the name : Canton ) for each billing and shipping method(
   this is automatic, without coding )
    2. Put in the theme child functions.php 
   the above code :
 *     ```
       add_filter( 'gettext', 'my_text_strings', 20, 3);
   
       function my_text_strings( $translated, $text, $domain ) {
         $translated = str_ireplace( 'facultatif', 'obligatoire', $translated );
         return $translated;
       }
       ```
   
 * This is a method to change the text ( here in French ). In English is optional/
   required.
 * OK, with this method, we don’t see the apostrophe (*) but we have possibility
   to inform the customer this is a required cell.
 * Info for developers : I put a lot of possibilities, try to gettext everywhere
   and see in the upside code : it is impossible to change the normal text (facultatif).
   It’s put out automatic the ‘(‘ and ‘)’. This is reason I put only \facultatif\
   between the two ‘ ‘.
    The code is located as : `<span class="optional">(optional)
   </span>`
 * Hope this could be help
 * Regards
    -  This reply was modified 6 years ago by [myBuzz](https://wordpress.org/support/users/mybuzz/).
      Reason: add name of select Canton in order of state
    -  This reply was modified 6 years ago by [myBuzz](https://wordpress.org/support/users/mybuzz/).
      Reason: add translated text in English
 *  [kinmx](https://wordpress.org/support/users/kinmx/)
 * (@kinmx)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/shipping-method-problem-2/#post-13435946)
 * Hi! I have a question about the plugin. I´m actually use de free version since
   3 years ago and never have a problem. But recently, the plugin ask me to update,
   so I decide to do it (i have to update the php version of my page in order to
   update woocommerce) and now i have a problem in the shipping. I can’t modify 
   or add a shipping area or shipping method. Every time i try to click in the button
   of add shipping method (or create a shipping area) just reload the page but it
   doesn’t give any option (flat rate, or any other option) Any idea of the problem?
   Also, I deactivate all the plugins (extensions) that can affect woocommerce like
   woocommerce payments, etc. but still the same, just reload the page but not options.
   
   What can i do to fix it?

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

The topic ‘Shipping method problem’ 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/)

 * 10 replies
 * 6 participants
 * Last reply from: [kinmx](https://wordpress.org/support/users/kinmx/)
 * Last activity: [5 years, 8 months ago](https://wordpress.org/support/topic/shipping-method-problem-2/#post-13435946)
 * Status: resolved