Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Looping on checkout_shipping because of new Shipping modules


Guest

Recommended Posts

Hey all...

 

I'm having a problem with looping on the checkout_shipping page. Whenever you select the shipping method and press continue, it just refreshes the same page. You are never taken to the checkout_payment page. After a whole bunch of reading here in the Forums, I was able to determine that the problem has to do with some modifications to the Table shipping module. Read on...

 

I have copied and modified the Table-based shipping module, table.php, so that I could setup and configure three different table shipping rates per my clients request. No problem. Each of the modules is active and working.

 

Something within these modified files is causing the looping problem. If I were to deactivate all of the new Table Rate Shipping modules and activate any of the other shipping modules, for instance Flat Rate, everything works fine and I am redirected to the checkout_payment page like I am supposed to.

 

So... my question is this, what is going on in these files that is keeping it from progressing past checkout_shipping? I did not change any of the code logic, I just did some renaming of some of the variables.

 

BTW... snapshot 2/11/2003

 

I have included a copy of one of the modified files below. You can compare it to the default table.php file (catalog/includes/modules/shipping/table.php) that comes with osC.

 

I'm sure its something easy that I'm missing.

<?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 (c) 2003 osCommerce



 Released under the GNU General Public License

*/



 class ups_ground {

   var $code, $title, $description, $icon, $enabled;



// class constructor

   function ups_ground() {

     global $order;



     $this->code = 'ups_ground';

     $this->title = MODULE_SHIPPING_UPS_GROUND_TEXT_TITLE;

     $this->description = MODULE_SHIPPING_UPS_GROUND_TEXT_DESCRIPTION;

     $this->sort_order = MODULE_SHIPPING_UPS_GROUND_SORT_ORDER;

     $this->icon = '';

     $this->tax_class = MODULE_SHIPPING_UPS_GROUND_TAX_CLASS;

     $this->enabled = ((MODULE_SHIPPING_UPS_GROUND_STATUS == 'True') ? true : false);



     if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_UPS_GROUND_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_UPS_GROUND_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;



     if (MODULE_SHIPPING_UPS_GROUND_MODE == 'price') {

       $order_total = $cart->show_total();

     } else {

       $order_total = $shipping_weight;

     }



     $table_cost = split("[:,]" , MODULE_SHIPPING_UPS_GROUND_COST);

     $size = sizeof($table_cost);

     for ($i=0, $n=$size; $i<$n; $i+=2) {

       if ($order_total <= $table_cost[$i]) {

         $shipping = $table_cost[$i+1];

         break;

       }

     }



     if (MODULE_SHIPPING_UPS_GROUND_MODE == 'weight') {

       $shipping = $shipping * $shipping_num_boxes;

     }



     $this->quotes = array('id' => $this->code,

                           'methods' => array(array('id' => $this->code,

                                                    'title' => MODULE_SHIPPING_UPS_GROUND_TEXT_WAY,

                                                    'cost' => $shipping + MODULE_SHIPPING_UPS_GROUND_HANDLING)));



     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_UPS_GROUND_STATUS'");

       $this->_check = tep_db_num_rows($check_query);

     }

     return $this->_check;

   }



   function install() {

     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_UPS_GROUND_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, date_added) values ('Shipping Table', 'MODULE_SHIPPING_UPS_GROUND_COST', '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())");

     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_UPS_GROUND_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_UPS_GROUND_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_UPS_GROUND_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_UPS_GROUND_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_UPS_GROUND_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");

   }



   function remove() {

     tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");

   }



   function keys() {

     return array('MODULE_SHIPPING_UPS_GROUND_STATUS', 'MODULE_SHIPPING_UPS_GROUND_COST', 'MODULE_SHIPPING_UPS_GROUND_MODE', 'MODULE_SHIPPING_UPS_GROUND_HANDLING', 'MODULE_SHIPPING_UPS_GROUND_TAX_CLASS', 'MODULE_SHIPPING_UPS_GROUND_ZONE', 'MODULE_SHIPPING_UPS_GROUND_SORT_ORDER');

   }

 }

?>

Thanks!

 

-R

Link to comment
Share on other sites

Problem solved!!! I'm writing this as a courtesy to anyone else that may encounter this issue.

 

I remember reading somewhere in one of the many threads (I think it was a response from Linda), to make sure not to include any numbers within the functions or variables. It was something like that.

 

That made me think about the naming conventions I used for the Class/Function names... ups_ground, ups_next_day, ups_second_day. I was courious if having an "_" in the name was causing the issue.

 

I checked all of the other shipping modules included with osC for the use of an "_" in the Class/Functions... not a one. Each and every shipping modules uses a single word Class/Function... i.e. "flat", "table" or "zone".

 

