• Resolved peregrine12

    (@peregrine12)


    My client wants to be able to sell to any continental US State, but exclude shipping to Florida. I have scoured and tested, but I can’t get it to work. I was able to override the $states values but that applies to both billing and shipping. How can I exclude, say Florida, from ONLY the shipping list. Thanks for any help.

    The page I need help with: [log in to see the link]

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Support Praveen a11n

    (@spraveenitpro)

    Automattic Happiness Engineer

    Hi @peregrine12,

    You could customize this snippet to exclude Florida: https://www.speakinginbytes.com/2013/12/ship-continental-us/

    Cheers,

    Thread Starter peregrine12

    (@peregrine12)

    Praveen,

    Thank you so much for your considerate response and the snippet. However, I added it to my functions.php and it does not exclude the states. I tried the various options on https://gist.github.com/BFTrick/7805588 and they don’t work (I actually posted a comment at the end of that). The last function works but that applies to all state lists and I need shipping only. Any other suggestions?

    Thanks,
    Dave

    Thread Starter peregrine12

    (@peregrine12)

    Any help on this from someone? My client is waiting to go live. Thank you.

    I would expect this to work:
    Dashboard > WooCommerce > Settings > Shipping > Add Shipping Zone
    call it say Custom States List
    Edit
    then at Zone regions, add the other 49 states. A bit tedious but no code needed.

    Thread Starter peregrine12

    (@peregrine12)

    Thanks, but doesn’t work. The excluded states still show in the shipping dropdown list.

    Try this snippet:

    add_filter( 'woocommerce_states', 'custom_woocommerce_states' );
    function custom_woocommerce_states( $states ) {
      $states['US'] = array(
        'AL' => __( 'Alabama', 'woocommerce' ),
        'AK' => __( 'Alaska', 'woocommerce' ),
        'AZ' => __( 'Arizona', 'woocommerce' ),
        'AR' => __( 'Arkansas', 'woocommerce' ),
      );
      return $states;
    }

    You can get the full list from:
    wp-plugins/woocommerce/i18n/states/us.php
    then delete the non-continental lines. If you want to sell to Florida, leave it in.

    The thing is, you can’t sell to a state you don’t ship to. If a Floridian tries to make a purchase, they would get a “No shipping methods exist for your location” error.

    “Ship” is a wide term and can mean any method, not just post. So, if you want to sell to Florida, you will need to set it up as shipping zone with a shipping method, local pickup for example. You can change the name “local pickup” to reflect however a Floridian would get the goods if you do not ship there.

    Thread Starter peregrine12

    (@peregrine12)

    Thanks, Lorro. Based on your explanation I think we need to re-consider the approach. Probably not selling to FL is the only way.

    @lorro, I needed to exclude a state from my store (Hawaii). Adding your snippet to my child theme’s functions.php, removing the line for Hawaii, did the trick!

    Thanks!
    Susan

    Yes it works. Do you have an idea if a city is not attached to a particular state?

    • This reply was modified 5 years, 6 months ago by sevun.
    • This reply was modified 5 years, 6 months ago by sevun.

    @sevun
    Sorry, I don’t understand. Please give an example.

    I need to exclude Vatican or Saint Marin in Italy but they are not Province of Italy. Should I just create Province and not add them?

    The Vatican and Saint Marin are not states which are part of Italy – they are separate countries.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘exclude state from only shipping option’ is closed to new replies.