Determining Shipping Costs
Understanding both, how the shipping type model works and how to retrieve the required XML descriptions, the question is: How do I calculate the right order value from the products or articles that are in the basket or order?
The answer is actually quite simple. The Keep in mind that for an existing basket, the basket resource already contains the assumed shipping costs. If you want to display shipping costs beforehand, it is possible to evaluate the ruleset shown above as follows:
The order value for the shipping cost calculation is always calculated based on product types and product type prices. As you already know from the product model, each article and product is created based on a product type and links the product type in the XML description. Each product type also a sellable's price and a sellable's product type. Each product type has a shipping factor between 0 and 1 (0-100%) that defines to which part the product type sellable price is used to calculate the order value. 0 means it is not used and 1 means the full product type sellable price is used for order value calculation. With the calculated order value, we now only need to find the right shipping region for the country we want to ship to and identify the shipping costs by finding the matching order value range for the shipping region.
Let’s assume we have an order with 2 x Bud Bud Spencer t-shirts from our marketplace shirts (sellables at 12.90 € each) that we want to ship from Germany to Germany with the standard the standard shipping type, which means we use shipping type 1, shipping country 148 and shipping region 1. The Bud Spencer t-shirt is based on our classic mens t-shirt, which costs 12.90 € on the German marketplace. The The shipping factor is 1 for that product type as we ship a real item. Based on that data the order value calculation is as follows:
2 (quantity) x 1.0 (shipping factor) x 12.90 € Buds Spencer T-Shirt(sellable price) --------------------------------------------------------------------- = 25.80 €
Using the hypothetical shipping cost order value ranges defined for shipping region 1, which are
0.00 € - 24.89 € -> 2.90 € 24.89 € - 59.99 € -> 3.90 € 59.99 € - 500.00 € -> 0.00 € 500.00 € - -> 0.00 €