Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Xml Ordering System To Manufacturer


stew_g4

Recommended Posts

Hello all, im hoping someone can help me with this:

 

I have set up the oscommerce site very basically and need to integrate some code into the ordering process before i go too far

 

I have 2 class files (stockpriceandchecker.class.php and xpath.class.php) which will order (via xml feed) the products directly from the manufacturer. Where in the oscommerce php code do i need to modify and with what statements and where do i need to place these files?

 

I have enclosed the file stockprice and checker below in the hope of getting a responce (note i have changed the suppliers name to supplier for obvious reasons), but i cant show the xpath file as it has 6265 lines of code and makes the post too long - my apologies for this:

 

stockpriceandchecker.class.php

 

<?php

require_once('classes/XPath.class.php');

/**

* StockAndPriceChecker class.

*

* This class provides a very simple interface to the XML Stock and Price Service from Supplier.

* You can use it to gain real time information on all of our products.

*

* {@internal

* You will need to download the xPath class in order to use this class, the xPath class must

* be placed somewhere accesable on your server. Then you must alter the include in the

* StockAndPriceChecker class file to reflect where the xPath class is stored as the

* example shows.

* <code>

* {require_once('/path/to/XPath.class.php');}

* </code>

* The class may be obtained from

* {@link http://sourceforge.net/projects/phpxpath/} }}

* You may instantiate a new instance of this class by following the example below

* <code>

* require_once('/path/to/StockAndPriceChecker.class.php');

* $objStkPriceChk=new StockAndPriceChecker();

* </code>

* @version 1.00

* @copyright Supplier Ltd. 2005

*/

class StockAndPriceChecker