Just for giggles, I modified one of the new Shipping modules, ups_ground, to reflect a single word naming convention... "ground"... both in the filename and Class/Functions.

 

HaHa... That was it!!!

 

So, in addition to never using numbers in the filename of Class/Function statements, you should also never use and "_" .

 

Hope this helps others!

 

Good Luck!

 

-R

Link to comment
Share on other sites

Hello. I'm glad you posted your answer to the problem. Maybe you can help me figure it out like you did. I don't understand where these Class/Function things are that you're talking about? I installed a couple of modules (Easy Populate and Separate Pricing) and now my site hangs up on the shipping part of checkout (keeps looping, as you described). So I copied all the files from my backup into the cart to fix it, but it still loops on the shipping! Where do I go to look at what you've described?

 

Thanks!

Link to comment
Share on other sites

This is my /www/catalog/includes/modules/shipping/table.php

 

Does it look right? I'm posting it here to compare it to yours.

I've not made any extra shipping modules. I have only the standard OSC ones.

 

<?php

/*

 $Id: table.php,v 1.22 2002/11/01 04:47:03 hpdl Exp $

 

 osCommerce, Open Source E-Commerce Solutions

 http://www.oscommerce.com

 

 Copyright © 2002 osCommerce

 

 Released under the GNU General Public License

*/

 

 class table {

   var $code, $title, $description, $icon, $enabled;

 

// class constructor

   function table() {

     $this->code = 'table';

     $this->title = MODULE_SHIPPING_TABLE_TEXT_TITLE;

     $this->description = MODULE_SHIPPING_TABLE_TEXT_DESCRIPTION;

     $this->icon = '';

     $this->enabled = MODULE_SHIPPING_TABLE_STATUS;

   }

 

// class methods

   function quote($method = '') {

     global $cart, $shipping_weight, $shipping_num_boxes;

 

     if (MODULE_SHIPPING_TABLE_MODE == 'price') {

       $order_total = $cart->show_total();

     } else {

       $order_total = $shipping_weight;

     }

 

     $table_cost = split("[:,]" , MODULE_SHIPPING_TABLE_COST);

     for ($i=0, $n=sizeof($table_cost); $i<$n; $i+=2) {

       if ($order_total <= $table_cost[$i]) {

         $shipping = $table_cost[$i+1];

         break;

       }

     }

 

     if (MODULE_SHIPPING_TABLE_MODE == 'weight') {

       $shipping = $shipping * $shipping_num_boxes;

     }

 

     $this->quotes = array('id' => $this->code,

                           'module' => MODULE_SHIPPING_TABLE_TEXT_TITLE,

                           'methods' => array(array('id' => $this->code,

                                                    'title' => MODULE_SHIPPING_TABLE_TEXT_WAY,

                                                    'cost' => $shipping + MODULE_SHIPPING_TABLE_HANDLING)));

 

     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() {

     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) VALUES ('Enable Table Method', 'MODULE_SHIPPING_TABLE_STATUS', '1', 'Do you want to offer table rate shipping?', '6', '0', now())");

     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Shipping Table', 'MODULE_SHIPPING_TABLE_COST', '25:8.50,50:5.50,10000:0.00', 'Shipping based on the total cost 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())");

     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', '5', '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, set_function, date_added) values ('Table Method', 'MODULE_SHIPPING_TABLE_MODE', 'weight', 'Is the shipping table based on total Weight or Total amount of order.', '6', '0', 'tep_cfg_select_option(array('weight', 'price'), ', now())");

   }

 

   function remove() {

     $keys = '';

     $keys_array = $this->keys();

     for ($i=0; $i<sizeof($keys_array); $i++) {

       $keys .= "'" . $keys_array[$i] . "',";

     }

     $keys = substr($keys, 0, -1);

 

     tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in (" . $keys . ")");

   }

 

   function keys() {

     return array('MODULE_SHIPPING_TABLE_STATUS', 'MODULE_SHIPPING_TABLE_COST', 'MODULE_SHIPPING_TABLE_HANDLING', 'MODULE_SHIPPING_TABLE_MODE');

   }

 }

?>

Link to comment
Share on other sites

Also note, if you recently upgraded snapshots, a lot of times if there are changes to the shipping and payment classes or modules the settings in the configuration table are no longer correct or may be missing something.

 

Backup current settings especially for zone or table and turn off all of the shipping modules and turn them all on so they reset their values.

 

Then edit them as needed to put in your settings.

 

Now see if that helps fix the problem in checkout.

Link to comment
Share on other sites

