Nikolas Reissis Posted November 6, 2013 Share Posted November 6, 2013 (edited) Hello everyone, I would appreciate any response to my question. I see that there are similar posts, so other people might have the same problem Unless I misunderstood, the shipping cost in Weight Range is fixed for all the range. Case 1: Weight Range: 10-15 kg - Price: 2 Euro. This means that the shipping cost will be 2 Euros for any quantity between 10kg and 15kg. I suppose that the code for the calculation of the shipping cost is something like:“Lookup for the shipping cost for this weight range” Case 2: I don’t know how it works in the other countries, but our carriers in Greece would charge: - a fixed rate for the first weight range (eg: 0 - 2 kg - 6 Euros) and - per kg for the rest of the quantity (eg: 2 - 50kg, 1,5 Euro per kg). So a pack weighting 10kg would have a shipping cost: 6 + (10-2)*1,5 = 18 Euro In this case the code for the calculation of the shipping cost would be something like this: P1 = the price from the first Weight Range W = the weight of the order W1 = the max weight from the first Weight Range W2 = Subtract W1 from W : (W-W1) P2 = the price for the W2 Weight Range Shipping cost = P1+ W2*P2 Case 3: A simplified method would be to just multiply the weight with the price of the 1 and only Weight Range P = the price from the first and only Weight Range W = the weight of the order Shipping cost = W*P My question is: Can I modify the code so that the shipping cost is calculated according to Case 2 or Case 3? And if so, how and where is this code? Edited November 10, 2013 by Nikolas Reissis (see edit history) Link to comment Share on other sites More sharing options...
Nikolas Reissis Posted November 10, 2013 Author Share Posted November 10, 2013 Partialy solved Case 3 Case 3: A simplified method would be to just multiply the weight with the price of the 1 and only Weight Range P = the price from the first and only Weight Range W = the weight of the order Shipping cost = W*P In Carrier.php line 250-253 I added * $total_weight. So now the Weight Range price is considered to be the per kg cost and not a fixed price. if (!isset($result['price'])) self::$price_by_weight[$cache_key] = $this->getMaxDeliveryPriceByWeight($id_zone) * $total_weight;//added * $total_weight; else self::$price_by_weight[$cache_key] = $result['price'] * $total_weight;//added * $total_weight; It seems to be working. And even better it calculates the price of the correct Weight Range, so we can have as many Weight Ranges as we wish. I am new to PHP so I am not sure that everything is OK. Also I don't know how to make Case 2 Any help? Link to comment Share on other sites More sharing options...
Recommended Posts