{

/**

* Your Account Number.

* This must be changed to your ten digit account number issued by Supplier.

* @access private

* @var string

* @example 0000123456

*/

var $account_no='0000520465';

/**

* Your Password.

* This must be changed to the password for XML Query Service issued by Supplier.

* @access private

* @var string

* @example y0urpa55w0rd

*/

var $password='aw63fd7aw';

/**

* Part Number (Manufacturer or Supplier).

* This may be either the Manufacturer or Supplier Part Number and will be used to in the "querySupplier" method

* which grabs the XML data from the Supplier server. This should not be initialised here. To swap between using

* the Manufacturer or Supplier Part Number you must set the "manuOrMidwPn" variable to the appropriate value.

* @access private

* @var string

* @see manuOrMidwPn

* @see querySupplier

*/

var $part_pn='';

/**

* xPath Object.

* The xPath object is initialised in the constructor call and is responsible for grabbing and parsing the XML

* returned from the query.

* @access private

* @var object

*/

var $xPath;

/**

* Debug Flag.

* This cannot be set directly, this variable controls this class's debug functionality only, to get full

* debug information you should use the "setDebug" function as this also sets the debug flag for the xPath

* class which has some exelent debug of it's own.

* @access private

* @var boolean

* @example false

* @see setDebug

*/

var $debug=false;

/**

* Manufacturer or Supplier Part Number Flag.

* This can either be hard coded her or altered between requests by accessing the variable directly

* through the "StockAndPriceChecker" object you have created.

* @access public

* @var string

* @example midwpn or manupn

*/

var $manuOrMidwPn='midwpn';

 

/**

* Constructor StockAndPriceChecker.

* This constructor creates a new instance of the xPath class and sets any relevant variables within

* it.

*/

function StockAndPriceChecker()

{

$this->xPath = new XPath();

$this->xPath->bDebugXmlParse=$this->debug;

}

 

/**

* querySupplier queries the Supplier servers to get the realtime XML data.

* This function can be called many times to retrieve new data using the same object. Do this rather

* than instantiating a new StockAndPriceChecker object.

* @access public

* @param string [$pn] the Manufacturer of Supplier Part Number to retrieve data for.

*/

function querySupplier($pn)

{

$this->_reset();

$this->part_pn=$pn;

$this->part_pn;

if(!$this->xPath->importFromFile('http://www.Supplier.com/services/realtimeCheck.php?message=QUERY&tpid=' . $this->account_no . '&pass=' . $this->password . '&'.$this->manuOrMidwPn.'=' . $this->part_pn) && $this->debug){_debug($this->xPath->getLastError());}

}

 

/**

* setDebug sets the debug flag for StockAndPriceChecker and xPath.

* This function can be used to get extra debug info during development. The method sets both the

* StockAndPriceChecker and the xPath flag.

* @access public

* @param boolean [$value] debug flag (true or false).

*/

function setDebug($value)

{

$this->debug=$value;

$this->xPath->bDebugXmlParse=$value;

}

 

/**

* getSuccess assertains wether the xml has been recieved sucessfuly.

* This function is used to ascertain wether an error has occured, and if debug mode is set it will

* print out the error message to the screen.

* @access public

* @return boolean true or false depending on success.

*/

function getSuccess()

{

$result=false;

switch($this->xPath->getData('/query[1]/queryheader[1]/queryresult[1]/result[1]'))

{

case 'QUERY SUCCESS':

$result=true;

break;

case 'QUERY FAIL':

$result=false;

if($this->debug){_debug($this->xPath->getData('/query[1]/queryheader[1]/queryresult[1]/info[1]'));}

break;

default:

$result=false;

break;

}

return $result;

}

 

/**

* getGenerationTime Returns The Time And Date The Data Was Generated.

* This function returns the time and date the data was generated for debugging or logging purposes.

* @access public

* @return array array('date'=>20050601,'time'=>233355)

*/

function getGenerationTime()

{

return array('date'=>$this->xPath->getData('/query[1]/queryheader[1]/generation[1]/date[1]'), 'time'=>$this->xPath->getData('/query[1]/queryheader[1]/generation[1]/time[1]'));

}

 

/**

* getProductData Returns All Product Data Returned From The XML Query.

* This function returns an associative array of all product information gained from the XML query.

* @access public

* @return array array(midwpartno,manupartno,manuname,productname,category,description,list,deale

rprice,weight,stock,type)

*/

function getProductData()

{

return array(

'midwpartno'=>$this->xPath->wholeText('/query[1]/productdata[1]/midwpartno[1]'),

'manupartno'=>$this->xPath->wholeText('/query[1]/productdata[1]/manupartno[1]'),

'manuname'=>$this->xPath->wholeText('/query[1]/productdata[1]/manuname[1]'),

'productname'=>$this->xPath->wholeText('/query[1]/productdata[1]/productname[1]'),

'category'=>$this->xPath->wholeText('/query[1]/productdata[1]/category[1]'),

'description'=>$this->xPath->wholeText('/query[1]/productdata[1]/description[1]'),

'list'=>$this->xPath->wholeText('/query[1]/productdata[1]/list[1]'),

'dealerprice'=>$this->xPath->wholeText('/query[1]/productdata[1]/dealerprice[1]'),

'weight'=>$this->xPath->wholeText('/query[1]/productdata[1]/weight[1]'),

'stock'=>$this->xPath->wholeText('/query[1]/productdata[1]/stock[1]'),

'type'=>$this->xPath->wholeText('/query[1]/productdata[1]/type[1]')

);

}

 

/**

* getStock Returns Value Of Current Stock Level.

* This function returns the current stock level of the product the query was run for.

* @access public

* @return integer stock level value

*/

function getStock()

{

return $this->xPath->getData('/query[1]/productdata[1]/stock[1]');

}

 

/**

* getCost Returns Value Of Current Cost To You.

* This function returns the current cost to you of the product the query was run for.

* @access public

* @return float(2 d.p) dealer cost

*/

function getCost()

{

return $this->xPath->getData('/query[1]/productdata[1]/dealerprice[1]');

}

 

/**

* getAccessoryList Returns Accessory Details.

* This function returns an associative array of all the queried products accessories.

* @access public

* @return array array(array(midwpartno,manupartno,manuname,productname)) Accessory details

*/

function getAccessoryList()

{

$noAccessories=count($this->xPath->getDataParts('/query[1]/accessorylist[1]'))-1;

for($i=1;$i<=$noAccessories;$i++)

{

$aAccessoryList[]=array(

'midwpartno'=>$this->xPath->getData('/query[1]/accessorylist[1]/accessory['.$i.']/midwpartno[1]'),

'manupartno'=>$this->xPath->getData('/query[1]/accessorylist[1]/accessory['.$i.']/manupartno[1]'),

'manuname'=>$this->xPath->getData('/query[1]/accessorylist[1]/accessory['.$i.']/manuname[1]'),

'productname'=>$this->xPath->getData('/query[1]/accessorylist[1]/accessory['.$i.']/productname[1]')

); }

return $aAccessoryList;

}

 

/**

* getXMLAsHTML XML Formated As HTML.

* This function returns a HTML representation of the XML returned from the current query.

* @access public

* @return string HTML formated XML

*/

function getXMLAsHTML()

{

return $this->xPath->exportAsHtml();

}

 

/**

* getXML Raw XML Data.

* This function returns the raw XML from the query.

* @access public

* @return string Raw XML

*/

function getXML()

{

return $this->xPath->exportAsXml();

}

 

/**

* exportXMLToFile Export Raw XML Data To A File.

* This function writes the raw XML from the query to the specified file.

* @access public

* @param string [$filename] string value of a path to a file.

*/

function exportXMLToFile($filename)

{

return $this->xPath->exportToFile($filename);

}

 

/**

* _reset resets the xPath Object.

* This function resets the xPath object so that is does not have to be re-insantiated when

* making another XML query using the same object.the specified file.

* @access private

*/

function _reset()

{

$this->xPath->reset();

}

 

/**

* _debug formats debug info.

* This function formats debug information

* @access private

*/

function _debug($value)

{

echo '<br><hr><b>'.$value.'</b><hr><br>';

}

}

?>

 

 

Your help is very much appreciated

Link to comment
Share on other sites

Why not use config>my store>send extra order emails to

 

Just may need to tweak the email contents a bit to get it how you want it to be sent. That email will include the customers address, what they ordered etc etc.

Link to comment
Share on other sites

Some of you may have noticed I have the wrong filename its supposed to be StockAndPriceChecker class. Thanks for the response and I can use email ordering but I was hoping to use the xml as it’s preferred by the supplier. Thats of course if anyone knows how to implement it as i am bloomin useless. :'(

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...