Need to calculate USPS shipping cost for each item in order, separately

OrthiasOrthias Member
Hi, I haven't managed to find a snippet that covers this scenario:

- my client ships crates of sauce which are already packaged by them and they're quite heavy (around 22lbs each);
- they use UPS live shipping rates to calculate the shipping cost;
- normally, the live rate works by getting the total weight of the order and inputting that into the UPS API to get the estimated cost;
- however, my client ships each crate in the order (each "item" in the order) separately, with its own tracking code, even if they go to the same address (which they all do, we don't use multi-shipping).

How can I add custom logic so that the shipping cost is calculated like this instead:
- for each item in the order, the shipping rate is calculated as though it was the only one being shipped.
- then the sum of the shipping costs for all items in the order is calculated and displayed.

I have taken a look at this snippet https://wiki.foxycart.com/v/2.0/snippets/breaking_large_shipments_into_multiple but I would need to change it so that it calculates shipping for sauce crates separately matter the weight (sauce packages might be from 14 lbs to 32 lbs).

Thanks in advance for your help!
Ovi
Comments
  • fc_adamfc_adam FoxyCart Team
    @Orthias,

    Good question, thanks for detailing the requirements you're working against.

    The snippet you linked to there is the closest thing we have currently, but it won't do exactly what you're after, as you've noted, because it'll still only be calculating the rates against a single weight.

    To achieve what you're after exactly, it would require a custom integration with UPS through our custom shipping endpoint. You would then be able to loop through each product in the cart and create a rate request that takes into account each different package being shipped, before returning the rates back to the checkout. It would mean a custom connection to UPS, but there are some helper libraries available online to assist with doing that process too.

    While it would require some custom development, it would allow you to get a set up exactly like you're wanting to have. Let us know if we can help clarify anything further!
Sign In or Register to comment.