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.

Javascript for shipping

zoomcreateszoomcreates Member
in Bugs & Feature Requests edited August 2010
Hello all, first time post here, so sorry if this has already been covered.

I've browsed a bunch of the posts about writing custom javascript for the shipping section of the checkout process. I've gotten close to a solution, but can't quite get there. Here's what is going on:

If a customer orders a bunch of products and they get over a total weight of 150 pounds, we loose all options except for the free customer pickup option. I'd love to just relabel this option, but only if it is the only option available to the customer. Something like "Your order is too heavy for automated shipping costs, so please call us at xxx-xxx-xxxx." and pass the free shipping option through for processing.

I've set up the override FC.checkout.override and have it running my code everytime the form is updated, but I don't want to run any changes unless the cost of the items is over 150 lbs.

Make sense? I guess if i got the code for the normal shipping stuff I could just put that in an if/else clause, unless there is a better option? Any help is greatly appreciated. Thanks.
  • fc_adamfc_adam FoxyCart Team
    edited August 2010
    @zoomcreates, can you link your checkout so we can see what you have already? You'll basically be checking the fc_json object for the total weight, which you can access by
  •, add an item to the cart, then go to checkout.

    I have an if statement checking fc_json.total_weight, but can't seem to get any shipping options when i use FC.checkout.override(functionA, functionB).

    Thanks for your help.
  • lukeluke FoxyCart Team
    Hey zoomcreates. It looks like you're not wanting to override the update shipping functionality as much as you'd like to run the normal process and then capture the case where you have no rates returned due to the weight of the items in the cart. Search the forum for ajaxComplete and you should find some examples to help you out. Basically that will allow you to fire off your code right after the AJAX rate request takes place (and before anything is displayed to the customer) and hide any errors that might be displayed there and replace them with your own custom message instead.

    Something like this:
    jQuery("#fc_shipping_methods_inner").ajaxComplete(function(event, request, settings) {
    if (fc_json.total_weight > 70) {
    jQuery(this).html("Your order is too heavy for automated shipping costs, so please call us at xxx-xxx-xxxx.");
    jQuery("#fc_complete_order_button_container").html("Please contact us to complete your order or limit the number of items in this order.");
  • This does look like the right track. I've tried to implement your code with a few modifications but it doesn't seem like it is working. I've searched the forums and wiki for ajaxComplete, but couldn't find anything. Do you have any links that you can send my way?
  • zoomcreateszoomcreates Member
    edited August 2010
    Ah-ha! I put that code inside of a $(document).ready(function() { //code goes here }); and it all started working.

    Thanks so much for the help!
  • fc_adamfc_adam FoxyCart Team
    Glad you got it working zoomcreates
Sign In or Register to comment.