This is a long running issue with seemingly no proper answer. What is the best way to go about creating accurate shipping costs for purchases of more than one item? Delivery companies don't use a price per gram formula and many don't have an API also what about shipping small items and big items together when the small item can be packed in with the larger one.
We charge our customers based on the actual weight of an item or the cubic weight (whichever is greater). If a customer buys 2 or more items at the same time, the cart simply adds actual and cubic weight for each item, calculates the total weight (both actual and cubic), and charges the customer based on whichever one is greater. Works pretty well and is very accurate.