I remember reading somewhere in one of the many threads (I think it was a response from Linda), to make sure not to include any numbers within the functions or variables. It was something like that.

 

That made me think about the naming conventions I used for the  Class/Function names... ups_ground, ups_next_day, ups_second_day. I was courious if having an "_" in the name was causing the issue.

 

I know I have run into this a zillion times and posted that somewhere along the way.

 

It does help to hear that happened to you too and was not my imagination or something weird I was doing in my customized modules that made it appear to be the problem.

 

I have never pursued the reasons to this issue in the classes, I just know they break so don't do it. And sometimes, I even remember to follow that rule before my modules start to flake out on me ... :roll:

Link to comment
Share on other sites

The files I had the "_" that I was having problems with were located in catalog/includes/modules/shipping, which it looks like you found.

 

My particular problem was self-created, though. When I modified the existing table.php shipping file and created my own, instead of making the Class/Functions a single word, like "ground" or "nextday", I used "ups_ground", or "ups_next_day". This would correspond to "table" in your example.

 

As Linda said, I don't know why it doesn't work, I just know that it doesn't and steer around it.

 

Turn off ALL of your shipping modules, then turn on just "Flat Rate" (for testing purposes) and see if you can get past the checkout_shipping page. If so, you know that the problem is in one of your Shipping Modules that you turned off. If not, than the problem is elsewhere.

 

As Linda was eluding to, depending on the date of your osC snapshot, because of changes to the checkout, you could have an incompatibility somewhere between one of your addon's and osC. By turning off all of your shipping modules, you are removing all aspects of these modules from the DB. When you turn them back on, the modules are read and once again loaded into the DB and made active.

 

Hope this helps!

 

-R

Link to comment
Share on other sites

Hi, thanks for the input.

 

I think I'm getting closer to the problem. I can't even see the shipping modules in the admin interface. It's just this line of code:

Module Directory: DIR_FS_CATALOG_MODULESshipping/

 

Linda is trying to help me figure out why it's there instead of the shipping modules.

 

I'll let you know, b/c more people than me have had this problem and there needs to be a solution posted.

 

Thanks! - Lindsay

Link to comment
Share on other sites

  • 2 months later...

Do you see in the Shipping modules a Free Shipping?

 

If so, you have an old version that requires this to be on and a weight in the products that are not Free Shipping. Same with the Free Payments.

 

The Downloads Controller v5.3 uses the new logic of Payment modules orders_status and they can be on or off and you do not need to add weight to the products unless you want to use the Free Shipping module.

Link to comment
Share on other sites

Nope, didn't see a Free Shipping. We're using a very recent snapshot. I did get this problem "fixed" but now have a totally new problem that doesn't really relate to this thread, so I'll do some searching on that and may post a new thread if I don't see a solution.

 

Thanks for your help.

Link to comment
Share on other sites

Nope, didn't see a Free Shipping. We're using a very recent snapshot. I did get this problem "fixed" but now have a totally new problem that doesn't really relate to this thread, so I'll do some searching on that and may post a new thread if I don't see a solution.

 

And ... you were about to share the fix with everyone so we all learn something new ... right?! :wink:

Link to comment
Share on other sites

Well, my "fix" didn't really work, at least not completely.

 

What I did is instead of creating and enabling three different "table" shipping "clones", I used the pre-packaged "table" shipping method (just changed the text to meet my needs) and used two "clones" . For some reason, this took care of the looping - have no idea why.

 

However, this created a new problem (which I started a new thread on). Now, instead of the radio buttom defaulting to the cheapest (which is the original table.php), it defaults to the most expensive (one of my clones). The biggest problem, however, is that no matter which of the three shipping methods is selected on the checkout_shipping page, when the order summary comes up, the cheapest method (original table.php) is always the one quoted and displayed. I'm really confused as to why the checkout is ignoring the customer's selection. If anyone cares to check it out, you'll have to go through the order process (you can use the card number - fake - 4111111111111111 exp 01/04) at http://www.improveyournutrition.com

 

I hope that makes sense. If I can just get this figured out, I can go live :)

Link to comment
Share on other sites

I was having a problem with looping also. Then it magically stopped. What turned out to be the problem is I've been stress testing this app, trying to get ready to go live. The customer wanted PayPal for the time being. If you dump out of a transaction right after going to PayPal without actually paying and then try to return to the home page, your dead in the water. You will loop forever. The only way to get out of it is close the browser and reopen, starting a new session, then proceed to checkout. This is not the normal process anyone would ever take but it had me thinking I broke the app (again) Fortunately Linda came to my rescue and showed me it worked fine (yea Linda).

 

Ruth in AZ

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...