♥kymation Posted February 20, 2010 Share Posted February 20, 2010 No, if no warnings were output, the function would still fail. It would have generated a warning anyway; that behavior has been in PHP since 3.1 (and probably before; I just don't remember.) 1. It shouldn't be an array, it should be a string. 2. No, it's set in in $shipping_data = $_POST['shipping_' . $vendor_id]; You're real close to the bug though. I think I've found it, based on what you are telling me. It's a Session error, probably caused by Register Globals being off and the rules being strictly enforced. This may have happened in PHP 5.3 or it may just be a combination of the settings on your server. Anyway, the bug is near the end of the code that you posted above: $shipping = array('id' => $shipping, Note that the final $shipping can have two values at this point: The Initial value of the variable set up above (an empty array) and the session variable that has previously been set. It appears that previous versions of PHP (and possibly 5.3 if it's set up a certain way) would use the Session variable. This is not happening in your case. So, just to find out if I'm anywhere near right, try replacing the line above with $shipping = array('id' => $SESSION['shipping'], Please let me know what that does. Regards Jim Quote See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
jfkafka Posted February 20, 2010 Share Posted February 20, 2010 1. It shouldn't be an array, it should be a string. 2. No, it's set in in $shipping_data = $_POST['shipping_' . $vendor_id]; try replacing the line above with $shipping = array('id' => $SESSION['shipping'], Please let me know what that does. Regards Jim Hi Jim, Thanks for your patience. -----------SNIPPET FROM CHECKOUT_SHIPPING.PHP------------------- // 2-19-10 original used below as potential fix $shipping = array('id' => $shipping, $shipping = array('id' => $SESSION['shipping'], 'title' => $shipping_title, 'cost' => $total_shipping_cost, 'shipping_tax_total' => $total_ship_tax, 'vendor' => $output ); print ' in classes/checkout shipping php line 146 ' . "<br />\n"; print 'module[id]: <pre>'; print_r ($module['id']); print 'vendor[id]: <pre>'; print_r ($output[$vendor_id]); print 'shipping: <pre>'; print_r ($shipping); print '</pre>'; ------------END OF SNIPPET------------------------------- ------------ECHO PRINTOUT------------------------------ in classes/checkout shipping php line 146 module[id]: uvendor[id]: Array ( [id] => usps_PARCEL [title] => Parcel Post (3 Days) [ship_tax] => 0 [products] => Array ( [0] => 1{4}3{3}6 ) [cost] => 12.18 ) shipping: Array ( [id] => [title] => Combined Shipping [cost] => 12.1801 [shipping_tax_total] => 0 [vendor] => Array ( [1] => Array ( [id] => freeamount_freeamount [title] => Economy (9 - 14 Days) [ship_tax] => 0 [products] => Array ( [0] => 20 [1] => 8 [2] => 11 [3] => 7 ) [cost] => 0.0001 ) [3] => Array ( [id] => usps_PARCEL [title] => Parcel Post (3 Days) [ship_tax] => 0 [products] => Array ( [0] => 1{4}3{3}6 ) [cost] => 12.18 ) ) ) -----------END OF ECHO PRINTOUT---------------------- Additional info yes, register globals is off 1. Also did a printout of: $shipping_data = $_POST['shipping_' . $vendor_id]; print ' $shipping_data: <pre>'; print_r ($shipping_data); -----------ECHO PRINTOUT---------------------- u $shipping_data: usps_PARCEL_0vendor[id]: -----------END OF ECHO PRINTOUT---------------------- 1. not sure where the u comes from in the above printout unless because it's not an array 2. would renaming shipping to something else be a solution 3. would using the vendor array to retrieve the info be a viable solution since it contains the two pieces of the shipping string ($_POST['shipping_' . $vendor_id];) Really appreciate your time and expertise, John Quote Link to comment Share on other sites More sharing options...
♥kymation Posted February 20, 2010 Share Posted February 20, 2010 1. That looks like the result of incorrectly accessing an array. The first letter of usps_PARCEL? That usps_PARCEL looks very suspicious as well. It could just be from the USPS module though. 2. That's only a solution if the problem is a naming conflict. If it were only that, this code would have failed long ago. 3. Try it and see. I'm temporarily out of ideas. This may not even be the problem, since I just guessed at that anyway. Regards Jim Quote See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
jfkafka Posted February 20, 2010 Share Posted February 20, 2010 scratch #3. it looks like $vendor_id should be a number hmmm... (3. would using the vendor array to retrieve the info be a viable solution since it contains the two pieces of the shipping string ($_POST['shipping_' . $vendor_id]) Quote Link to comment Share on other sites More sharing options...
jfkafka Posted February 20, 2010 Share Posted February 20, 2010 just did another test of shipping data --------CODE----------------------------------- $shipping_data = $_POST['shipping_' . $vendor_id]; print ' in classes/checkout shipping php line 96 ' . "<br />\n"; print 'shipping data: <pre>'; print_r ($shipping_data); print '</pre>'; --------END CODE------------------- ----------ECHO PRINTOUT------------------- in classes/checkout shipping php line 96 shipping data: freeamount_freeamount_0 in classes/checkout shipping php line 96 shipping data: usps_PARCEL_0 ---------END ECHO PRINTOUT------------------ that looks correct, I'm gonna run a few more tests Quote Link to comment Share on other sites More sharing options...
jfkafka Posted February 20, 2010 Share Posted February 20, 2010 Hi Jim, Howbout this: could you post the results of what the correct printout of print 'shipping: <pre>'; print_r ($shipping); print '</pre>'; should look like- (it would help to know exactly what results are being sought) specifically in classes/checkout shipping php approx line 140 AFTER $shipping = array('id' => $shipping, 'title' => $shipping_title, 'cost' => $total_shipping_cost, 'shipping_tax_total' => $total_ship_tax, 'vendor' => $output ); print ' in classes/checkout shipping php line 146 ' . "<br />\n"; print 'shipping: <pre>'; print_r ($shipping); print '</pre>'; ---------------------------------------- I think with that info I should be able to find some way to make id happen! Thanks a lot for all your input, John Quote Link to comment Share on other sites More sharing options...
♥kymation Posted February 20, 2010 Share Posted February 20, 2010 Well now look at that: shipping: Array ( [id] => Array ( ) [title] => Best Way [cost] => 5 [shipping_tax_total] => 0 [vendor] => Array ( [1] => Array ( [id] => flat_flat [title] => Best Way [ship_tax] => 0 [products] => Array ( [0] => 19 ) [cost] => 5 ) ) ) That's on my test server running PHP 5.2.9, so at least we know it's not PHP 5.3. And, of course, it works even with the error. This tells me that the ID is not the problem with your site, even though it's obviously wrong. Oh well. Looks like you'll have to keep searching. Regards Jim Quote See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
jfkafka Posted February 20, 2010 Share Posted February 20, 2010 That's on my test server running PHP 5.2.9, so at least we know it's not PHP 5.3. And, of course, it works even with the error. This tells me that the ID is not the problem with your site, even though it's obviously wrong. Oh well. Looks like you'll have to keep searching. Regards Jim Hi Jim, When you say "it works" do you mean that, given the $module['id'] array is empty, the code is still able to go into the If Statement in vendor_shipping.php: if ( (tep_not_null($module)) && (in_array(substr($module['id'], 0, strpos($module['id'], '_')) . '.' . substr($PHP_SELF, (strrpos($PHP_SELF, '.')+1)), $modules_array)) ) { I suspect that because the $module['id'] array is empty, the if statement is failing and going to the else portion, in other words not reassigning the $include_modules[] I came to this conclusion by adding an echo statement inside the if statement in vendor_shipping.php on the webhost which is running <php5.3 and doesn't generate warnings like the localhost, the result was the order confirmation page came up with no warnings and no echo statement or exit so either the code is bypassing the top portion of the If Statement and going to the else or echo statements are being ignored but the if statement is resolving to true and entering the top portion (not going to the else) in short, I'm wondering if the $module['id'] array needs to be assigned values in order to go into: if ( (tep_not_null($module)) && (in_array(substr($module['id'], 0, strpos($module['id'], '_')) . '.' . substr($PHP_SELF, (strrpos($PHP_SELF, '.')+1)), $modules_array)) ) { echo 'in vendor_shipping.php inside if'; exit; $include_modules[] = array('class' => substr($module['id'], 0, strpos($module['id'], '_')), 'file' => substr($module['id'], 0, strpos($module['id'], '_')) . '.' . substr($PHP_SELF, (strrpos($PHP_SELF, '.')+1))); ------------------------------- 1. Is it necessary for that portion to execute? (Maybe I'm just presuming it needs to) 2. If your code is going into the portion above, what would a printout of includes_modules[] look like (with multiple vendors) Thanks once more. I hope all this testing I'm doing does not include your patience. John Quote Link to comment Share on other sites More sharing options...
♥kymation Posted February 21, 2010 Share Posted February 21, 2010 1. I'm assuming not, or the code is dong something weird. In that case, setting $shipping = array('id' => '', would probably work. 2. Pretty much as expected: shipping: Array ( [id] => Array ( ) [title] => Combined Shipping [cost] => 12.5 [shipping_tax_total] => 0 [vendor] => Array ( [1] => Array ( [id] => flat_flat [title] => Best Way [ship_tax] => 0 [products] => Array ( [0] => 24 ) [cost] => 5 ) [3] => Array ( [id] => item_item [title] => Best Way [ship_tax] => 0 [products] => Array ( [0] => 3 ) [cost] => 7.5 ) ) ) No, my patience today is being tested by a different set of code. I think I finally have it beaten into submission though. Regards Jim Quote See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
jfkafka Posted February 21, 2010 Share Posted February 21, 2010 2. Pretty much as expected: shipping: Array ( [id] => Array ( ) [title] => Combined Shipping [cost] => 12.5 [shipping_tax_total] => 0 [vendor] => Array ( [1] => Array ( [id] => flat_flat [title] => Best Way [ship_tax] => 0 [products] => Array ( [0] => 24 ) [cost] => 5 ) [3] => Array ( [id] => item_item [title] => Best Way [ship_tax] => 0 [products] => Array ( [0] => 3 ) [cost] => 7.5 ) ) ) No, my patience today is being tested by a different set of code. I think I finally have it beaten into submission though. Regards Jim Hi yet again, I could be wrong, (Lord knows I've made a career of it) but the shipping array that you posted doesn't seem to be a printout of: (from classes/vendor_shipping.php) $include_modules[] = array('class' => substr($module['id'], 0, strpos($module['id'], '_')), 'file' => substr($module['id'], 0, strpos($module['id'], '_')) . '.' . substr($PHP_SELF, (strrpos($PHP_SELF, '.')+1))); This is what it looks like when it goes into the else part of the If Statement: (lists all the shipping modules) Array ( [0] => Array ( [class] => flat [file] => flat.php ) [1] => Array ( [class] => freeamount [file] => freeamount.php ) [2] => Array ( [class] => ups [file] => ups.php ) [3] => Array ( [class] => usps [file] => usps.php ) ) -------------------------------------- I was just wondering if your code was able to go into the top portion of the If Statement where it updates the $include_modules[] with only the shipping modules selected, and, if so, what the printout would look like since I try to avoid assuming, plus especially curious whether your code would even go into that part of the If Statement. Glad to hear of your having success getting the different set of code to "obey", I'm about to take this computer out to the woodshed. John Quote Link to comment Share on other sites More sharing options...
♥kymation Posted February 21, 2010 Share Posted February 21, 2010 Sorry, my mind was still in checkout_shipping.php. I'm not sure where you want me to put the print statement and what you want a printout of. Help? Regards Jim Quote See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
jfkafka Posted February 21, 2010 Share Posted February 21, 2010 Hi, It's in classes/vendor_shipping.php. In function shipping($module = '') there's an If Statement: if ( (tep_not_null($module)) && (in_array(substr($module['id'], 0, strpos($module['id'], '_')) . '.' . substr($PHP_SELF, (strrpos($PHP_SELF, '.')+1)), $modules_array)) ) { $include_modules[] = array('class' => substr($module['id'], 0, strpos($module['id'], '_')), 'file' => substr($module['id'], 0, strpos($module['id'], '_')) . '.' . substr($PHP_SELF, (strrpos($PHP_SELF, '.')+1))); // 2-20-10 ADDED PRINTOUT CODE print '$include_modules[]: <pre>'; print_r ($include_modules[]); print '</pre>' . "<br />\n"; exit; // X 2-20-10 ADDED PRINTOUT CODE } else { reset($modules_array); foreach ($installed_modules_array as $value) { $class = substr($value, 0, strrpos($value, '.')); $include_modules[] = array('class' => $class, 'file' => $value); }//foreach }////if tep_not_null --------------------------------- I added the code to the portion of the If statement where it updates the $include_modules[], but I think it never goes here because the $modules[id] array is blank/empty so that's why Warnings are fired in PHP5.3, so I was hoping you could test your vendor_shipping.php to see if your code ever enters the true portion of the If Statement and if so what the printout of the $include_modules[] array contains so I would know what to try to duplicate somehow. I'm inclined to think that empty $modules[id] needs to be populated (back in checkout_shipping.php), but it kinda depends on whether your code is able to produce a printout of an updated (only the selected shipping methods) $include_modules[] array within that If Statement OR evaluates to false and just goes to the else part (loops through ALL the shipping methods). I'm guessing your code will not produce a printout based on the empty $module[id] array. Then it will indicate either that $module[id] array needs to be assigned values to pass the If Statement or that it is unnecessary for the $include_modules[] to be populated with only specifically chosen shipping details(class and file) or maybe the conditions for the If Statement need to be modified. Hope the explanation makes sense and doesn't cause drowsiness. John Quote Link to comment Share on other sites More sharing options...
♥kymation Posted February 21, 2010 Share Posted February 21, 2010 Got it now. My mind has been set on the code I am working on, and I have trouble shifting gears. I tried your print code, and it never goes into the print section that you added. I added a print statement to the else part and it goes there. I admit I'm having trouble remembering this part of the code. Particularly embarrassing since this class is one of the parts that I wrote. Bah. If I'm remembering at all correctly, this is at the point where the customer has already selected the shipping method(s) so we should be looking at a single method. That means that the ID needs to be set. At this point I would go back to checkout_shipping.php and start looking for where that value should come from. Try using print_r to print out the $_SESSION and $_POST arrays. One of those should carry the value. Regards Jim Quote See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
jfkafka Posted February 21, 2010 Share Posted February 21, 2010 I tried your print code, and it never goes into the print section that you added. I added a print statement to the else part and it goes there. I admit I'm having trouble remembering this part of the code. Particularly embarrassing since this class is one of the parts that I wrote. Bah. Know precisely what you mean, I'm beginning to feel like the kid who said my memory is the thing I forget with. Well, I'm going to pursue populating that $modules[id] array back in checkout_shipping.php which is likely the point of origin. Thanks for all your support yesterday, will be in touch... John Quote Link to comment Share on other sites More sharing options...
jfkafka Posted February 21, 2010 Share Posted February 21, 2010 I think this may be the problem. in checkout_shipping.php there is this section: ----------STEP 1------------------ $shipping = array(); foreach ($vendor_shipping as $vendor_id => $vendor_data) { $products_shipped = $_POST['products_' . $vendor_id]; $products_array = explode ("_", $products_shipped); $shipping_data = $_POST['shipping_' . $vendor_id]; $shipping_array = explode ("_", $shipping_data); $module = $shipping_array[0]; $method = $shipping_array[1]; $ship_tax = $shipping_array[2]; ----------X STEP 1-------------------- further down this: --------STEP 2---------------- $shipping = array('id' => $shipping, --------X STEP 2-------------- which as we discovered is an empty array I am hypothesizing it's because in Step 1: $shipping_data = $_POST['shipping_' . $vendor_id]; $shipping_data is never added to the $shipping (array) in other words, in Step 2: $shipping = array('id' => $shipping, the => $shipping, has not been populated so we are adding an empty array to id which is why $modules[id] is blank the solution may be to simply include adding the shipping_data to shipping array in Step 1 I attempted to do so by adding a line here: $shipping_data = $_POST['shipping_' . $vendor_id]; // 2-21-10 jk added line to put shipping_data into shipping array $shipping = array('id' => $shipping_data); // 2-21-10 jk added line to put shipping_data into shipping array which did add this to a printout of shipping array: $shipping: Array ( [id] => Array ( [id] => usps_PRIORITY_0 ) As you can see, [id] is now present, BUT it is incorrect because it only includes the last vendor, because the line I added is instantiating a new shipping array each time through the foreach loop in step 1 where it should add all the (vendors) $shipping_data info to shipping BEFORE going to Step 2. Does that make sense? John Quote Link to comment Share on other sites More sharing options...
jfkafka Posted February 21, 2010 Share Posted February 21, 2010 Actually this seems to work better: $shipping_data = $_POST['shipping_' . $vendor_id]; // 2-21-10 jk added line to put shipping_data into shipping array $shipping[] = $shipping_data; // 2-21-10 jk added line to put shipping_data into shipping array Printout Result: Array ( [0] => freeamount_freeamount_0 [1] => usps_PARCEL_0 ) $shipping: Array ( [id] => Array ( [0] => freeamount_freeamount_0 [1] => usps_PARCEL_0 ) [title] => Combined Shipping [cost] => 12.1801 [shipping_tax_total] => 0 [vendor] => Array ( [1] => Array ( [id] => freeamount_freeamount [title] => Economy (9 - 14 Days) [ship_tax] => 0 [products] => Array ( [0] => 20 [1] => 8 [2] => 11 [3] => 7 ) [cost] => 0.0001 ) [3] => Array ( [id] => usps_PARCEL [title] => Parcel Post (3 Days) [ship_tax] => 0 [products] => Array ( [0] => 1{4}3{3}6 ) [cost] => 12.18 ) ) ) Now to see what happens in vendor_shipping.php and whether it now goes into the If Statement. John Quote Link to comment Share on other sites More sharing options...
jfkafka Posted February 22, 2010 Share Posted February 22, 2010 just an epilogue to my adventures assimilating arrays (purely in the interests of helping someone else although it seems to be non issue somehow) i confess i was working in the dark not completely understanding what the ultimate purpose of the If Statement was intended to accomplish only that it must have some role to fulfill otherwise what was it doing there? Right? yeah that means I was ASSuming and well, you know... anyway i finally got it to go into that If Statement in vendor_shipping.php by modifying the qualifications and had to further augment the $include_modules[] array assignments using what can best be described as frankenstein code, which i dug up from various google searches, which i hesitate to post it without explicit request/permission, lest it cause someone to use it and unwittingly "create a monster" meaning wreak havoc on their existing code but it does work for moi and is available upon requests, oh and there were also alterations to ot_shipping.php which having been implemented, no longer generate those pesky Warnings in PHP5.3 about expecting a string and an array is given, well that's it, crime stoppers now back to merging MVS with paypal ipn. later, jk Quote Link to comment Share on other sites More sharing options...
drillsar Posted February 26, 2010 Share Posted February 26, 2010 i'm trying to figure out to different table rates based by price, I tried to add alaska but it wont let me install it, when I click install nothing happens, or is there a easier or better way of doing this? can someone look at my code or can i upload it here, anyone else done this? Quote Link to comment Share on other sites More sharing options...
drillsar Posted February 26, 2010 Share Posted February 26, 2010 basically I want to add this contribution to mvs, here is the table.php, it uses different methods like alaska, 2 day, etc <?php /* $Id: table.php,v 1.27 2003/02/05 22:41:52 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2003 osCommerce Released under the GNU General Public License */ class table { var $code, $title, $description, $icon, $enabled; // class constructor function table() { global $order; $this->code = 'table'; $this->title = MODULE_SHIPPING_TABLE_TEXT_TITLE; $this->description = MODULE_SHIPPING_TABLE_TEXT_DESCRIPTION; $this->sort_order = MODULE_SHIPPING_TABLE_SORT_ORDER; // $this->icon = DIR_WS_ICONS . 'shipping_ups.gif'; //$this->icon = ''; $this->tax_class = MODULE_SHIPPING_TABLE_TAX_CLASS; $this->enabled = ((MODULE_SHIPPING_TABLE_STATUS == 'True') ? true : false); if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_TABLE_ZONE > 0) ) { $check_flag = false; $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_TABLE_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id"); while ($check = tep_db_fetch_array($check_query)) { if ($check['zone_id'] < 1) { $check_flag = true; break; } elseif ($check['zone_id'] == $order->delivery['zone_id']) { $check_flag = true; break; } } if ($check_flag == false) { $this->enabled = false; } } } // class methods function quote($method = '') { global $order, $cart, $shipping_weight, $shipping_num_boxes,$order_total; if (MODULE_SHIPPING_TABLE_MODE == 'Price') { $order_total = $cart->show_total(); } else { $order_total = $cart->show_weight(); } $availableMethods = array(); for ($methodNum = 1; $methodNum <= MODULE_SHIPPING_TABLE_NUMBER_OF_METHODS; $methodNum++) { $table_cost_name = 'MODULE_SHIPPING_TABLE_COST_METHOD_' . $methodNum; $table_text_name = 'MODULE_SHIPPING_TABLE_TEXT_METHOD_' . $methodNum; $table_cost = split("[:,]", constant($table_cost_name)); for ($i = 0; $i < sizeof($table_cost); $i += 2) { if (($table_cost[$i] == "infinity") || ($table_cost[$i] >= $order_total)) { $shipping = $table_cost[$i+1]; break; } } if ($i == sizeof($table_cost)) continue; if (MODULE_SHIPPING_TABLE_MODE == 'Weight') { $shipping *= $shipping_num_boxes; } if ( ($method == '') || ($method == $methodNum) ) { $availableMethods[] = array('id' => $methodNum, 'title' => constant($table_text_name), 'cost' => $shipping + MODULE_SHIPPING_TABLE_HANDLING); } } if (sizeof($availableMethods)) { $this->quotes = array('id' => $this->code, 'module' => $this->title, 'methods' => $availableMethods); } else { return false; } if ($this->tax_class > 0) { $this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']); } if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title); return $this->quotes; } function check() { if (!isset($this->_check)) { $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_TABLE_STATUS'"); $this->_check = tep_db_num_rows($check_query); } return $this->_check; } function install() { global $language; require(DIR_FS_CATALOG_LANGUAGES . "$language/modules/shipping/table.php"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Enable Table Method', 'MODULE_SHIPPING_TABLE_STATUS', 'True', 'Do you want to offer table rate shipping?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Table Method', 'MODULE_SHIPPING_TABLE_MODE', 'weight', 'The shipping cost is based on the order total or the total weight of the items ordered.', '6', '0', 'tep_cfg_select_option(array(\'Weight\', \'Price\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Handling Fee', 'MODULE_SHIPPING_TABLE_HANDLING', '0', 'Handling fee for this shipping method.', '6', '0', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_SHIPPING_TABLE_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Shipping Zone', 'MODULE_SHIPPING_TABLE_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_TABLE_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())"); if (0) { for ($methodNum = 1; $methodNum <= MODULE_SHIPPING_TABLE_NUMBER_OF_METHODS; $methodNum++) { $method = 'METHOD_' . $methodNum; $table_cost_name = 'MODULE_SHIPPING_TABLE_COST_' . $method; $table_text_name = 'MODULE_SHIPPING_TABLE_TEXT_' . $method; $sql = "insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('" . constant($table_text_name) . " Shipping Table', '" . $table_cost_name . "', '25:8.50,50:5.50,10000:0.00', 'The shipping cost is based on the total cost or weight of items. Example: 25:8.50,50:5.50,etc.. Up to 25 charge 8.50, from there to 50 charge 5.50, etc', '6', '0', now())"; //echo $sql . '<br>'; tep_db_query($sql); } } else { $methodNum = 0; do { $methodNum++; $table_cost_name = "MODULE_SHIPPING_TABLE_COST_METHOD_$methodNum"; $table_text_name = "MODULE_SHIPPING_TABLE_TEXT_METHOD_$methodNum"; if (!defined($table_text_name)) { $methodNum--; break; } $sql = "insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('" . constant($table_text_name) . " Shipping Table', '" . $table_cost_name . "', '25:8.50,50:5.50', 'The shipping cost is based on the total cost or weight of items. Example: 25:8.50,50:5.50. Up to 25 charge 8.50, from there to 50 charge 5.50, past 50 and this option is not allowed. Can also specify \"infinity\" to avoid a cap 25:8.50,50:5.50,infinity:4.75', '6', '0', now())"; tep_db_query($sql); } while (1); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Number of Methods', 'MODULE_SHIPPING_TABLE_NUMBER_OF_METHODS', '$methodNum', 'Number of registered shipping methods.', '6', '0', now())"); } } function remove() { tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key like 'MODULE_SHIPPING_TABLE%'"); } function keys() { $retval = array('MODULE_SHIPPING_TABLE_STATUS', 'MODULE_SHIPPING_TABLE_MODE', 'MODULE_SHIPPING_TABLE_HANDLING', 'MODULE_SHIPPING_TABLE_TAX_CLASS', 'MODULE_SHIPPING_TABLE_ZONE', 'MODULE_SHIPPING_TABLE_SORT_ORDER'); $result = tep_db_query("select configuration_key from " . TABLE_CONFIGURATION . " where configuration_key like 'MODULE_SHIPPING_TABLE_COST_METHOD%' order by configuration_key"); while ($row = tep_db_fetch_array($result)) { $retval[] = $row['configuration_key']; } return $retval; } } ?> Quote Link to comment Share on other sites More sharing options...
drillsar Posted February 26, 2010 Share Posted February 26, 2010 for some reason i hit install and nothing happens, here is the Alaska table I have done, whats wrong? <?php /* $Id: alaska.php,v 1.27 2003/02/05 22:41:52 hpdl Exp $ Modified for MVS V1.0 2006/03/25 JCK/CWG osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2006 osCommerce Released under the GNU General Public License */ class Alaska { var $code, $title, $description, $icon, $enabled, $vendors_id, $sort_order; // class constructor function Alaska() { global $order, $vendors_id; $this->code = 'Alaska'; $this->title = MODULE_SHIPPING_Alaska_TEXT_TITLE; $this->description = MODULE_SHIPPING_Alaska_TEXT_DESCRIPTION; $this->icon = ''; $this->delivery_country_id = $order->delivery['country']['id']; $this->delivery_zone_id = $order->delivery['zone_id']; } //MVS start function sort_order($vendors_id = '1') { $sort_order = @ constant('MODULE_SHIPPING_Alaska_SORT_ORDER_' . $vendors_id); if (isset ($sort_order)) { $this->sort_order = $sort_order; } else { $this->sort_order = '-'; } return $this->sort_order; } function tax_class($vendors_id = '1') { $this->tax_class = constant('MODULE_SHIPPING_Alaska_TAX_CLASS_' . $vendors_id); return $this->tax_class; } function enabled($vendors_id = '1') { $this->enabled = false; $status = @ constant('MODULE_SHIPPING_Alaska_STATUS_' . $vendors_id); if (isset ($status) && $status != '') { $this->enabled = (($status == 'True') ? true : false); } if (($this->enabled == true) && ((int) constant('MODULE_SHIPPING_Alaska_ZONE_' . $vendors_id) > 0)) { $check_flag = false; $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . (int) constant('MODULE_SHIPPING_Alaska_ZONE_' . $vendors_id) . "' and zone_country_id = '" . $this->delivery_country_id . "' order by zone_id"); while ($check = tep_db_fetch_array($check_query)) { if ($check['zone_id'] < 1) { $check_flag = true; break; } elseif ($check['zone_id'] == $this->delivery_zone_id) { $check_flag = true; break; } } if ($check_flag == false) { $this->enabled = false; } //if } //if return $this->enabled; } function zones($vendors_id = '1') { if (($this->enabled == true) && ((int) @ constant('MODULE_SHIPPING_Alaska_ZONE_' . $vendors_id) > 0)) { $check_flag = false; $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_ITEM_ZONE . "' and zone_country_id = '" . $this->delivery_zone_id . "' order by zone_id"); while ($check = tep_db_fetch_array($check_query)) { if ($check['zone_id'] < 1) { $check_flag = true; break; } elseif ($check['zone_id'] == $this->delivery_zone_id) { $check_flag = true; break; } //if } //while if ($check_flag == false) { $this->enabled = false; } //if } //if // print $this->code . ' zone enabled!'; return $this->enabled; } //function //MVS End //Get a quote function quote($method = '', $module = '', $vendors_id = '1') { global $HTTP_POST_VARS, $shipping_weight, $order, $cart, $shipping_num_boxes; switch (@constant('MODULE_SHIPPING_Alaska_MODE_' . $vendors_id) ) { case 'price': $order_total = $cart->vendor_shipping[$vendors_id]['cost']; break; case 'weight': $order_total = $cart->vendor_shipping[$vendors_id]['weight']; break; case 'quantity': $order_total = $cart->vendor_shipping[$vendors_id]['qty']; } // if (@ constant('MODULE_SHIPPING_TABLE_MODE_' . $vendors_id) == 'price') { // $order_total = $cart->vendor_shipping[$vendors_id]['cost']; // } else { // $order_total = $cart->vendor_shipping[$vendors_id]['weight']; // } $table_cost = split("[:,]", @ constant('MODULE_SHIPPING_Alaska_COST_' . $vendors_id)); $size = sizeof($table_cost); for ($i = 0, $n = $size; $i < $n; $i += 2) { if ($order_total <= $table_cost[$i]) { $pos = strpos($table_cost[$i +1], '%'); if ($pos === false) { $shipping = $table_cost[$i +1]; } else { $shipping_cost_temp = split("%", $table_cost[$i +1]); $shipping = $order_total * $shipping_cost_temp[0] / 100; } break; } } if (@ constant('MODULE_SHIPPING_Alaska_MODE_' . $vendors_id) == 'weight') { $shipping = $shipping * $shipping_num_boxes; } //MVS Start $vendors_data_query = tep_db_query("select handling_charge, handling_per_box, vendor_country, vendors_zipcode from " . TABLE_VENDORS . " where vendors_id = '" . (int) $vendors_id . "'"); $vendors_data = tep_db_fetch_array($vendors_data_query); $country_name = tep_get_countries($vendors_data['vendor_country'], true); $handling_charge = $vendors_data['handling_charge']; $handling_per_box = $vendors_data['handling_per_box']; if ($handling_charge > $handling_per_box * $shipping_num_boxes) { $handling = $handling_charge; } else { $handling = $handling_per_box * $shipping_num_boxes; } //MVS End //MVS - Changed 'cost' => $shipping + $handling $this->quotes = array ( 'id' => $this->code, 'module' => MODULE_SHIPPING_Alaska_TEXT_TITLE, 'methods' => array ( array ( 'id' => $this->code, 'title' => MODULE_SHIPPING_Alaska_TEXT_WAY, 'cost' => $shipping + $handling ) ) ); // $this->tax_class = constant(MODULE_SHIPPING_Alaska_TAX_CLASS_ . $vendors_id); if ($this->tax_class($vendors_id) > 0) { $this->quotes['tax'] = tep_get_tax_rate($this->tax_class($vendors_id), $order->delivery['country']['id'], $order->delivery['zone_id']); } if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title); return $this->quotes; } function check($vendors_id = '1') { if (!isset ($this->_check)) { //multi vendor add "vendors_id = '". $vendors_id ."' and" $check_query = tep_db_query("select configuration_value from " . TABLE_VENDOR_CONFIGURATION . " where vendors_id = '" . $vendors_id . "' and configuration_key = 'MODULE_SHIPPING_Alaska_STATUS_" . $vendors_id . "'"); $this->_check = tep_db_num_rows($check_query); } return $this->_check; } /////VID function install($vendors_id) { //multi vendor add 'vendors_id' to field names and '" . $vendors_id . "', to values // $vendors_id = $vendors_id; tep_db_query("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) VALUES ('Enable Table Method', 'MODULE_SHIPPING_Alaska_STATUS_" . $vendors_id . "', 'True', 'Do you want to offer table rate shipping?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now(), '" . $vendors_id . "')"); tep_db_query("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('Shipping Table', 'MODULE_SHIPPING_Alaska_COST_" . $vendors_id . "', '25:8.50,50:5.50,10000:0.00', 'The shipping cost is based on the total cost or weight of items. Example: 25:8.50,50:5.50,etc.. Up to 25 charge 8.50, from there to 50 charge 5.50, etc', '6', '0', now(), '" . $vendors_id . "')"); tep_db_query("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Table Method', 'MODULE_SHIPPING_Alaska_MODE_" . $vendors_id . "', 'weight', 'The shipping cost is based on the order total or the total weight of the items ordered.', '6', '0', 'tep_cfg_select_option(array(\'weight\', \'price\', \'quantity\'), ', now(), '" . $vendors_id . "')"); tep_db_query("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('Handling Fee', 'MODULE_SHIPPING_Alaska_HANDLING_" . $vendors_id . "', '0', 'Handling fee for this shipping method.', '6', '0', now(), '" . $vendors_id . "')"); tep_db_query("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added, vendors_id) values ('Tax Class', 'MODULE_SHIPPING_Alaska_TAX_CLASS_" . $vendors_id . "', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now(), '" . $vendors_id . "')"); tep_db_query("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added, vendors_id) values ('Shipping Zone', 'MODULE_SHIPPING_Alaska_ZONE_" . $vendors_id . "', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now(), '" . $vendors_id . "')"); tep_db_query("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('Sort Order', 'MODULE_SHIPPING_Alaska_SORT_ORDER_" . $vendors_id . "', '0', 'Sort order of display.', '6', '0', now(), '" . $vendors_id . "')"); } function remove($vendors_id) { tep_db_query("delete from " . TABLE_VENDOR_CONFIGURATION . " where vendors_id = '" . $vendors_id . "' and configuration_key in ('" . implode("', '", $this->keys($vendors_id)) . "')"); } function keys($vendors_id) { return array ( 'MODULE_SHIPPING_Alaska_STATUS_' . $vendors_id, 'MODULE_SHIPPING_Alaska_COST_' . $vendors_id, 'MODULE_SHIPPING_Alaska_MODE_' . $vendors_id, 'MODULE_SHIPPING_Alaska_HANDLING_' . $vendors_id, 'MODULE_SHIPPING_Alaska_TAX_CLASS_' . $vendors_id, 'MODULE_SHIPPING_Alaska_ZONE_' . $vendors_id, 'MODULE_SHIPPING_Alaska_SORT_ORDER_' . $vendors_id ); } } ?> Quote Link to comment Share on other sites More sharing options...
Guest Posted February 28, 2010 Share Posted February 28, 2010 Hello, I've tried to integrate MultiGeoZone MultiTable Shipping following the instruction in mvs for new shipping modules. At the begin it seems that worked, but I noticed that in the calculation of shipments by weight the system calculates the weight only when the weight is equivalent to the rate, for example if my table of rate is: 1: 27.5 , 1.5: 30 , 2: 32.8 This should mean that if the weight is from 0 to 1 kg the shipment rate is 27.5€, from 1 to 1.5 kg is 30€ and so on but my system doesn't read the between. If the product have a weight between 1 and 1.5 kg my osc just show 0€ as shipment rate. If the product weight is 1 or exactely 1.5 (or 2) kg then everything goes well. Can somebody help me to fix somehow this bug? This is my code for MZMS <?php /* $Id: mzmt.php,v 1.100 2004-11-09 Josh Dechant Exp $ Copyright (c) 2004 Josh Dechant osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Protions Copyright (c) 2003 osCommerce Released under the GNU General Public License */ class mzmt { var $code, $title, $description, $icon, $enabled, $num_zones, $num_tables, $delivery_geozone, $geozone_mode, $order_total; function mzmt() { global $order; $this->code = 'mzmt'; $this->title = MODULE_SHIPPING_MZMT_TEXT_TITLE; $this->description = MODULE_SHIPPING_MZMT_TEXT_DESCRIPTION; } // class methods // mvs function num_tables($vendors_id='1') { $vendors_data_query = tep_db_query("select num_tables from " . TABLE_VENDORS . " where vendors_id = '" . (int)$vendors_id . "'" ); $vendors_data = tep_db_fetch_array($vendors_data_query); $this->num_tables = $vendors_data['num_tables']; return $this->num_tables; } //Set the number of geozones used for this vendor function num_geozones($vendors_id='1') { $vendors_data_query = tep_db_query("select zones from " . TABLE_VENDORS . " where vendors_id = '" . (int)$vendors_id . "'" ); $vendors_data = tep_db_fetch_array($vendors_data_query); $this->num_zones = $vendors_data['zones']; return $this->num_zones; } function sort_order($vendors_id='1') { if (defined (@constant ('MODULE_SHIPPING_MZMT_SORT_ORDER_' . $vendors_id))) { $this->sort_order = @constant('MODULE_SHIPPING_MZMT_SORT_ORDER_' . $vendors_id); } else { $this->sort_order = '0'; } return $this->sort_order; } function tax_class($vendors_id='1') { $this->tax_class = constant('MODULE_SHIPPING_MZMT_TAX_CLASS_' . $vendors_id); return $this->tax_class; } function enabled($vendors_id='1') { $this->enabled = false; $status = constant('MODULE_SHIPPING_MZMT_STATUS_' . $vendors_id); if (isset ($status) && $status != '') { $this->enabled = (($status == 'True') ? true : false); } return $this->enabled; } function zones($vendors_id='1') { if ( ($this->enabled == true) && ((int)constant('MODULE_SHIPPING_TABLE_ZONE_' . $vendors_id) > 0) ) { $check_flag = false; $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . (int)constant('MODULE_SHIPPING_TABLE_ZONE_' . $vendors_id) . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id"); while ($check = tep_db_fetch_array($check_query)) { if ($check['zone_id'] < 1) { $check_flag = true; break; } elseif ($check['zone_id'] == $order->delivery['zone_id']) { $check_flag = true; break; } //if }//while if ($check_flag == false) { $this->enabled = false; }//if }//if return $this->enabled; }//function // end mvs function quote($method = '', $module = '', $vendors_id = '1') { global $order, $shipping_weight; //MVS Start //return an error if the module is not enabled for this vendor if ($this->enabled($vendors_id) < 1) { $this->quotes['error'] = MODULE_SHIPPING_ZONES_INVALID_ZONE; return $this->quotes; } $enabled = false; for ($n=1; $n<=$this->num_geozones($vendors_id); $n++) { if ( ((int)constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $n . '_ID_' . $vendors_id) > 0) && ((int)constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $n . '_ID_' . $vendors_id) == $this->getGeoZoneID($order->delivery['country']['id'], $order->delivery['zone_id'])) ) { $enabled = true; $this->delivery_geozone = $n; break; } elseif ( ((int)constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $n . '_ID_' . $vendors_id) == 0) && ($n == (int)$this->num_geozones) ) { $enabled = true; $this->delivery_geozone = $n; break; } } if (!$enabled) { $this->quotes['error'] = MODULE_SHIPPING_ZONES_INVALID_ZONE; return $this->quotes; } $vendors_data_query = tep_db_query("select handling_charge, handling_per_box, vendor_country, vendors_zipcode from " . TABLE_VENDORS . " where vendors_id = '" . (int)$vendors_id . "'" ); $vendors_data = tep_db_fetch_array($vendors_data_query); $country_name = tep_get_countries($vendors_data['vendor_country'], true); $handling_charge = $vendors_data['handling_charge']; $handling_per_box = $vendors_data['handling_per_box']; if ($handling_charge > $handling_per_box*$shipping_num_boxes) { $handling = $handling_charge; } else { $handling = $handling_per_box*$shipping_num_boxes; } //MVS End(' . $shipping_weight . ' kgs)'. ' $this->quotes = array('id' => $this->code, 'module' => constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_TEXT_TITLE') , 'methods' => array()); $this->determineTableMethod(constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_MODE_' . $vendors_id)); if ($method) { $j = substr($method, 5); $shipping = $this->determineShipping(split("[:,]" , constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_TABLE_' . $j . '_' . $vendors_id))); $this->quotes['methods'][] = array('id' => 'table' . $j, 'title' => constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_TABLE_' . $j . '_TEXT_WAY'), // same for all vendors - omit vendors_id 'cost' => $shipping + constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_HANDLING' . '_' . $vendors_id)); } else { for ($j=1; $j<=$this->num_tables($vendors_id); $j++) { if (!tep_not_null(constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_TABLE_' . $j . '_' . $vendors_id))) continue; $shipping = $this->determineShipping(split("[:,]" , constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_TABLE_' . $j . '_' . $vendors_id))); $this->quotes['methods'][] = array('id' => 'table' . $j, 'title' => constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_TABLE_' . $j . '_TEXT_WAY'), // same for all vendors - omit vendors_id 'cost' => $shipping + constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_HANDLING' . '_' . $vendors_id)); } } if ($this->tax_class > 0) { $this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']); } if (tep_not_null(constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_ICON'))) $this->quotes['icon'] = tep_image(DIR_WS_ICONS . constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_ICON'), $this->title); return $this->quotes; } function check($vendors_id='1') { if (!isset($this->_check)) { $check_query = tep_db_query("select configuration_value from " . TABLE_VENDOR_CONFIGURATION . " where vendors_id = '". $vendors_id ."' and configuration_key = 'MODULE_SHIPPING_MZMT_STATUS_" . $vendors_id . "'"); $this->_check = mysql_num_rows($check_query); } return $this->_check; } function install($vendors_id='1') { $query = "insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Enable MultiRegion MultiTable Method', 'MODULE_SHIPPING_MZMT_STATUS_" . $vendors_id . "', 'True', 'Do you want to offer multi-region multi-table rate shipping?', '6', '0', \"tep_cfg_select_option(array('True', 'False'),\", now(), '" . $vendors_id . "')"; tep_db_query($query); $query = "insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added, vendors_id) values ('Tax Class', 'MODULE_SHIPPING_MZMT_TAX_CLASS_" . $vendors_id . "', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now(), '" . $vendors_id . "' )"; tep_db_query($query); $query = "insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('Sort Order', 'MODULE_SHIPPING_MZMT_SORT_ORDER_" . $vendors_id . "', '0', 'Sort order of display.', '6', '0', now(), '" . $vendors_id . "')"; tep_db_query($query); for ($n=1; $n<=$this->num_geozones($vendors_id); $n++) { $query = "insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added, vendors_id) values ('<hr />Geo Zone $n', 'MODULE_SHIPPING_MZMT_GEOZONE_{$n}_ID_" . $vendors_id . "', '', 'Enable this for the following geo zone.', '6', '0', 'tep_get_zone_class_title', '_cfg_pull_down_geozones(', now(), '" . $vendors_id . "')"; tep_db_query($query); $query = "insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Geo Zone $n Table Method', 'MODULE_SHIPPING_MZMT_GEOZONE_{$n}_MODE_" . $vendors_id . "', 'weight', 'The shipping cost is based on the total weight, total price, or total count of the items ordered.', '6', '0', 'tep_cfg_select_option(array(\'weight\', \'price\', \'count\'), ', now(), '" . $vendors_id . "')"; tep_db_query($query); for ($j=1; $j<=$this->num_tables($vendors_id); $j++) { $query = "insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('Geo Zone $n Shipping Table $j', 'MODULE_SHIPPING_MZMT_GEOZONE_{$n}_TABLE_{$j}_" . $vendors_id . "', '', 'Shipping table $j for this geo zone', '6', '0', now(), '" . $vendors_id . "')"; tep_db_query($query); } $query = "insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('Geo Zone $n Handling Fee', 'MODULE_SHIPPING_MZMT_GEOZONE_{$n}_HANDLING_" . $vendors_id . "', '0', 'Handling Fee for this shipping geo zone', '6', '0', now(), '" . $vendors_id . "')"; tep_db_query($query); } } function remove($vendors_id) { tep_db_query("delete from " . TABLE_VENDOR_CONFIGURATION . " where vendors_id = '". $vendors_id ."' and configuration_key in ('" . implode("', '", $this->keys($vendors_id)) . "')"); } function keys($vendors_id) { $keys = array('MODULE_SHIPPING_MZMT_STATUS_' . $vendors_id, 'MODULE_SHIPPING_MZMT_TAX_CLASS_' . $vendors_id, 'MODULE_SHIPPING_MZMT_SORT_ORDER_' . $vendors_id); for ($n=1; $n<=$this->num_geozones($vendors_id); $n++) { $keys[] = 'MODULE_SHIPPING_MZMT_GEOZONE_' . $n . '_ID_' . $vendors_id; $keys[] = 'MODULE_SHIPPING_MZMT_GEOZONE_' . $n . '_MODE_' . $vendors_id; $keys[] = 'MODULE_SHIPPING_MZMT_GEOZONE_' . $n . '_HANDLING_' . $vendors_id; for ($j=1; $j<=$this->num_tables($vendors_id); $j++) { $keys[] = 'MODULE_SHIPPING_MZMT_GEOZONE_' . $n . '_TABLE_' . $j . '_' . $vendors_id; } } return $keys; } function determineTableMethod($geozone_mode) { global $total_count, $shipping_weight; $this->geozone_mode = $geozone_mode; if ($this->geozone_mode == 'price') { $this->order_total = $_SESSION['cart']->show_total(); } elseif ($this->geozone_mode == 'count') { $this->order_total = $total_count; } else { $this->order_total = $shipping_weight; } return true; } function determineShipping($table_cost) { global $shipping_num_boxes; for ($i=0, $n=sizeof($table_cost); $i<$n; $i+=2) { if ($this->order_total >= $table_cost[$i]) { $shipping_factor = $table_cost[$i+1]; } } if (substr_count($shipping_factor, '%') > 0) { $shipping = ((($this->order_total*10)/10)*((str_replace('%', '', $shipping_factor))/100)); } else { $shipping = str_replace('$', '', $shipping_factor); } if ($this->geozone_mode == 'weight') { $shipping = $shipping * $shipping_num_boxes; } return $shipping; } function getGeoZoneID($country_id, $zone_id) { // First, check for a Geo Zone that explicity includes the country & specific zone (useful for splitting countries with zones up) $zone_query = tep_db_query("select gz.geo_zone_id from " . TABLE_GEO_ZONES . " gz left join " . TABLE_ZONES_TO_GEO_ZONES . " ztgz on (gz.geo_zone_id = ztgz.geo_zone_id) where ztgz.zone_country_id = '" . (int)$country_id . "' and ztgz.zone_id = '" . (int)$zone_id . "' and LOWER(gz.geo_zone_name) like 'shp%'"); if (mysql_num_rows($zone_query)) { $zone = mysql_fetch_assoc($zone_query); return $zone['geo_zone_id']; } else { // No luck… Now check for a Geo Zone for the country and "All Zones" of the country. $zone_query = tep_db_query("select gz.geo_zone_id from " . TABLE_GEO_ZONES . " gz left join " . TABLE_ZONES_TO_GEO_ZONES . " ztgz on (gz.geo_zone_id = ztgz.geo_zone_id) where ztgz.zone_country_id = '" . (int)$country_id . "' and (ztgz.zone_id = '0' or ztgz.zone_id is NULL) and LOWER(gz.geo_zone_name) like 'shp%'"); if (mysql_num_rows($zone_query)) { $zone = mysql_fetch_assoc($zone_query); return $zone['geo_zone_id']; } else { return false; } } } } function _cfg_pull_down_geozones($zone_class_id, $key = '') { $name = (($key) ? 'configuration[' . $key . ']' : 'configuration_value'); $zone_class_array = array(array('id' => '0', 'text' => 'Rest of the World')); $zone_class_query = tep_db_query("select geo_zone_id, geo_zone_name from " . TABLE_GEO_ZONES . " where LOWER(geo_zone_name) like 'shp%' order by geo_zone_name"); while ($zone_class = mysql_fetch_assoc($zone_class_query)) { $zone_class_array[] = array('id' => $zone_class['geo_zone_id'], 'text' => $zone_class['geo_zone_name']); } return tep_draw_pull_down_menu($name, $zone_class_array, $zone_class_id); } ?> Quote Link to comment Share on other sites More sharing options...
♥kymation Posted February 28, 2010 Share Posted February 28, 2010 Have you tested the unmodified module with MVS turned off? I'm seeing some very odd code. If this thing actually works, take a look at Lines 135 and 138: $shipping_num_boxes is undefined. Normally thins would need to be declared as a global. Regards Jim Quote See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
motorcity Posted March 1, 2010 Share Posted March 1, 2010 We've noticed that the "Free Shipping w/ Minimum Order Amount" module doesn't work in respect to the maximum weight. Has anyone else had this problem? I downloaded the MVS rollover update and looked through those files but I haven't found anything. Quote Link to comment Share on other sites More sharing options...
♥kymation Posted March 1, 2010 Share Posted March 1, 2010 In catalog/includes/moducle/vendors_shipping/freeamount.php, Lines 128, 134, and 137: Remove the space between the @ and the constant... and see if that helps. Otherwise I don't see anything that looks wrong here. Regards Jim Quote See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
motorcity Posted March 2, 2010 Share Posted March 2, 2010 In catalog/includes/moducle/vendors_shipping/freeamount.php, Lines 128, 134, and 137: Remove the space between the @ and the constant... and see if that helps. Otherwise I don't see anything that looks wrong here. Regards Jim Thanks Jim, but actually the extra space only shows up in the rollup update, it's not in the original file and that's what I'm running. Full disclosure; I copied the freeamount files and renamed them fairamount, renaming everything that said free to fair and changing only line 126 $shipping = @constant('MODULE_SHIPPING_FREEAMOUNT_COST_' . $vendors_id) + $handling + my_new_shipping_cost_minimum_number; It works fine except for those items or order quantities where the order weight goes over (10 lbs) or whatever your setpoint max weight is. I tested it just now on a product that is well over the minimum cost and over the maximum weight, it jams right through as the preselected shipping method where it shouldn't even show to the customer. Thanks in advance for any direction or insight into finding the answer. Motorcity 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.