• Resolved protosoftwareraymond

    (@protosoftwareraymond)


    Hi,

    I am developing a website for a client.

    They are only dealing with 2 counties in Northern Ireland so I used the following code (in my functions.php file) to override the Counties on the UK dropdown

    function custom_woocommerce_states( $states ) {
    
      $states['GB'] = array(
        'FER' =>'FERMANAGH',
    	'TYR' =>'TYRONE'
      );
    
      return $states;
    }

    This works fine. I’ve also set up a shipping zone so that if a visitor enters a postcode outside of a list they are told there are no shipping methods for the postcode.

    I added “FERMANAGH” and “TYRONE” as created above to this shipping zone.

    However, when checking out, after entering the relevant information and hitting Update the calculation for shipping doesn’t happen and the “Enter your address to view shipping options” appears again. I checked the console log in the browser and there are no errors.

    If I remove my custom state code and check out, the postcode check works fine.

    So the question would be can shipping zones be applied correctly to a custom state?

    Cheers!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Riaan K.

    (@riaanknoetze)

    Hi there,

    Just to check: Which filter are you using for your custom_woocommerce_states function? Do you have any restrictions on the countries/states the shop is allowed to sell/ship to (found under **WooCommerce > Settings > General**)?

    To answer your question though: Yes, shipping zones can be configured for custom states in WooCommerce. This is also the premise of one of the extensions on the marketplace: https://woocommerce.com/products/shipping-locations-pro/

    Thread Starter protosoftwareraymond

    (@protosoftwareraymond)

    Hi,

    I’m not using any filter on the function. When I add the function, it replaces the default “States” within UK to Tyrone & Fermanagh – should I have a filter applied?

    Essentially what I’m trying to do is have the country hidden from the user and have the custom shipping zones still function.

    Hi,

    * Can you please share a copy of your site’s System Status? It is under WooCommerce > Status. Select “Get system report” and then “Copy for support”. 

    * Also, please share a copy of any fatal error log found under WooCommerce > System Status > Logs (if any).

    * Under WooCommerce > settings > shipping can you please attach screenshots of your shipping zones, shipping options, shipping classes, and conditions.

    For screenshots you can use https://snipboard.io – please follow the instructions on that page, then paste the Screenshot URL in this thread.

    That will allow taking a better look. Thank you.

    Thread Starter protosoftwareraymond

    (@protosoftwareraymond)

    Hi,

    Figured it out! The install is fine but when I was hiding the field the field itself wasn’t being posted so the calculating shipping function was breaking.

    However, when I used CSS to hide the field instead – it worked fine!

    Thank you!

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

The topic ‘Shipping Zone on Custom State doesn’t work’ is closed to new replies.