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.

Preselect shipping option

Hey there,

With the old flat rate snippet i was able to make it work so that a shipping option was preselected once the user enters a post code.

However with the new custom shipping endpoint (which works good) there is no such way. Any idea how to do that? Otherwise maybe create a ticket for that.

BTW: Are you interested in a Java Library for the shipping endpoint? Currently there is helper library for php and js, we are using java, so probably we will convert it for java and can then send it to you guys.
Comments
  • fc_adamfc_adam FoxyCart Team
    @fileee,

    Good question, and we actually had someone ask just the same thing today! Something as simple as this added to your custom footer should replicate that experience:
    <script>FC.client.on("cart-shipping-options-update.done", autoSelectRate);
    FC.client.on("checkout-shipping-options-update.done", autoSelectRate);

    function autoSelectRate() {
    jQuery("[name='shipping_service_id']:first").attr("checked", "checked").trigger("click");
    if (FC.json.context == "cart") {
    FC.Template(FC.json.context).clearOutput();
    FC.cart.showShippingLocationInput();
    }
    }</script>
    In terms of a java endpoint - if you were happy to share that with the community, we'd certainly be happy to link to it from our wiki for sure!
  • thx, seems to work. just changed the selector to select to right one and not just the first shipping option. Perfect
  • Not sure if this is asking the same thing....I'd like to limit our customers' shipping options based on where they are shipping to. Our product is perishable and we are in Texas. Is there a way to give them the option of Fedex Home Delivery, Ground and Express if they are shipping in state, but if they are shipping out of state they only get the Express option?
  • fc_adamfc_adam FoxyCart Team
    @Dairymaidl,

    What you're after is slightly different, which is restricting what rates are available to the customer. For that you'll use the Live Rates Shipping Modification snippet available at https://wiki.foxycart.com/v/2.0/snippets/live_rate_shipping_modification if you're on 2.0, or from https://wiki.foxycart.com/snippets/shipping/live_rate_shipping_modification for older versions.
Sign In or Register to comment.