Excluding certain state from being shipped to

Alright, I'm no programmer and I'm in need of some assistance. I have four different products that can no longer be shipped to Washington State. I know that there's a way to restrict shipping on all products to certain states with the code here (https://wiki.foxycart.com/snippets/shipping/restricting_countries_and_states_on_the_checkout), but is there any way that shipping won't be allowed to Washington for ONLY the four products? Something that would not allow a complete checkout if a customer has any of these products in their cart and selects WA as their shipping destination?

Full disclosure: We use the FoxyShop plugin for WP, and my support request through them pointed me to that code ^ and suggested maybe asking here if anyone can help out with writing the script.
Comments
  • fc_adamfc_adam FoxyCart Team
    @RyanWN,

    We'd be happy to help. Could you confirm your store version for us please?
  • RyanWNRyanWN Member
    We're using FoxyShop 4.6.1 on WordPress 4.2.2
  • fc_adamfc_adam FoxyCart Team
    @RyanWN,

    Sorry - I meant your FoxyCart store version.
  • RyanWNRyanWN Member
    @fc_adam

    Ah, sorry. FoxyCart 1.1

    Side note: I see that there's a 2.0 now, is there any advantage to switching to this new version? I'm concerned with upgrading, however, because we upgraded to the latest WordPress version and it screwed a whole bunch of stuff up.
  • fc_adamfc_adam FoxyCart Team
    edited June 2015
    @RyanWN,

    So for FoxyCart version 1.1, something like this would work - assuming that the four products were all part of a category on their own with a code of "widgets". You can change that within the below code to match the category code of the products. If they don't all share the same category - if you can let me know what other identifying information could be used, I'd be happy to help you adjust the code.
    var restricted = false;
    for (var p = 0; p < fc_json.products.length; p++) {
    if (fc_json.products[p].category == "widgets") {
    restricted = true;
    }
    }

    if (restricted) {
    FC.locations.removeStates('US', ['WA']);
    }
    Use that for the custom logic for the snippet you linked to in your initial post, and that should work for what you need - assuming you can pick the products based on the category.
    Side note: I see that there's a 2.0 now, is there any advantage to switching to this new version? I'm concerned with upgrading, however, because we upgraded to the latest WordPress version and it screwed a whole bunch of stuff up.
    There are some great new features and functionality in 2.0, along with bugfixes and stability improvements as well. We always recommend keeping as close to the latest stable release as possible.

    What we'd recommend doing though is setting up a test store and testing out the new version and upgrading there. It's free to have a test store for as long as you need it without paying anything, so you can test the new version and more generally any change you need to make in the future as well. That way you won't affect your live site and store with testing changes.
  • RyanWNRyanWN Member
    @fc_adam

    Awesome! Thanks for the help. I'll be implementing this tomorrow, I'll let you know if I need help with other identifying information.
Sign In or Register to comment.