Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Call to undefined method xpress::isEnabled() public_html/includes/classes/osc_template.php on line 92


nafri

Recommended Posts

hi

 

i been at this for a while.. cant get the module to work ..It works fine in 2.2 rc2 but not in 2.3.3. I get this error message..

 

Call to undefined method xpress::isEnabled() public_html/includes/classes/osc_template.php on line 92 ..cant see anything in line 92 that is at fault.

 

if ( $mb->isEnabled() ) {
		    $mb->execute();
		  }

 

My module code is

 

<?php
/*
 $Id: ot_total.php 1739 2007-12-20 00:52:16Z hpdl $
 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com
 Copyright (c) 2003 osCommerce
 Released under the GNU General Public License
*/
 class xpress {
   var $title, $output, $uname, $pw, $response, $status, $qty, $price,$enabled = false;
   function xpress() {
  $this->code = 'xpress';
  $this->title = MODULE_STOCK_XPRESS_TITLE;
  $this->description = MODULE_STOCK_XPRESS_DESCRIPTION;
  $this->enabled = ((MODULE_STOCK_XPRESS_STATUS == 'true') ? true : false);
  $this->sort_order = MODULE_STOCK_XPRESS_SORT_ORDER;
  $this->shopid = base64_encode(MODULE_STOCK_XPRESS_SHOPID);
  $this->acccode = base64_encode(MODULE_STOCK_XPRESS_ACCODE);
  $this->output = '';

   }

function process($manupn){
 unset($this->qty);
 $this->xml = '<apiRequest xmlns="API_Request_ProductDetails">
   <header>
 <apiVersion>1</apiVersion>
 <userID>' . $this->shopid . '</userID>
 <loginGUID>' . $this->acccode . '</loginGUID>
   </header>
   <request>
 <searchRequest>
  <itemcode>' . $manupn . '</itemcode>
 </searchRequest>
   </request>
  </apiRequest>';

 $this->response = $this->xml2array($this->sendrequest($this->xml));
 $this->status = 'fail';
 if(isset($this->response['productdescription']['product']['item_qty']['value'])){
  $this->status = 'success';
  $this->qty = $this->response['productdescription']['product']['item_qty']['value'];
  $this->price = $this->response['productdescription']['product']['item_price']['value'];
 } else {
  $this->price = NULL;
 }
}
function sendrequest($xml){
 // set curl header options
 $curl_header = "POST https://xxxxxxxxxxxxxxxxxxxxxxxxx HTTP/1.0 \r\n";
 $curl_header .= "MIME-Version: 1.0 \r\n";
 $curl_header .= "Content-type: application/PTI26 \r\n";
 $curl_header .= "Content-length: ".strlen($xml)." \r\n";
 $curl_header .= "Content-transfer-encoding: text \r\n";
 $curl_header .= "Request-number: 1 \r\n";
 $curl_header .= "Document-type: Request \r\n";
 $curl_header .= "Interface-Version: Test 1.4 \r\n";
 $curl_header .= "Connection: close \r\n\r\n";
 $curl_header .= $xml;// add xml to header
 $curl = curl_init();// create curl handler
 // set curl options
 curl_setopt($curl, CURLOPT_URL, "https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
 curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
 curl_setopt($curl, CURLOPT_TIMEOUT, 30);
 curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $curl_header);
 curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
 curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
 $response = curl_exec($curl);// execute the curl request
 if(curl_errno($curl)){// check for error in processing curl request
  exit;
 }
 curl_close($curl);// close the curl connection
 return $response;
}

function xml2array($contents, $get_attributes=1) {
   if(!$contents) return array();
   if(!function_exists('xml_parser_create')) {
    //print "'xml_parser_create()' function not found!";
    return array();
   }
   //Get the XML parser of PHP - PHP must have this module for the parser to work
   $parser = xml_parser_create();
   xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, 0 );
   xml_parser_set_option( $parser, XML_OPTION_SKIP_WHITE, 1 );
   xml_parse_into_struct( $parser, $contents, $xml_values );
   xml_parser_free( $parser );
   if(!$xml_values) return;//Hmm...
   //Initializations
   $xml_array = array();
   $parents = array();
   $opened_tags = array();
   $arr = array();
   $current = &$xml_array;
   //Go through the tags.
   foreach($xml_values as $data) {
    unset($attributes,$value);//Remove existing values, or there will be trouble
    //This command will extract these variables into the foreach scope
    // tag(string), type(string), level(int), attributes(array).
    extract($data);//We could use the array by itself, but this cooler.
    $result = '';
    if($get_attributes) {//The second argument of the function decides this.
	    $result = array();
	    if(isset($value)) $result['value'] = base64_decode($value);
	    //Set the attributes too.
	    if(isset($attributes)) {
		    foreach($attributes as $attr => $val) {
			    if($get_attributes == 1) $result['attr'][$attr] = $val; //Set all the attributes in a array called 'attr'
			    /**  :TODO: should we change the key name to '_attr'? Someone may use the tagname 'attr'. Same goes for 'value' too */
		    }
	    }
    } elseif(isset($value)) {
	    $result = $value;
    }
    //See tag status and do the needed.
    if($type == "open") {//The starting of the tag '<tag>'
	    $parent[$level-1] = &$current;
	    if(!is_array($current) or (!in_array($tag, array_keys($current)))) { //Insert New tag
		    $current[$tag] = $result;
		    $current = &$current[$tag];
	    } else { //There was another element with the same tag name
		    if(isset($current[$tag][0])) {
			    array_push($current[$tag], $result);
		    } else {
			    $current[$tag] = array($current[$tag],$result);
		    }
		    $last = count($current[$tag]) - 1;
		    $current = &$current[$tag][$last];
	    }
    } elseif($type == "complete") { //Tags that ends in 1 line '<tag />'
	    //See if the key is already taken.
	    if(!isset($current[$tag])) { //New Key
		    $current[$tag] = $result;
	    } else { //If taken, put all things inside a list(array)
		    if((is_array($current[$tag]) and $get_attributes == 0)//If it is already an array...
				    or (isset($current[$tag][0]) and is_array($current[$tag][0]) and $get_attributes == 1)) {
			    array_push($current[$tag],$result); // ...push the new element into that array.
		    } else { //If it is not an array...
			    $current[$tag] = array($current[$tag],$result); //...Make it an array using using the existing value and the new value
		    }
	    }
    } elseif($type == 'close') { //End of tag '</tag>'
	    $current = &$parent[$level-1];
    }
   }
   return($xml_array);
}

   function check() {
  if (!isset($this->_check)) {
    $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_STOCK_XPRESS_STATUS'");
    $this->_check = tep_db_num_rows($check_query);
  }
  return $this->_check;
   }
   function keys() {
  return array('MODULE_STOCK_XPRESS_STATUS', 'MODULE_STOCK_XPRESS_SORT_ORDER', 'MODULE_STOCK_XPRESS_SHOPID', 'MODULE_STOCK_XPRESS_ACCODE');
   }
   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 Xpress', 'MODULE_STOCK_XPRESS_STATUS', 'true', 'Do you want to enable Xpress stock checker?', '6', '1','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 ('Shop ID', 'MODULE_STOCK_XPRESS_SHOPID', '', 'Xpress Shop ID', '6', '2', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Account Code', 'MODULE_STOCK_XPRESS_ACCODE', '', 'Xpress Account Code', '6', '3', 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_STOCK_XPRESS_SORT_ORDER', '1', 'Sort order of display.', '6', '4', now())");
   }
   function remove() {
  tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
   }
 }
?>

 

I hope someone can have a look and let me know whats wrong...

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...