Annie Dragon Posted January 18, 2007 Share Posted January 18, 2007 Hi Annie, When you say duplicate, are you talking about the copy function in admin/categories/products? IF you use the link instead of copy it's not a problem and then you also only have one product to make changes on such as stock. You could edit the file though to include products_height, products_width, and products_length. Yes. Copy and duplicate product - not copy and link product to put it into another category (I do that quite a bit too). If I have a similar item in stock (same size and weight etc..) and all that I have to change is the image and a few words, I love to use the duplicate function in the products - makes my life easier. Annie Quote It's not a learning curve, it's a cliff! Link to comment Share on other sites More sharing options...
Annie Dragon Posted January 18, 2007 Share Posted January 18, 2007 1136 - Column count doesn't match value count at row 1 insert into products (products_quantity, products_model,products_image, products_price, products_date_added, products_date_available, products_weight, products_length, products_width, products_height, products_ready_to_ship, products_status, products_tax_class_id, manufacturers_id) values ('1', 'modelnumber', 'image.jpg', '10.0000', now(), '', '1.00', '0', '0', '10') This is the error message that I got from admin/categories.php Any suggestions would be appreciated - I'm trying to tease out where I need to make adjustments. The area that I though may have been the issue (right around line 300) was already adjusted with this mod. Annie Quote It's not a learning curve, it's a cliff! Link to comment Share on other sites More sharing options...
John Wisdom Posted January 18, 2007 Share Posted January 18, 2007 Well, I just copied a product from one category to another to test it and it works on mine moving all the data. I looks like you don't have all the data on the product you are trying to copy, but I just get by with manipulating code. Here is the query insert from my admin/categories.php. case 'copy_to_confirm': if (isset($HTTP_POST_VARS['products_id']) && isset($HTTP_POST_VARS['categories_id'])) { $products_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']); $categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']); if ($HTTP_POST_VARS['copy_as'] == 'link') { if ($categories_id != $current_category_id) { $check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$products_id . "' and categories_id = '" . (int)$categories_id . "'"); $check = tep_db_fetch_array($check_query); if ($check['total'] < '1') { tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$products_id . "', '" . (int)$categories_id . "')"); } } else { $messageStack->add_session(ERROR_CANNOT_LINK_TO_SAME_CATEGORY, 'error'); } } elseif ($HTTP_POST_VARS['copy_as'] == 'duplicate') { // LINE MODED: Added "products_ship_price" $product_query = tep_db_query("select products_ship_price, products_quantity, products_model, products_image, products_price, products_date_available, products_weight, products_length, products_width, products_height, products_ready_to_ship, products_tax_class_id, manufacturers_id from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'"); $product = tep_db_fetch_array($product_query); // LINE CHANGED: MS2 update 501112 - Added :(empty($product['products_date_available']) ? "null" : ...{some code}... ") . " // LINE MODED: Added "products_ship_price" tep_db_query("insert into " . TABLE_PRODUCTS . " (products_quantity, products_model, products_ship_price, products_image, products_price, products_date_added, products_date_available, products_weight, products_length, products_width, products_height, products_ready_to_ship, products_status, products_tax_class_id, manufacturers_id) values ('" . tep_db_input($product['products_quantity']) . "', '" . tep_db_input($product['products_model']) . "', '" . $product['products_ship_price'] . "', '" . tep_db_input($product['products_image']) . "', '" . tep_db_input($product['products_price']) . "', now(), " . (empty($product['products_date_available']) ? "null" : "'" . tep_db_input($product['products_date_available']) . "'") . ". '" . tep_db_input($product['products_weight']) . "', '0', '" . $product['products_length'] . "', '" . $product['products_width'] . "', '" . $product['products_height']. "', '" . $product['products_ready_to_ship'] . (int)$product['products_tax_class_id'] . "', '" . (int)$product['manufacturers_id'] . "')"); $dup_products_id = tep_db_insert_id(); Hope this helps Quote John Wisdom Link to comment Share on other sites More sharing options...
teamXXXrob Posted January 18, 2007 Share Posted January 18, 2007 I just installed the UPSXML module and everything seems to be working correctly. I just have a couple questions... 1. What is the difference between the Test and Production Mode? Does it need to be set to production when the store is ready to go live? 2. Is there a way of not showing the "estimated delivery time" next to the different shipping methods in the delivery information and the order confirmation? Example— "United Parcel Service (XML) (1 pkg x 16 lbs total) (UPS Ground, 2007-01-29):" All i really want it to say is... United Parcel Service (UPS) Quote Link to comment Share on other sites More sharing options...
John Wisdom Posted January 18, 2007 Share Posted January 18, 2007 1. What is the difference between the Test and Production Mode? Does it need to be set to production when the store is ready to go live? Yes 2. Is there a way of not showing the "estimated delivery time" next to the different shipping methods in the delivery information and the order confirmation? Example— "United Parcel Service (XML) (1 pkg x 16 lbs total) (UPS Ground, 2007-01-29):" All i really want it to say is... United Parcel Service (UPS) To remove time in transit from displaying comment out line 304-324 Most text that you need to change in OSC is found in includes/languages/ and for this contrib it's includes/languages/english/modules/shipping/upsxml.php and you can change it to United Parcel Service (UPS) Quote John Wisdom Link to comment Share on other sites More sharing options...
teamXXXrob Posted January 18, 2007 Share Posted January 18, 2007 (edited) Yes To remove time in transit from displaying comment out line 304-324 Most text that you need to change in OSC is found in includes/languages/ and for this contrib it's includes/languages/english/modules/shipping/upsxml.php and you can change it to United Parcel Service (UPS) Thanks for the help. Since i'm not that savvy with coding, if you could go a little further indepth with which parts exactly need to be changed and which files i would really appreciate it. I would ultimately like it to say this in the order confirmation section: "United Parcel Service (XX lbs total) (UPS Ground):" And in the delivery information section just show the options without the delivery time: UPS Ground $11.20 UPS 3 Day Select $17.88 UPS 2nd Day Air $22.04 UPS Next Day Air Saver $40.76 UPS Next Day Air Early A.M. $76.02 Edited January 18, 2007 by teamXXXrob Quote Link to comment Share on other sites More sharing options...
John Wisdom Posted January 18, 2007 Share Posted January 18, 2007 (edited) Thanks for the help. Since i'm not that savvy with coding, if you could go a little further indepth with which parts exactly need to be changed and which files i would really appreciate it. The old saying "having the right tool for the job makes life easier" really applies to working on OSC. I don't know what you're using to work on your site, but I've been where you are and you are in for a challenge. Get Macromedia Dreamweaver and learn how it works and it's capabilities. It's worth it. Go to the PHP website tutorial and that will help a lot and explain how to comment out lines etc. The other thing is read all the OSC documentation so you understand how the file structure works and see examples of "how to". I would ultimately like it to say this in the order confirmation section: "United Parcel Service (XX lbs total) (UPS Ground):" And in the delivery information section just show the options without the delivery time: UPS Ground $11.20 UPS 3 Day Select $17.88 UPS 2nd Day Air $22.04 UPS Next Day Air Saver $40.76 UPS Next Day Air Early A.M. $76.02 Open catalog/includes/languages/english/modules/shipping/upsxml.php and you will see where that is defined. Look for define('MODULE_SHIPPING_UPSXML_RATES_TEXT_DESCRIPTION', 'United Parcel Service (XML)'); Change it to say what you want. Edited January 18, 2007 by John Wisdom Quote John Wisdom Link to comment Share on other sites More sharing options...
John Wisdom Posted January 18, 2007 Share Posted January 18, 2007 (edited) double post Edited January 18, 2007 by John Wisdom Quote John Wisdom Link to comment Share on other sites More sharing options...
simplicity Posted January 18, 2007 Share Posted January 18, 2007 United Parcel Service (XML) 100001: Unknown error. Anyone know why Iv had no luck with with this? Quote Link to comment Share on other sites More sharing options...
teamXXXrob Posted January 18, 2007 Share Posted January 18, 2007 The old saying "having the right tool for the job makes life easier" really applies to working on OSC. I don't know what you're using to work on your site, but I've been where you are and you are in for a challenge. Get Macromedia Dreamweaver and learn how it works and it's capabilities. It's worth it. Go to the PHP website tutorial and that will help a lot and explain how to comment out lines etc. The other thing is read all the OSC documentation so you understand how the file structure works and see examples of "how to". Open catalog/includes/languages/english/modules/shipping/upsxml.php and you will see where that is defined. Look for define('MODULE_SHIPPING_UPSXML_RATES_TEXT_DESCRIPTION', 'United Parcel Service (XML)'); Change it to say what you want. Yea i have dreamweaver8 and know the basics, but its time for me to get more indepth with it. I'll check out those tutorials and see if i can't figure this out. Thanks again. Quote Link to comment Share on other sites More sharing options...
Jan Zonjee Posted January 18, 2007 Share Posted January 18, 2007 John, The packaging routine is defintely is more effecient and it doesn't put items that don't fit into a box now. However, I still have problem with the packaging routine not selecting an alternate box. I list a 48x8x6 box but it will not select it until I change it to 48x10x10, which I just realized makes it the largest box available and then it wants to use it all the time. Here's my example: 2 items that are 30x3x3 3 times that 33x1.5x1.5 box choices 34x8x5, 31x15x10 and 48x8x6 It won't use the 48x8x6 but instead sends the othe two items as Ready to Ship items. Is this problem unique to me and possibly being caused by something else on my site? Anyone else run into this? I think this is caused by the fact that the function packProducts is only looking if an items fits the biggest (in volume) box. Now I haven't tried this yet but could you try to change that function to (only part of the function shown, look for sanity checks on the product): function packProducts($productsArray) { $definedPackages = $this->getPackagesByVol(); /* echo '<pre>'; print_r($definedPackages); exit; */ $emptyBoxesArray = array(); for ($i = 0; $i < count($definedPackages); $i++) { $definedBox = $definedPackages[$i]; $definedBox['remaining_volume'] = $definedBox['volume']; $definedBox['current_weight'] = $definedBox['empty_weight']; $emptyBoxesArray[] = $definedBox; } $packedBoxesArray = array(); $currentBox = NULL; $index_of_largest_box = count($emptyBoxesArray)-1; // Get the product array and expand multiple qty items. $productsRemaining = array(); for ($i = 0; $i < count($productsArray); $i++) { $product = $productsArray[$i]; // sanity checks on the product /* if (!$this->fitsInBox($product, $emptyBoxesArray[$index_of_largest_box])) { $product['ready_to_ship'] = '1'; } */ $product['ready_to_ship'] = '1'; for ($x = 0; $x <= $index_of_largest_box; $x++) { if ($this->fitsInBox($product, $emptyBoxesArray[$x])) { $product['ready_to_ship'] = '0'; // if the product fits at least one box no need to iterate any further break; } } // end for ($x = 0; $x <= $index_of_largest_box; $x++) for ($j = 0; $j < $productsArray[$i]['quantity']; $j++) { $productsRemaining[] = $product; } } // end for ($i = 0; $i < count($productsArray); $i++) // make sure the products that did not fit the largest box and are now set as ready-to-ship // are out of the way as soon as possible Quote Link to comment Share on other sites More sharing options...
notubes_pete Posted January 19, 2007 Share Posted January 19, 2007 Witch line should i comment out to remove the weight from the description "United Parcel Service (XML) (1 pkg x 14 lbs total)" Quote Link to comment Share on other sites More sharing options...
Jan Zonjee Posted January 19, 2007 Share Posted January 19, 2007 Witch line should i comment out to remove the weight from the description "United Parcel Service (XML) (1 pkg x 14 lbs total)" Look in the includes/modules/shipping/upsxml.php file for this piece (around line 328): $upsQuote = $this->_upsGetQuote(); if ((is_array($upsQuote)) && (sizeof($upsQuote) > 0)) { if ($this->dimensions_support > 0) { $this->quotes = array('id' => $this->code, 'module' => $this->title . ' (' . $this->boxCount . ($this->boxCount > 1 ? ' pkg(s), ' : ' pkg, ') . round($totalWeight,0) . ' ' . strtolower($this->unit_weight) . ' total)'); } else { $this->quotes = array('id' => $this->code, 'module' => $this->title . ' (' . $shipping_num_boxes . ($this->boxCount > 1 ? ' pkg(s) x ' : ' pkg x ') . round($shipping_weight,0) . ' ' . strtolower($this->unit_weight) . ' total)'); } As you can see this is where that line is built. Quote Link to comment Share on other sites More sharing options...
John Wisdom Posted January 19, 2007 Share Posted January 19, 2007 Hi Jan, Unfortunately, commenting out the sanity check does not correct the problem. I studied the packaging routine quite a bit yesterday and I was thinking that I could specify boxes for certain products based on thier length. I'll work on that next week and see how it goes. John Quote John Wisdom Link to comment Share on other sites More sharing options...
Jan Zonjee Posted January 19, 2007 Share Posted January 19, 2007 Unfortunately, commenting out the sanity check does not correct the problem. I studied the packaging routine quite a bit yesterday and I was thinking that I could specify boxes for certain products based on thier length. I'll work on that next week and see how it goes. Very strange. I edited the packages to your sizes and changed some test products to your sizes and when I added four items of each they all fit into the 48x8x6 box (with less items I also never saw the ready_to_ship go to 1, with the "old" and the "new" code): Array ( [0] => Array ( [id] => 4 [name] => 48x8x6 [description] => 48x8x6 [length] => 48.00 [width] => 8.00 [height] => 6.00 [empty_weight] => 1.00 [max_weight] => 30.00 [volume] => 2304.000000 [x] => 6.00 [y] => 8.00 [z] => 48.00 [remaining_volume] => 927 [current_weight] => 9 [products] => Array ( [0] => Array ( [id] => 78 [name] => test_30x3x3 [model] => X-4000 [image] => test_4x4x4.JPG [price] => 4.0000 [quantity] => 4 [weight] => 1.000 [length] => 30.00 [width] => 3.00 [height] => 3.00 [ready_to_ship] => 0 [final_price] => 4 [tax_class_id] => 0 [attributes] => [x] => 3.00 [y] => 3.00 [z] => 30.00 [volume] => 270 ) [1] => Array ( [id] => 78 [name] => test_30x3x3 [model] => X-4000 [image] => test_4x4x4.JPG [price] => 4.0000 [quantity] => 4 [weight] => 1.000 [length] => 30.00 [width] => 3.00 [height] => 3.00 [ready_to_ship] => 0 [final_price] => 4 [tax_class_id] => 0 [attributes] => [x] => 3.00 [y] => 3.00 [z] => 30.00 [volume] => 270 ) [2] => Array ( [id] => 78 [name] => test_30x3x3 [model] => X-4000 [image] => test_4x4x4.JPG [price] => 4.0000 [quantity] => 4 [weight] => 1.000 [length] => 30.00 [width] => 3.00 [height] => 3.00 [ready_to_ship] => 0 [final_price] => 4 [tax_class_id] => 0 [attributes] => [x] => 3.00 [y] => 3.00 [z] => 30.00 [volume] => 270 ) [3] => Array ( [id] => 78 [name] => test_30x3x3 [model] => X-4000 [image] => test_4x4x4.JPG [price] => 4.0000 [quantity] => 4 [weight] => 1.000 [length] => 30.00 [width] => 3.00 [height] => 3.00 [ready_to_ship] => 0 [final_price] => 4 [tax_class_id] => 0 [attributes] => [x] => 3.00 [y] => 3.00 [z] => 30.00 [volume] => 270 ) [4] => Array ( [id] => 79 [name] => test_33x1.5x1.5 [model] => X-8000 [image] => test_8x8x8.JPG [price] => 8.0000 [quantity] => 4 [weight] => 1.000 [length] => 33.00 [width] => 1.50 [height] => 1.50 [ready_to_ship] => 0 [final_price] => 8 [tax_class_id] => 0 [attributes] => [x] => 1.50 [y] => 1.50 [z] => 33.00 [volume] => 74.25 ) [5] => Array ( [id] => 79 [name] => test_33x1.5x1.5 [model] => X-8000 [image] => test_8x8x8.JPG [price] => 8.0000 [quantity] => 4 [weight] => 1.000 [length] => 33.00 [width] => 1.50 [height] => 1.50 [ready_to_ship] => 0 [final_price] => 8 [tax_class_id] => 0 [attributes] => [x] => 1.50 [y] => 1.50 [z] => 33.00 [volume] => 74.25 ) [6] => Array ( [id] => 79 [name] => test_33x1.5x1.5 [model] => X-8000 [image] => test_8x8x8.JPG [price] => 8.0000 [quantity] => 4 [weight] => 1.000 [length] => 33.00 [width] => 1.50 [height] => 1.50 [ready_to_ship] => 0 [final_price] => 8 [tax_class_id] => 0 [attributes] => [x] => 1.50 [y] => 1.50 [z] => 33.00 [volume] => 74.25 ) [7] => Array ( [id] => 79 [name] => test_33x1.5x1.5 [model] => X-8000 [image] => test_8x8x8.JPG [price] => 8.0000 [quantity] => 4 [weight] => 1.000 [length] => 33.00 [width] => 1.50 [height] => 1.50 [ready_to_ship] => 0 [final_price] => 8 [tax_class_id] => 0 [attributes] => [x] => 1.50 [y] => 1.50 [z] => 33.00 [volume] => 74.25 ) ) [price] => 48 ) ) I obtained that by adding a bit of code in the function quote (around line 230): if ($this->dimensions_support == '2') { // sort $productsArray according to ready-to-ship (first) and not-ready-to-ship (last) usort($productsArray, ready_to_shipCmp); // Use packing algoritm to return the number of boxes we'll ship $boxesToShip = $this->packProducts($productsArray); echo '<pre>'; print_r($boxesToShip); exit; // Quote for the number of boxes Quote Link to comment Share on other sites More sharing options...
John Wisdom Posted January 19, 2007 Share Posted January 19, 2007 Well, I'm puzzled now. Here is that output with some various products but it fails with just the bamboo items too. The really strange thing is I could swear it worked correctly when I first changed over from the old version. Unfortunately, I have a mountain paperwork so I have to wait to dig for the problem. Array ( [0] => Array ( [length] => 33.0 [width] => 1.5 [height] => 1.5 [current_weight] => 0.7 [price] => 5.25 ) [1] => Array ( [length] => 33.0 [width] => 1.5 [height] => 1.5 [current_weight] => 0.7 [price] => 5.25 ) [2] => Array ( [length] => 33.0 [width] => 1.5 [height] => 1.5 [current_weight] => 0.7 [price] => 5.25 ) [3] => Array ( [length] => 33.0 [width] => 1.5 [height] => 1.5 [current_weight] => 0.7 [price] => 5.25 ) [4] => Array ( [length] => 33.0 [width] => 1.5 [height] => 1.5 [current_weight] => 0.7 [price] => 5.25 ) [5] => Array ( [id] => 43 [name] => 31x15x7 [description] => 31x15x7 [length] => 31.0 [width] => 15.0 [height] => 7.0 [empty_weight] => 1.5 [max_weight] => 16.00 [volume] => 3255.000 [x] => 7.0 [y] => 15.0 [z] => 31.0 [remaining_volume] => 2550 [current_weight] => 2.7 [products] => Array ( [0] => Array ( [id] => 45 [name] => Avena (oats) - Natural Green - 6 oz [model] => [image] => Avena_natural.jpg [price] => 3.4900 [quantity] => 1 [weight] => 0.4 [length] => 30.0 [width] => 2.0 [height] => 2.0 [ready_to_ship] => 0 [final_price] => 3.49 [tax_class_id] => 1 [attributes] => [x] => 2.0 [y] => 2.0 [z] => 30.0 [volume] => 120 ) [1] => Array ( [id] => 71 [name] => Triticum (wheat) - Natural Green- 26"-29" - 6 oz [model] => [image] => Triticum_natural.jpg [price] => 4.2900 [quantity] => 1 [weight] => 0.5 [length] => 30.0 [width] => 2.0 [height] => 3.0 [ready_to_ship] => 0 [final_price] => 4.29 [tax_class_id] => 1 [attributes] => [x] => 2.0 [y] => 3.0 [z] => 30.0 [volume] => 180 ) [2] => Array ( [id] => 419 [name] => Dried Hydrangeas - Large Hamburgs - 3 stems [model] => [image] => hydrangea_hamburg_large.jpg [price] => 11.9900 [quantity] => 1 [weight] => 0.3 [length] => 5.0 [width] => 9.0 [height] => 9.0 [ready_to_ship] => 0 [final_price] => 11.99 [tax_class_id] => 1 [attributes] => [x] => 5.0 [y] => 9.0 [z] => 9.0 [volume] => 405 ) ) [price] => 19.77 ) ) Here is a PhPmyadmin output of my packaging table. INSERT INTO `packaging` VALUES (31, 'Large', '31x15x10', '31.0', '15.0', '10.0', '2.0', '20.00', 2), (43, '31x15x7', '31x15x7', '31.0', '15.0', '7.0', '1.5', '16.00', 1), (46, '34x5x8', '34x5x8', '34.0', '8.0', '5.0', '1.5', '10.00', 1), (45, '48x8x6', '48x8x6', '48.0', '8.0', '6.0', '2.0', '25.00', 1), (47, '13x13x13', '13x13x13', '13.0', '13.0', '13.0', '1.0', '5.00', 2); Quote John Wisdom Link to comment Share on other sites More sharing options...
Jan Zonjee Posted January 20, 2007 Share Posted January 20, 2007 Well, I'm puzzled now. Me too, because what are those first 5 (empty) boxes doing in that array? Quote Link to comment Share on other sites More sharing options...
John Wisdom Posted January 20, 2007 Share Posted January 20, 2007 The first 4 of the array are a product that's being packaged on its own. Do you think I have a problem somewhere else? Quote John Wisdom Link to comment Share on other sites More sharing options...
Jan Zonjee Posted January 20, 2007 Share Posted January 20, 2007 The first 4 of the array are a product that's being packaged on its own. Yes, you are right but why are they set ready-to-ship? I can't fathom that (and can't replicate it myself...) Quote Link to comment Share on other sites More sharing options...
Jan Zonjee Posted January 20, 2007 Share Posted January 20, 2007 The first 4 of the array are a product that's being packaged on its own. Do you think I have a problem somewhere else? I get the same thing when I use the "old" code that only looks if the product fits in the largest box by volume (which happens to be the 31x15x10 and since the product is 33 it doesn't fit. However, using the "new" code that looks if fits one of the boxes I don't have the problem. What happens if you mix such a product with a large number of other items I don't know. Could be a problem when it tries to stuff other things in the box and goes to a larger one in volume where it doesn't fit... Quote Link to comment Share on other sites More sharing options...
Jan Zonjee Posted January 20, 2007 Share Posted January 20, 2007 What happens if you mix such a product with a large number of other items I don't know. Could be a problem when it tries to stuff other things in the box and goes to a larger one in volume where it doesn't fit... It is a problem and the code cannot recover from it (maximum execution time exceeded). Changing things to keep apart products that will not fit in a box that is tried seems to work well. Most packing functions are changed: function packProducts($productsArray) { $definedPackages = $this->getPackagesByVol(); /* echo '<pre>'; print_r($definedPackages); exit; */ $emptyBoxesArray = array(); for ($i = 0; $i < count($definedPackages); $i++) { $definedBox = $definedPackages[$i]; $definedBox['remaining_volume'] = $definedBox['volume']; $definedBox['current_weight'] = $definedBox['empty_weight']; $emptyBoxesArray[] = $definedBox; } if (count($emptyBoxesArray) == 0) { print("ERROR: No boxes to ship unpackaged product<br />\n"); break; } $packedBoxesArray = array(); $currentBox = NULL; $index_of_largest_box = count($emptyBoxesArray)-1; // Get the product array and expand multiple qty items. $productsRemaining = array(); for ($i = 0; $i < count($productsArray); $i++) { $product = $productsArray[$i]; // sanity checks on the product $product['ready_to_ship'] = '1'; for ($x = 0; $x <= $index_of_largest_box; $x++) { if ($this->fitsInBox($product, $emptyBoxesArray[$x])) { $product['ready_to_ship'] = '0'; $product['largest_box_it_will_fit'] = $x; } } // end for ($x = 0; $x <= $index_of_largest_box; $x++) for ($j = 0; $j < $productsArray[$i]['quantity']; $j++) { $productsRemaining[] = $product; } } // end for ($i = 0; $i < count($productsArray); $i++) // make sure the products that did not fit the largest box and are now set as ready-to-ship // are out of the way as soon as possible usort($productsRemaining, ready_to_shipCmp); // Worst case, you'll need as many boxes as products ordered. while (count($productsRemaining)) { // Immediately set aside products that are already packed and ready. if ($productsRemaining[0]['ready_to_ship'] == '1') { $packedBoxesArray[] = array ( 'length' => $productsRemaining[0]['length'], 'width' => $productsRemaining[0]['width'], 'height' => $productsRemaining[0]['height'], 'current_weight' => $productsRemaining[0]['weight'], 'price' => $productsRemaining[0]['final_price']); $productsRemaining = array_slice($productsRemaining, 1); continue; } //Cycle through boxes, increasing box size if all doesn't fit. for ($b = 0; $b < count($emptyBoxesArray) && tep_not_null($productsRemaining); $b++) { $result = $this->fitProductsInBox($productsRemaining, $emptyBoxesArray[$b], $packedBoxesArray, $b, count($emptyBoxesArray) -1 ); $packedBoxesArray = $result['packed_boxes']; $productsRemaining = $result['remaining']; } } // end while return $packedBoxesArray; } //***************************** function fitsInBox($product, $box) { // in case by accident or by choice length, width or height is not set // we will estimate it by using a set density and the product['weight'] variable // will only be used in the check for whether it fits the largest box // after that it will already be set, if product['weight'] is set at least if ($product['x'] > $box['x'] || $product['y'] > $box['y'] || $product['z'] > $box['z']) { return false; } if ($product['volume'] <= $box['remaining_volume']) { if ($box['max_weight'] == 0 || ($box['current_weight'] + $product['weight'] <= $box['max_weight'])) { return true; } } return false; } //*********************************** function putProductInBox($product, $box) { $box['remaining_volume'] -= $product['volume']; $box['products'][] = $product; $box['current_weight'] += $product['weight']; $box['price'] += $product['final_price']; return $box; } //********************* function fitProductsInBox($productsRemaining, $emptyBox, $packedBoxesArray, $box_no, $index_of_largest_box) { $currentBox = $emptyBox; $productsRemainingSkipped = array(); $productsRemainingNotSkipped = array(); // keep apart products that will not fit this box anyway for ($p = 0; $p < count($productsRemaining); $p++) { if ($productsRemaining[$p]['largest_box_it_will_fit'] < $box_no) { $productsRemainingSkipped[] = $productsRemaining[$p]; } else { $productsRemainingNotSkipped[] = $productsRemaining[$p]; } } unset($productsRemaining); $productsRemaining = $productsRemainingNotSkipped; unset($productsRemainingNotSkipped); if (count($productsRemaining) == 0) { // products remaining are the ones that will not fit this box (productsRemaimingSkipped) $result_array = array('remaining' => $productsRemainingSkipped, 'box_no' => $box_no, 'packed_boxes' => $packedBoxesArray); return ($result_array); } //Try to fit each product that can fit in box for ($p = 0; $p < count($productsRemaining); $p++) { if ($this->fitsInBox($productsRemaining[$p], $currentBox)) { //It fits. Put it in the box. $currentBox = $this->putProductInBox($productsRemaining[$p], $currentBox); if ($p == count($productsRemaining) - 1) { $packedBoxesArray[] = $currentBox; $productsRemaining = array_slice($productsRemaining, $p + 1); $productsRemaining = array_merge($productsRemaining, $productsRemainingSkipped); $result_array = array('remaining' => $productsRemaining, 'box_no' => $box_no, 'packed_boxes' => $packedBoxesArray); return ($result_array); } } else { if ($box_no == $index_of_largest_box) { //We're at the largest box already, and it's full. Keep what we've packed so far and get another box. $packedBoxesArray[] = $currentBox; $productsRemaining = array_slice($productsRemaining, $p); $productsRemaining = array_merge($productsRemaining, $productsRemainingSkipped); $result_array = array('remaining' => $productsRemaining, 'box_no' => $box_no, 'packed_boxes' => $packedBoxesArray); return ($result_array); } // Not all of them fit. Stop packing remaining products and try next box. $productsRemaining = array_merge($productsRemaining, $productsRemainingSkipped); $result_array = array('remaining' => $productsRemaining, 'box_no' => $box_no, 'packed_boxes' => $packedBoxesArray); return ($result_array); } // end else } // end for ($p = 0; $p < count($productsRemaining); $p++) } // end function Quote Link to comment Share on other sites More sharing options...
John Wisdom Posted January 23, 2007 Share Posted January 23, 2007 Jan, YOU ARE A GENIUS! Well, maybe. Seriously, I plugged that in on my test site a few hours ago and it worked with some of the same products it was failing with before. But, I keep getting phone calls and emails so I haven't been able to do better testing. I'll give it some harder and more real world product combinations to see how well it will work, but intitially it looks great. Thanks a lot for your help on this because I don't know if I would have been able to make it work correctly. Do you think it will run into problems with time on large orders? Quote John Wisdom Link to comment Share on other sites More sharing options...
Jan Zonjee Posted January 23, 2007 Share Posted January 23, 2007 Do you think it will run into problems with time on large orders? No, I don't think so. I tested it with like 15 of each and it went well. First all the "little" stuff went in one box (when I first put the long ones in the shopping basket) and then the long ones went in a box that it fitted. So yes, I have confidence in it but more rigorous testing is always the best. Hopefully it will go well :) Quote Link to comment Share on other sites More sharing options...
tranquilsense Posted January 30, 2007 Share Posted January 30, 2007 So after uninstalling the XML mod and reinstalling the mod, I am still getting this unexplained pricing. As seen below: Canada Post (1 box(es) to be shipped) Priority Courier, 2007-02-01 $15.05 Expedited, 2007-02-01 $7.31 Regular, 2007-02-02 $7.31 Federal Express (Total items: 25 pcs. Total weight: 3.5 lbs) Priority (by 10:30AM, later for rural) $28.22 2 Day Air $27.23 Ground Service (1 days) $12.12 United Parcel Service (XML) (25 pkg(s), 3 lbs total) UPS Standard, 2007-01-31 $11.00 UPS Expedited, 2007-01-31 $2.00 UPS Saver $13.00 UPS Express Early A.M. $14.00 UPS Express, 2007-01-31 $1.00 Also the UPS module is not recognizing any weight or dimensions when it is quoting. I tried changing the weights to different weights. It show the weight in the header "United Parcel Service (XML) (25 pkg(s), 3 lbs total) ', but is not using that when calculating. I am still also receiving 2 low rates UPS Expedited, 2007-01-31 $2.00 UPS Express, 2007-01-31 $1.00 Here is a link to my error log. Any help is appreciated. http://www.tranquilsense.com/upserror.log Thanks Quote _________________________________________________________________________ David G Aschenbrener Tranquil | Sense - Your Stop for Tranquility. Link to comment Share on other sites More sharing options...
tranquilsense Posted January 30, 2007 Share Posted January 30, 2007 Will also pay to get this fixed. Thanks Quote _________________________________________________________________________ David G Aschenbrener Tranquil | Sense - Your Stop for Tranquility. 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.