spencerb Posted October 5, 2007 Share Posted October 5, 2007 I'm trying to make a mod based on Individual Shipping Prices, but to install it as an order total module to calculate shipping insurance. Now at checkout_confirmation, I get Fatal error: Call to undefined function: process() in .../includes/classes/order_total.php on line 41 I have never edited that file for any contribution or mod. I tried installing later and earlier versions of the contrib and get the same error. Here's the code: function process() { $order_total_array = array(); if (is_array($this->modules)) { reset($this->modules); while (list(, $value) = each($this->modules)) { $class = substr($value, 0, strrpos($value, '.')); if ($GLOBALS[$class]->enabled) { $GLOBALS[$class]->process(); ***THIS IS LINE 41*** for ($i=0, $n=sizeof($GLOBALS[$class]->output); $i<$n; $i++) { if (tep_not_null($GLOBALS[$class]->output[$i]['title']) && tep_not_null($GLOBALS[$class]->output[$i]['text'])) { $order_total_array[] = array('code' => $GLOBALS[$class]->code, 'title' => $GLOBALS[$class]->output[$i]['title'], 'text' => $GLOBALS[$class]->output[$i]['text'], 'value' => $GLOBALS[$class]->output[$i]['value'], 'sort_order' => $GLOBALS[$class]->sort_order); I don't understand how the function process was defined but suddenly becomes undefined. What is actually going on in the function? I assume there is some downstream process that's the actual problem. Link to comment Share on other sites More sharing options...
Jan Zonjee Posted October 5, 2007 Share Posted October 5, 2007 I don't understand how the function process was defined but suddenly becomes undefined. I assume order_total is loading your new module, which hasn't got a function process therefore the error. Link to comment Share on other sites More sharing options...
spencerb Posted October 5, 2007 Author Share Posted October 5, 2007 Thank you! So I changed a function quote to function process. I now get no errors. But the line in the order total shows a price of zero. I fiddled with the array a bit to make it look like other order total modules' arrays: $this->output[] = array('title' => MODULE_ORDER_TOTAL_INDVINS_TEXT_TITLE . ':', 'text' => $currencies->format($value, true, $order->info['currency'], $order->info['currency_value']), 'value' => $instot); I echo $instot, and it shows the correct number. But for some reason the array is failing. I'm going to look at it some more. I think I need to hack at the code a bit to make it more like the other order total modules. Link to comment Share on other sites More sharing options...
spencerb Posted October 5, 2007 Author Share Posted October 5, 2007 I found an error that caused the price to end up as zero on the confirmation page. So now all the line items are correct, but it's not adding the individual insurance to the total. Here's the array in the module: $this->output[] = array('title' => MODULE_ORDER_TOTAL_INDVINS_TEXT_TITLE . ':', 'text' => $currencies->format($instot, true, $order->info['currency'], $order->info['currency_value']), 'value' => $instot); I feel like I'm so close! I keep looking at how other order total modules are constructed, and so far can't find the problem. Oh, and I did check the sort order and it seems fine. Link to comment Share on other sites More sharing options...
Jan Zonjee Posted October 5, 2007 Share Posted October 5, 2007 I feel like I'm so close! I keep looking at how other order total modules are constructed, and so far can't find the problem. Did you add a line like this in the function that instantiates the class like: $this->enabled = ((MODULE_ORDER_TOTAL_LOWORDERFEE_STATUS == 'true') ? true : false); Link to comment Share on other sites More sharing options...
spencerb Posted October 7, 2007 Author Share Posted October 7, 2007 Did you add a line like this in the function that instantiates the class like: $this->enabled = ((MODULE_ORDER_TOTAL_LOWORDERFEE_STATUS == 'true') ? true : false); Yes, I have: $this->enabled = ((MODULE_ORDER_TOTAL_INDVINS_STATUS == 'True') ? true : false); I know the capitalization is odd, but down under function install() is has 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 Individual Insurance Prices', 'MODULE_ORDER_TOTAL_INDVINS_STATUS', 'True', 'Do you want to offer individual insurance prices?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'\False\'), ', now())"); So the case matches up. It seems like the module is enabled, since is does show up on checkout_confirmation and will show the price as a line item. It's just the it's not being added into the total. Link to comment Share on other sites More sharing options...
spencerb Posted October 8, 2007 Author Share Posted October 8, 2007 Got it. I was missing $order->info['total'] += $instot; In the module file. Apparently the output array is what displays the price, and that line above is what sends the price to be calculated into the order total. Link to comment Share on other sites More sharing options...
spencerb Posted October 8, 2007 Author Share Posted October 8, 2007 I got it all working, and I have uploaded it as a contribution. Hopefully my efforts can help someone in the future. Individual Product Order Total Fee http://www.oscommerce.com/community/contributions,5461 Thanks to all who helped! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.