dtchaos Posted May 18, 2009 Share Posted May 18, 2009 I am trying to modify this mod, to split the weight of any order into 20 lb boxes, the shop I run sells rough rock, and people ordering over 20 lbs cant choose flat rate if their order is over 20 lbs as we are willing to ship in boxes up to 70 lbs. So what I'm trying to do is modify this mod so it divides the weight of the order into 20 lb packages. So this mod will show 2 boxes at 20 lbs instead of 1 box at 40 lbs. I realize that this is calculated in classes/shipping.php in the quote(); function. I noticed the quote(); function in uspsflat.php and I'm wondering if it would be possible to recalculate the package weight here so the user is shown the shipping cost if their order was split between 20 lb packages, or if I have to do that in shipping.php? Does anyone know if this would work? Quote Link to comment Share on other sites More sharing options...
web-project Posted May 18, 2009 Share Posted May 18, 2009 check the oscommerce admin panel --> configuration --> Shipping/Packaging Quote Please read this line: Do you want to find all the answers to your questions? click here. As for contribution database it's located here! 8 people out of 10 don't bother to read installation manuals. I can recommend: if you can't read the installation manual, don't bother to install any contribution yourself. Before installing contribution or editing/updating/deleting any files, do the full backup, it will save to you & everyone here on the forum time to fix your issues. Any issues with oscommerce, I am here to help you. Link to comment Share on other sites More sharing options...
dtchaos Posted May 18, 2009 Author Share Posted May 18, 2009 (edited) check the oscommerce admin panel --> configuration --> Shipping/Packaging Oh I realize it can be set in the Admin panel, but we need the over all wieght to be set to 70lbs so we can ship packages up to that weight, but we also need a a mod that shows what the shipping price would be if the order were split into several flat rate boxes. I.e. to find out which is cheaper etc. Note: I intended to post this in http://www.oscommerce.com/forums/index.php?showtopic=294676 sorry. Edited May 18, 2009 by dtchaos Quote Link to comment Share on other sites More sharing options...
dtchaos Posted May 18, 2009 Author Share Posted May 18, 2009 I tried modifying the calculation around line 85 of classes/shipping.php if(substr_count("flat",$method) > 0){ 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; } }else{ if ($shipping_weight > 18) { // Split into many boxes $shipping_num_boxes = ceil($shipping_weight/18); $shipping_weight = $shipping_weight/$shipping_num_boxes; } } However this wound up dividing ALL shipping methods into 18 lb boxes as opposed to just the flat rate mod. I'm assume once it found one instance, of "flat" it just divided all the shipping methods into 18 lb boxes. Quote Link to comment Share on other sites More sharing options...
dtchaos Posted May 21, 2009 Author Share Posted May 21, 2009 (edited) I solved this my self by doing the following: I took the USPS Flat Rate shipping module, then edited my includes/classes/shipping.php quote function to read as follows. function quote($method = '', $module = '') { global $total_weight, $shipping_weight, $shipping_quoted, $shipping_num_boxes, $flat_shipping_weight, $flat_shipping_num_boxes; // This was used for debugging and finding out what this function was doing. /* $myFile = "/home/thegemsh/thegemshop.com/html/osc/includes/classes/errlog.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = '$module = ' . $module . '\n'; fwrite($fh, $stringData); fclose($fh);*/ $quotes_array = array(); if (is_array($this->modules)) { $shipping_quoted = ''; $shipping_num_boxes = 1; $flat_shipping_num_boxes = 1; $shipping_weight = $total_weight; $flat_shipping_weight = $total_weight; if (SHIPPING_BOX_WEIGHT >= $shipping_weight*SHIPPING_BOX_PADDING/100) { $shipping_weight = $shipping_weight+SHIPPING_BOX_WEIGHT; $flat_shipping_weight = $flat_shipping_weight+SHIPPING_BOX_WEIGHT; } else { $shipping_weight = $shipping_weight + ($shipping_weight*SHIPPING_BOX_PADDING/100); $flat_shipping_weight = $flat_shipping_weight + ($flat_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; } // This was used for debugging to find out what this function was doing. /*$myFile = "/home/thegemsh/thegemshop.com/html/osc/includes/classes/errlog.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = '$this->modules = ' . $this->modules . '\n'; fwrite($fh, $stringData); fclose($fh);*/ if ($flat_shipping_weight > 18) { // Split into many boxes $flat_shipping_num_boxes = ceil($flat_shipping_weight/18); $flat_shipping_weight = $flat_shipping_weight/$flat_shipping_num_boxes; } I then modified every instance of $shipping_weight and $shipping_num_boxes in includes/modules/shippin/uspsflat.php to be $flat_shipping_weight, and $flat_shipping_num_boxes. Thus making it use the variables that divide it into 20 lb packages. The reason why it divides at 18 and not 20 is to allow for the tear weight of the packages to be added without blowing the 20 lb limit. I hope this helps anyone trying to do the same thing. The contribution I modified is http://addons.oscommerce.com/info/5783 http://www.oscommerce.com/forums/index.php?showtopic=294676 is the forum thread for the mod I modified. Edited May 21, 2009 by dtchaos Quote Link to comment Share on other sites More sharing options...
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.