The Foxy forums are on the move!

We're in the process of moving our forums over to a new system, and so these forums are now read-only.
If you have a question about your store in the meantime, please don't hesitate to reach out to us via email.

How to have a specifc category only be able to be shipped to certains cities

I'am creating a new category on my shop, but the items that will be sold can not be shipped to all cities or estates. Is possible to have a preset list of cities and its estates? So the costumer should pick one like a drop down.
  • fc_adamfc_adam FoxyCart Team

    Good question. One approach you could take is to add in a custom checkout field that displays the dropdown if the customer has at least one product from that category. You can make the dropdown a required field so the customer has to select an option. It would be separate from their normal address though, just to be clear. As an example of that:
    {% set destinations = ["City 1", "City 2", "City 3", "City 4", "City 5"] %}
    {% set has_category = false %}
    {% for item in items %}
    {% if item.category == "my-category-code" %}
    {% set has_category = true %}
    {% endif %}
    {% endfor %}

    {% if has_category and destinations|length > 0 %}
    <div class="fc-form-group">
    <div class="col-md-8 col-md-offset-3" data-fc-error-for="destination" data-fc-error-class="fc-alert-container--error">
    <div class="fc-input-group-container fc-input-group-container--checkbox fc-input-group-container--active">
    <label class="fc-input-group-container__title fc-input-group-container__title--forced fc-form-label">
    <div class="fc-form-group">
    <select name="destination" id="destination" class="fc-form-control" aria-required="true" data-fc-required>
    <option value="">Please select your city</option>
    {% for city in destinations %}
    <option value="{{ city }}" {% if destination == city %}selected{% endif %}>{{ city }}</option>
    {% endfor %}
    {% endif %}
    You mentioned estates there as well. I'm not sure if that's something the customer would already be filling out on their set up - but if it's something you can reliably filter on based on customer input (for example on the postcode), then you could also add custom validations using javascript and/or with the pre-payment webhook. That would stop the customer from having to re-select a portion of their address, but relies on being able to cleanly filter based on customer input.
Sign In or Register to comment.