how to allow free domestic shipping for orders over a certain amount

brevitybrevity Member
I would like to offer free shipping to domestic US customers with purchases of $150 and up. I've searched the foxycart forums and came up with one that suggested the following snippet (https://forum.foxycart.com/discussion/10549/can-i-offer-free-shipping-for-orders-over-x-amount):

var products = 0;
// where x is the threshold amount
if (FC.json.total_item_price > 150) {
FC.customLiveShipping.add(300, 0, '', 'Free Shipping');
}

Using this, however, gives free shipping to international customers, as well, which I don't want. I tried to combine it with US only snippets I found on this page (https://wiki.foxycart.com/v/2.0/snippets/live_rate_shipping_modification), but it's not working for me (free shipping no longer shows up as an option). Any thoughts on how I can make this work?
Comments
  • fc_adamfc_adam FoxyCart Team
    edited June 23
    @brevity,

    You're really close there, you can expand the custom logic you pasted above to check that it's from the US like this:
    var products = 0;
    if (FC.json.total_item_price > 150 && FC.json.shipping_address.country == "US") {
    FC.customLiveShipping.add(300, 0, '', 'Free Shipping');
    }

    This still relies on the script being included within the live rates modification snippet
  • brevitybrevity Member
    That worked perfectly - thank you so much! :)
  • brevitybrevity Member
    One last question - Is there a way to make my USPS First class mail option disappear when free shipping is available (since that is how I would ship it - everything else would be an upgrade). Thank you!
  • fc_adamfc_adam FoxyCart Team
    @brevity,

    Indeed there is!
    var products = 0;
    if (FC.json.total_item_price > 150 && FC.json.shipping_address.country == "US") {
    FC.customLiveShipping.add(300, 0, '', 'Free Shipping');
    FC.customLiveShipping.hide("first-class mail");
    }
    That should hide any rates that contain the text "first-class mail".
Sign In or Register to comment.