International Shipping

KNickKNick Member
in Help edited December 2012
I represent a company that sells musical instruments and accompanying accessories. We have a rather interesting method for shipping on complete instruments. If we ship an instrument to a customer internationally (outside the US) we use FedEx's GreatRates service, which gives a fluctuating price scheme depending on when the product is shipping, available space, and destination. So because this is so tricky and unpredictable, we've decided for international orders only we are going to collect a $100 shipping "deposit" up front from international customers. If the cost to ship is less than that, we'll refund them the difference. If the cost is more, we contact them and charge them what remains. Shipping on these instruments is free to the continental US.

The tricky part is programming this into our cart. I have products in two categories to which this shipping pricing scheme would apply. Essentially my question is how would I program the cart to charge an additional $100 flat rate to customers who buy products from these categories and choose to ship internationally, as well as to Alaska and Hawaii?

Thanks in advance for everyone's help!
Comments
  • fc_adamfc_adam FoxyCart Team
    @KNick,

    Do you use straight live rates for domestic orders (apart from Alaska and Hawaii)? If so, I'd recommend using the Live Rate Shipping Modification snippet here: http://wiki.foxycart.com/snippets/shipping/live_rate_shipping_modification

    You'd then remove all other options and display a $100 shipping deposit as the only option if the customer is not from continental US.
  • @fc_adam,

    Domestic shipping to the continental US is free. I'm not extremely fluid with Javascript yet so I don't know how much I could modify the coe, but according to that page it applies to live rates only anyway.
  • fc_adamfc_adam FoxyCart Team
    @KNick,

    So in that case, you'd use one of the flat rate options, depending how you want to display the deposit. If you want it as a radio button so the customer has to select it, use the Multiple Flat Rate's option - otherwise if you just want to add a $100 shipping fee, use the Tiered Flat Rate's option on our snippets page: http://wiki.foxycart.com/snippets/start
  • This looks like it should work. However, we do have products in more than just these two categories. They ship with a flat-rate fee in the US, and a different flat-rate fee abroad. This script looks as though it will charge customers $100 in shipping regardless of the product category. Is there a way to modify this so we will be able to set up the different parameters for these categories, or is there a way to make this script apply to only two categories of items?
  • fc_adamfc_adam FoxyCart Team
    @KNick,

    You can set up your conditionals however you want. If it only applies to two categories, then you would loop through the products in the cart, checking if either of those categories are present. Then, only if they're present, and the customer isn't from the continental US, you would add the $100 deposit for shipping.
  • KNickKNick Member
    edited January 2013
    @fc_adam

    Apologies for resurrecting my old thread but this issue has come up again and it appears I still need some help.

    We're now charging 250 flat rate international to everywhere except Canada, Alaska, and Hawaii (same price for each of them), and the continental US is still free.

    I've plugged the code from the Tiered Flat Rate Shipping snippet into Dreamweaver and modified it. Here's what I have so far:
    <script type="text/javascript" charset="utf-8">
    FC.checkout.config.customShipping = {
      onLoad: false,  // Set to false if you don't want shipping calculated when the checkout loads
      onLocationChange: true // Set to true if your shipping logic relies on updating whenever the shipping location for the order changes
    };
     
    function calculateShipping() {
      var shippingCost = 0;
     
      /* BEGIN CUSTOM SHIPPING LOGIC */
     if (typeof(country_code) === "undefined") {country_code = "";}
    new_country_code = (jQuery("#use_different_addresses").is(":checked") ? $("#shipping_country").val() : $("#customer_country").val());
    if (country_code != new_country_code) { // The shipping country has changed!
      country_code = new_country_code;
      switch (country_code) {
        case "US":
          shippingCost = 0;
          break;
        case "CA":
          shippingCost = 100;
          break;
        default:
          shippingCost = 250;
      }
    }
      /* END CUSTOM SHIPPING LOGIC */
     
      FC.checkout.config.orderFlatRateShipping = shippingCost;
      FC.checkout.updateShipping(-1);
    }
     
    jQuery(document).ready(function() {
      if (FC.checkout.config.customShipping.onLoad) {
        runShippingLogic();
      }
     
      if (FC.checkout.config.customShipping.onLocationChange) {
        FC.checkout.overload("updateTaxes", function() { runShippingLogic(); }, null);
      }
    });
     
    function runShippingLogic() {
      // Check to see if there are actually shippable products in the current cart before running the custom shipping (0.7.1+ only), or just run it for older carts
      if ((typeof(FC.checkout.config.hasShippableProducts) === "boolean" && FC.checkout.config.hasShippableProducts) || typeof(FC.checkout.config.hasShippableProducts) === "undefined") {
          calculateShipping();
      }
    }
    </script>
    

    I'm at a loss for how to do the following things:

    -Loop through the cart and apply this custom shipping only if an item from one of the categories this scheme applies to is present (as you said previously)
    -Set up cases for individual US states (i.e. Alaska, Hawaii) as well as a country (Canada). Is there any way to add multiple countries/states under a single case?

    Likewise, Dreamweaver is also telling me there is a syntax error on line 3 (onLoad: ... ) and I can't figure out if this is just a mistake or if there's something I'm actually missing.

    I appreciate the help. As I've said before I'm more or less a javascript rookie and learning as I go for the moment.
  • fc_adamfc_adam FoxyCart Team
    @KNick,

    Happy to give you a hand, but I might need a little bit more information to make sure I'm on the same page.

    So this custom shipping (free for continental US, fee for Alaska/Hawaii, fee for Canada) only applies if certain categories are present in the cart. If they're not present, what is the shipping cost? And what happens if one of the special categories is present, as well as other products from different categories?
  • @fc_adam,

    I'm going to whisper some stuff to you in hopes that we can get on the same page as well as give you a bit clearer of a picture.

    The products that this will apply to are in two different categories, let's call them "Category A" and "Category B." These are the only two categories this pricing scheme applies to. Our "Category C" and "Category D" and all other categories have shipping that we have already taken care of through the cart's control panel.

    For our instruments only (categories "Category A" and "Category B") shipping is as follows:
    -Free to the Continental US
    -$150 to AK, HI, and Canada
    -$250 to anywhere else in the world

    If these categories are not present in the cart then shipping should be taken care of by what's been programmed into the cart already. If products from a different category (say a "Category C") are in the cart with these products, the same shipping and handling charge from the "Category C" category is also tacked on because it cannot be sent in the same box as the first product.

    Hope this explains everything.

    Also, how do you use the whisper function in these forums? First time I've ever used a Vanilla-powered discussion board and I can't figure out how.
  • fc_adamfc_adam FoxyCart Team
    @KNick,

    That's great, thanks for that.

    You can whisper by checking the 'Whisper' box below the text input, and then typing my user name into the text box that appears below that.
  • fc_adamfc_adam FoxyCart Team
    @KNick,

    So this should cover it for you. Firstly, replace your custom logic with this: http://pastie.org/private/wzd9nkfmnsdta0jof5amlw

    You'll need to update the two category codes for the instrument categories.

    Also, you'll need to include this, put it before the script you pasted earlier in this thread: http://pastie.org/private/iziyc4fwekhkz58ymhkxwa
  • Hi, working on a shipping implementation with a 'rest of world' setting.

    One charge if within UK, and another charge if any country outside of UK.

    How to specify 'Rest of world'?

    If we don't ship to, say, Camaroon or Ivory Coast, can we just specify the exceptions like those countries?
  • fc_jedfc_jed FoxyCart Team
    edited October 2015
    @patrickpitman

    Since you're on v1.0, you could use this logic for your custom shipping logic:

    var country = (jQuery("#use_different_addresses").is(":checked") ? $("#shipping_country").val() : $("#customer_country").val());
    if (country == "GB") {
    FC.customLiveShipping.add(100, 4.99, 'United Kingdom', 'Delivery');
    }
    else {
    FC.customLiveShipping.add(101, 4.99, 'Rest of the World', 'International Delivery');
    }
    Feel free to change the values as you please, but basically, the "rest of the world" is the else statement to a conditional evaluating whether the country is "GB" or not. Please refer to the snippet pasted above for the live rate shipping modification.

    With regard to black listing countries, have a look at this snippet for more information: https://wiki.foxycart.com/snippets/shipping/restricting_countries_and_states_on_the_checkout
  • Thanks.

    We're planning to migrate to v2 foxycart as part of this, so does that change your reply?
    Seems this code does not work with version 2...
  • fc_adamfc_adam FoxyCart Team
    @patrickpitman,

    That does change the answer. In 2.0 you can restrict countries and states available for billing and shipping from within the FoxyCart administration for your store - so no need for a snippet.

    For the shipping if you're wanting to offer two different flat rates - you'd still use a snippet, but this one: https://wiki.foxycart.com/v/2.0/snippets/flat_rate_shipping_modification

    Your custom logic would look like this:
    if (address.country == "GB") {
    FC.customFlatRates.add(1, 5, 'Royal Mail', 'Standard');
    } else {
    FC.customFlatRates.add(2, 15, 'Royal Mail', 'International');
    }
Sign In or Register to comment.