Suggestion on flat rate ship for US only

happycloudhappycloud Member
in Important News edited March 2014
So I was using the Free Ground Ship option for domestic - however one of my distributor forbids free shipping on their product so I am now charging $0.01 for shipment on domestic for any order with their product. I have setup the categories accordingly but I don't see a way to then limit it to domestic only. How can I achieve this?
Tagged:
Comments
  • On the same note I have tried adding just a handling charge to my category but it doesn't seem to appear - still $0 for domestic - my store is gonegreen
  • fc_adamfc_adam FoxyCart Team
    @happycloud,

    The handling charge is rolled into the shipping rates, but free ground shipping will stay as $0 as you discovered.

    If you're wanting to ship with live rates, but then alternately show some flat rates or modify the live rates, you'll need to use some javascript to do that. Take a look at the 'live rates shipping modification' snippet in the wiki here: http://wiki.foxycart.com/snippets/start
  • happycloudhappycloud Member
    edited March 2014
    Ok - I was not able to use that script because it just modifies the rates that are shown or lets me add new flat ones - what I essentially need is a way to change the product categories from say FREE_SHIP to DEFAULT (live rates). I have the script mostly working but FC is not fetching new rates. I suspect it is because it initially sees that the products are set to have a FREE_SHIP category and will not bother to recheck rates even if I change the category to DEFAULT using javascript. I have toggled the hasLiveRateShippableProducts flag on but that did not work. Can you see what I might be missing?
    $().ready(function() {
        var updateProducts = function() {
          var dest = $('#use_different_addresses').prop('checked') ? $('#shipping_country').val() : $('#customer_country').val();
           if(dest != 'US') {
            for(var i = fc_json.products.length-1; i >= 0; i--) {
              fc_json.products[i].oldcat = fc_json.products[i].category;
              fc_json.products[i].category = 'DEFAULT';
            }
          } else {
            for(var i = fc_json.products.length-1; i >= 0; i--) {
              if(fc_json.products[i].oldcat) {
                fc_json.products[i].category = fc_json.products[i].oldcat;
              }
            }
          }
          FC.checkout.config.hasLiveRateShippableProducts = true;
          FC.checkout.updateShipping(-1);
        }
    
        updateProducts();
        $('#shipping_country, #customer_country').change(function() {
          updateProducts();
        });
      });
    

    Note that I currently have the free domestic ship option on but am toggling it for my tests.
  • fc_adamfc_adam FoxyCart Team
    @happycloud,

    The fc_json object is read-only unfortunately. You can't make changes to products that way. You'll need to interface with the cart using JSONP and remove all of the old products and re-add them with the different category in order to make that change stick.

    Is there a reason the snippet I linked to earlier wouldn't work? If I'm understanding you correctly, you want to show live rates if the customer is from any country except for the US, and then show flat rates if they're from the US. That's completely do-able from that snippet I mentioned. What you'd do is if the customer is from the US, you'd remove all of the returned live rates, and instead add your own fake live rate that is set to be the flat rate shipping cost you want.
  • Shoot. Here's my issue - Let's say I have 3 items - item A is heavy and should always be rate shipped, item B is free for US and rate shipped everywhere else, item C is $0.01 in US and rate shipped everywhere else. I don't see how I can use the snippet since it would require me to have a breakdown of each item's rate. Suggestions?
  • fc_adamfc_adam FoxyCart Team
    @happycloud,

    How were you going to handle the multiple different flat rates otherwise? We currently only allow a single flat rate in the administration - so you would need to create a different category for each different rate you want to apply to a product.

    Currently, when it comes to providing tiered flat rates and switching between flat rates and live rates - doing that with javascript is your best bet. What you've described there is possible with the javascript snippets - but it does require you to track the flat rate tiers in your checkout snippet, that's correct.
  • I am using categories - default, free_ship and penny_ship. I am still not clear on how I can use that snippet though - the only way I can see is to a) apply the above categories to the products so that I can find them in the fc_json object, have all the above categories set to use live rate, query for live rates, check if in US and then... what? I don't know how much each product was within the live rate (unless I start doing calculations with weights and quantity) - so how can I figure out how much it would be for the US since in the above example the cost would be (WEIGHT_RATE x 1) + ($0 x 1) + ($0.01 x 1) for the 3 products
  • fc_adamfc_adam FoxyCart Team
    @happycloud,

    Ah ok - I was misunderstanding you earlier. Sorry about that.

    Ok - so I would still say that the javascript snippet is still your best way to go. Here's how I'd suggest doing it.

    All of your products are rate shipped in some situation - so that would be your default. I'd still suggest keeping the three categories - but set all of the categories to live rate shipping, and instead use the categories to let your system know what shipping style they have.

    Then on the checkout, whenever the country field changes, perform a little bit of logic. That logic would first check the country, and then loop through all of the products. If the category is one that needs to get live rates for it for that country, you would add it's total weight into a variable, and once the loop has finished, set the live rate weight variable on the checkout to be that weight amount. That way you can dynamically set what weight the live rates should be fetched for. While you're looping through, for those rates that don't need live rates, you could also calculate what total cost you need to add onto the returned live rates. If no products need live rates, you would need to leave the live rates weight amount as a figure above 0 so the rates don't error - but you can also set a variable to say that no live rates are needed.

    Lastly, you'd use the snippet I mentioned above to add on the additional costs to the returned live rates so that the customer can select a live rate that encompasses everything, or instead show a fake rate that covers what the shipping needs to be when no live rates are required.

    I know that might sound complex, but it's not actually too bad - just a couple pieces to it.

    If you wanted to tackle it using categories - you can definitely do that as well. The catch is that you'll need to remove the products and re-add then using JSONP, and then also either refresh the checkout to set up the different config variables to match the new settings, or set them yourself using javascript.

    Both approaches are going to require some custom javascript work - it just depends which one you feel more comfortable tackling.
  • To clarify - you say I should calculate the weight of the rate items when in US and set a variable - are you taking about FC.checkout.config.orderLiveRateShipmentWeight? So set that and call FC.checkout.updateShipping(-1); again and that would get me new rates?
  • fc_adamfc_adam FoxyCart Team
    @happycloud,

    That's correct - that variable is used to pass on to the live rates to calculate how much it will cost.
  • Ya I don't think it will work :( The problem is that for the US I need to get the quote for the cheapest option which will only include the weight of items in DEFAULT but for the rest of the shipping options (i.e. next day etc) then my live rate quote needs to include all items. Which means making 2 rate queries, storing the first option of the first query then getting another quote and merging them etc.. Possible I suppose but so messy. I think we are going to come up with a flat/table rate for heavy items that way I don't need to make 2 queries and can just use the snippet and add a non live rate option. Thanks for brainstorming on that with me though and putting my 2 cents in for categories that can have domestic vs world shipping options
Sign In or Register to comment.