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.

Free Shipping with Multiple Flat Rates

mreeemreee Member
in Help edited July 2013
I am using the multiple flat rate shipping option with different rates for domestic and international.

I want to have free shipping over $50. Everything I have found in the scripts/forums seems to be conflicting and I can't get it working.

Any help is greatly appreciated.
Comments
  • fc_adamfc_adam FoxyCart Team
    @mreee,

    Could you confirm what you currently have? If you have it live on your checkout, you can simply link us to your add to carts
  • mreeemreee Member
    Right now I have one rate for domestic and international where the shipping increments with each item. I am trying to add
    <script type = "text/javascript"charset = "utf-8" >
    var myCustomShipping = function() {
    	jQuery("label[for='shipping_service_60']").hide();
    	if ($('#subtotal').val() > 50) {
    		jQuery("label[for='shipping_service_60']").show();
    	}
    }
    jQuery(document).ready(function() {
    	jQuery("#fc_shipping_methods_inner").ajaxComplete(function(event, request, settings) {
    		myCustomShipping();
    	});
    });
    </script>
    

    After my shipping code but it didn't seem to do anything.
  • fc_adamfc_adam FoxyCart Team
    @mreee,

    So what's happening there is you're mixing two different types of javascript approaches. You're currently creating your own shipping rates using the multiple flat rates snippet - and then the one you're trying to add is for live rates.

    What I'd suggest doing is just sticking to one or the other. From what I can see though, you should already be offering a free shipping option with the javascript you have. If the total is greater than $50, then the shipping cost is $0... Ah, I see now, switch your custom code out to this:
    if (sub_tot >= 50) {
      addShippingOption(3, 0, '', 'Free Shipping');
    } else if (country_code == "US") {
      postage = 4.9 * (fc_json.product_count);
      addShippingOption(1, postage, 'USPS', 'Standard');
    } else {
      postage = 9.9 * (fc_json.product_count);
      addShippingOption(2, postage, 'USPS', 'International');
    }
    

    Note how that first if statement now adds the free shipping block, that should work for you now.
  • mreeemreee Member
    Thanks!

    Im trying to make the free shipping US only but this isn't working:
    if (sub_tot >= 50) and (country_code == "US") {
      addShippingOption(3, 0, '', 'Free Shipping');
    } else if (country_code == "US") {
      postage = 4.9 * (fc_json.product_count);
      addShippingOption(1, postage, 'USPS', 'Standard');
    } else {
      postage = 9.9 * (fc_json.product_count);
      addShippingOption(2, postage, 'USPS', 'International');
    }
    

    Do you know what I'm doing wrong?
  • fc_adamfc_adam FoxyCart Team
    Change your first line to this:
    if (sub_tot >= 50 && country_code == "US") {
    
  • mreeemreee Member
    I am having a problem with the code. When The free shipping block it is giving free shipping all orders regardless of the price.
  • fc_adamfc_adam FoxyCart Team
    @mreee,

    I can't see that code on your checkout to see what might be the issue - but I did see one other issue:
    $("#fc_shipping_methods_inner label input[type='radio'").attr("checked", "checked");
    

    That line is missing a ] after 'radio'", so it should be:
    $("#fc_shipping_methods_inner label input[type='radio']").attr("checked", "checked");
    
  • mreeemreee Member
    Thanks for that fix!

    I don't want to leave the code on the page because the shop is live and I dont want people going through getting free shipping on all orders.
  • fc_adamfc_adam FoxyCart Team
    @mreee,

    Ah I see - you haven't specified the sub_tot variable. Update your first line like this:
    var sub_tot = fc_json.total_price;
    if (sub_tot >= 50 && country_code == "US") {
    

    That will be based off the total price, if you want literally the sub total before shipping and discounts, you'll want fc_json.total_item_price
  • mreeemreee Member
    Thank you.

    Its working in the dev site but on the production site the Shipping & Handling is not updated in the Shipping & Subtotal section.

    Free Shipping is showing up in the Shipping Options area but it is not updating the actual total.
  • fc_adamfc_adam FoxyCart Team
    @mreee,

    You've made an adjustment to the code to automatically check the rate entered into the page - but that doesn't make the totals update to take it into consideration. You'll need to make some adjustments to ensure that the code that is normally run when the radio input is clicked runs.

    Putting this at the end of your custom shipping logic should do just that:
    jQuery("#fc_shipping_methods_inner input[type='radio']:first").trigger("click");
    

    As per the documentation for the multiple flat rates snippet as well - you need to set your flat rate shipping in all of your categories to $0, otherwise the customer won't be able to get free shipping.
  • mreeemreee Member
    Thanks for your help. That got it working!
Sign In or Register to comment.