Medworks Posted June 11, 2010 Posted June 11, 2010 Not that I expect to get orders this large, but under "Enter the Maximum Package Weight you will ship", I notice that if it just barely exceeds this limit, it splits the order into equal-sized packages. Not what I want. If the weight is sufficiently large that it must be split into n separate packages, I don't want it to be split into n equal-weight packages, I want it to have n-1 packages at my set weight limit, and have the final one be whatever's left over. So I have a limit of "10896", which by the way I have all the weights measured, is 1089.6 ounces or 68.1 pounds, and if the total weight of the order is 70 pounds, then it splits it into two 35-pound packages currently. I want it to split it into a 68.1 pound parcel and a 1.9 pound parcel instead. What file do I modify to set this the way I want? Quote
Jan Zonjee Posted June 12, 2010 Posted June 12, 2010 What file do I modify to set this the way I want? If I remember correctly this is done in includes/classes/shipping.php: function quote($method = '', $module = '') { global $total_weight, $shipping_weight, $shipping_quoted, $shipping_num_boxes; $quotes_array = array(); if (is_array($this->modules)) { $shipping_quoted = ''; $shipping_num_boxes = 1; $shipping_weight = $total_weight; if (SHIPPING_BOX_WEIGHT >= $shipping_weight*SHIPPING_BOX_PADDING/100) { $shipping_weight = $shipping_weight+SHIPPING_BOX_WEIGHT; } else { $shipping_weight = $shipping_weight + ($shipping_weight*SHIPPING_BOX_PADDING/100); } if ($shipping_weight > SHIPPING_MAX_WEIGHT) { // Split into many boxes $shipping_num_boxes = ceil($shipping_weight/SHIPPING_MAX_WEIGHT); $shipping_weight = $shipping_weight/$shipping_num_boxes; } Quote
Medworks Posted June 19, 2010 Author Posted June 19, 2010 If I remember correctly this is done in includes/classes/shipping.php: function quote($method = '', $module = '') { global $total_weight, $shipping_weight, $shipping_quoted, $shipping_num_boxes; $quotes_array = array(); if (is_array($this->modules)) { $shipping_quoted = ''; $shipping_num_boxes = 1; $shipping_weight = $total_weight; if (SHIPPING_BOX_WEIGHT >= $shipping_weight*SHIPPING_BOX_PADDING/100) { $shipping_weight = $shipping_weight+SHIPPING_BOX_WEIGHT; } else { $shipping_weight = $shipping_weight + ($shipping_weight*SHIPPING_BOX_PADDING/100); } if ($shipping_weight > SHIPPING_MAX_WEIGHT) { // Split into many boxes $shipping_num_boxes = ceil($shipping_weight/SHIPPING_MAX_WEIGHT); $shipping_weight = $shipping_weight/$shipping_num_boxes; } Ahh, thank you. Naturally I will also have to sneakily modify my zone based rates. The way it comes is to just multiply $shipping_num_boxes by the calculated weight, and if they're not all equal sized boxes, well, you get the idea. I think I'll have $shipping_weight output by this correspond to the weight of the LAST box, and then the number of maximum-weight boxes will be implied to be ($shipping_num_boxes-1). Thank you for pointing me to the right place. Quote
Medworks Posted June 20, 2010 Author Posted June 20, 2010 I'm left with one last question. The parameter SHIPPING_MAX_WEIGHT. Is it defined and accessible within the shipping modules? Or is it an undefined variable outside of includes/classes/shipping.php? It seems to me that there is no need to actually modify includes/classes/shipping.php at all, since the 3 variables, SHIPPING_MAX_WEIGHT, $shipping_num_boxes and $shipping_weight completely contain all the information about the number of max-sized boxes and the size of the remaining box. The most important point is to have the shipping module figure it out right and output that it will be splitting it into n boxes of one size and one box of a smaller size - it'll be a little harder than a perfectly even split, since it will have to determine TWO independent things from the table which determines shipping cost as a function of weight: the shipping cost using the max weight AND the shipping cost using the remainder, while if they're all split equally, then there's only one equal value to use in multiplicity however many boxes there are. That's probably why it was programmed that way to begin with. But the simple fact is, it will be considerably cheaper to ship a 70 pound box and a 2 pound box than two 36 pound boxes. Just messing around, my shipping cost to jumped from like 40 dollars to 60 dollars by adding one tiny thing to the order. Quote
Jan Zonjee Posted June 20, 2010 Posted June 20, 2010 The parameter SHIPPING_MAX_WEIGHT. Is it defined and accessible within the shipping modules? It's value is stored in the table configuration and is loaded as one of the first thing in application_top.php by querying that table and get all the values (around line 69): // set the application parameters $configuration_query = tep_db_query('select configuration_key as cfgKey, configuration_value as cfgValue from ' . TABLE_CONFIGURATION); while ($configuration = tep_db_fetch_array($configuration_query)) { define($configuration['cfgKey'], $configuration['cfgValue']); } So yes, it should be available globally for all scripts/pages. Quote
Medworks Posted June 23, 2010 Author Posted June 23, 2010 Thanks for your help. It turned out, when I really started thinking of a solution, that I ought to just take the quantity ($shipping_weight*$shipping_num_boxes) as the single input from which the shipping module reads. That way nothing elsewhere needs to be changed to have the shipping module, and also, since I was modifying the zone based rates shipping method, this way I can have a different maximum package size to each zone. And it actually gives a prompt that lets you select between an equal box split and the method I proposed. I put it up on the community addons section, check it out here: http://addons.oscommerce.com/info/7458 Unfortunately, it won't let me edit the description it shows on the front. I failed to mention that I don't use pounds or kilograms but tenth-ounces, so if your items are measured in pounds, it will output a shipping weight that is 160 times too large. The only thing I could do was add a zero-size file, since it lets me add files with descriptions. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.