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.

Additional custom packaging charge

davidzupecdavidzupec Member
in Help edited July 2014
Hello, on top of the UPS live shipping rates (which I already have configured) I need to add an additional $13 packing cost if the order is 1-6 cases, plus another $13 packing cost for 7-12 cases ordered, another $13 for 13-18 cases ordered etc.

So for example if they ordered 8 cases their total would include the custom $26 packaging cost as well as the live shipping rate.

Could someone point me in the right direction as to how to implement this custom packaging cost? Thank you!
Tagged:
Comments
  • fc_adamfc_adam FoxyCart Team
    @davidzupec,

    This would be something you'd achieve within the live rates shipping modification from our snippets as well. You'd calculated from the JSON cart object how many cases you have, and then modify the returned rates to include the additional packaging costs based on how many cases are present.
  • Hey Adam thank you! I'll see if I can give it a shot. What makes this difficult for me is the javascript code that adds the $13 for 1-6 cases, then $26 for 7-12 cases, and so forth. If it was just adding the $13 to the live shipping I'd be alright : )
  • fc_adamfc_adam FoxyCart Team
    @davidzupec,

    How do you determine a case? Is it 1 product in the cart equals 1 case? Or is there some other form of calculation there?
  • Hey Adam, yes 1 product is equal to 1 case.
  • fc_adamfc_adam FoxyCart Team
    @davidzupec,

    Ok awesome - so basically to work out how much to add as the additional charge it would just be:
    13 * Math.ceil(fc_json.product_count/6)
    

    If you match that with the live rate shipping modification snippet, you should be good to go.
  • Hi Adam, thank you again and please excuse my coding skills lol! Since this custom additional cost is for the BEVERAGE category only, am I getting close below?
    for (p in fc_json.products) {
      switch (fc_json.products[p].category) {
        case "BEVERAGE":
          BEVERAGE += 13 * Math.ceil(fc_json.product_count/6);
          break;
      }
    }
    
  • fc_adamfc_adam FoxyCart Team
    @davidzupec,

    Very close, the only issue there is that it would add the total number of cases across all categories - not just beverages - each time. Try this:
    var beverages = 0;
    for (p in fc_json.products) {
      switch (fc_json.products[p].category) {
        case "BEVERAGE":
          beverages += fc_json.products[p].quantity;
          break;
      }
    }
    var handling = 13 * Math.ceil(beverages/6);
    

    Then in your call to modify the shipping using the snippets, you would add the handling amount in.
  • Thank you Adam!
Sign In or Register to comment.