Estimated Shipping Form (nopCommerce 3.80)

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 years ago
Hey guys,

I just wanted to suggest that there be some validation elements displayed on the 'Estimate Shipping' form when no ZIP code is submitted. Currently, no errors are shown when the ZIP code input is empty upon submission. All that is displayed is the 'In-Store Pickup' shipping method (estimate).

It also seems like the ZIP code should be labelled 'required', as many of the shipping rate calculators seem to use the ZIP to calculate rates.

Finally, hitting the 'Enter/Return' key while focused on these inputs submits the entire page's form. It does not submit just the 'Estimate Shipping' form (I know that there is not a separate form for 'Estimate Shipping'). It might be best to add some jQuery in 'EstimateShipping.cshtml' to listen for that keypress, prevent the form submission and instead conduct the Ajax request?

Thanks!
7 years ago
Hi Derek,

Thanks a lot. Here is a work item
7 years ago
Thanks Andrei!

I was working to resolve this yesterday, and I ended up putting the 'Estimate Shipping' form into a modal (we integrated Bootstrap into our theme). I like to keep things really modular. Also, Bootstrap suggests that modals be direct descendants of the '<body>' tag. This left me wondering, is there a '@section' (or something else) that allows us to the top or bottom of the page from inside of a View?

For example, from within '/Themes/MyTheme/Views/ShoppingCart/EstimateShipping.cshtml', how could I do something like:

@section before_closing_body_tag {
    <div class="modal" id="estimate-shipping-modal" aria-hidden="true">
        <form id="estimate-shipping-form" action="@(Url.RouteUrl("EstimateShipping"))" method="post">
            ...
        </form>
        <script>
        $(document).ready(function() {
            $('#estimate-shipping-form').on('submit', function( ev ) {
                ev.preventDefault();

                $('.estimate-shipping-result').empty();
                displayAjaxLoading( true );
                $.ajax({
                    cache: false,
                    type: $(this).attr('method'),
                    url: $(this).attr('action'),
                    data: $(this).serialize(),
                    success: function(data) {
                        $('.estimate-shipping-result').html( data );
                    },
                    error: function(xhr, ajaxOptions, thrownError) {
                        alert('Failed to retrieve shipping estimate!');
                    },
                    complete: function(xhr, thrownCode) {
                        displayAjaxLoading();
                    }
                });
            });
        });
        </script>
    </div>
}
6 years ago
IMHO, The Estimate Shipping should also respect the setting shippingsettings.returnvalidoptionsifthereareany for Pickup In Store. I.e. if False, and there are Errors, then Pickup In Store should not show. (Just the errors should show).

(I've suggested it in the work item ;)
6 years ago
Hey

the work item is closed, now ZIP code is required  in the Estimated Shipping form. Commit 1 and commit 2.
4 years ago
will it works in 4.10??
4 years ago
Yes, Zip Code is required for estimated shipping in 4.10.  You can test it in the demo http://demo.nopcommerce.com/cart
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.