Page 1 of 2

What the heck am i doing with php and xml???

Posted: Sun Jun 24, 2007 5:17 am
by stew_g4
Complete noob in this field so please bear with me, i have tried posting this on oscommerce forums but to know avail.

Basically i have started developing a site and chosen oscommerce to save time and because i have no php knowledge as its due to go live in 2 weeks, i need to integrate some code into the ordering process before i go too far.

I think by placing some code in the "checkout_confirmation.php" page i can call on the functions to work in the stockpriceandchecker.class.php (an additional file recieved from the suppliers) so that when you click Confirm order the file sends an xml data file to them to order the product.

Please note i have now started teaching myself php in the unfortunate event that i ever need to do something like this again

the file below is stockpriceandchecker.class.php

Code: Select all

<?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>';
}
}
?>
And the checkout_confirmation page is as follows:

Code: Select all

<?php
/*
  $Id: checkout_confirmation.php,v 1.139 2003/06/11 17:34:53 hpdl Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

  require('includes/application_top.php');

// if the customer is not logged on, redirect them to the login page
  if (!tep_session_is_registered('customer_id')) {
    $navigation->set_snapshot(array('mode' => 'SSL', 'page' => FILENAME_CHECKOUT_PAYMENT));
    tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
  }

// if there is nothing in the customers cart, redirect them to the shopping cart page
  if ($cart->count_contents() < 1) {
    tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
  }

// avoid hack attempts during the checkout procedure by checking the internal cartID
  if (isset($cart->cartID) && tep_session_is_registered('cartID')) {
    if ($cart->cartID != $cartID) {
      tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
    }
  }

// if no shipping method has been selected, redirect the customer to the shipping method selection page
  if (!tep_session_is_registered('shipping')) {
    tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
  }

  if (!tep_session_is_registered('payment')) tep_session_register('payment');
  if (isset($HTTP_POST_VARS['payment'])) $payment = $HTTP_POST_VARS['payment'];

  if (!tep_session_is_registered('comments')) tep_session_register('comments');
  if (tep_not_null($HTTP_POST_VARS['comments'])) {
    $comments = tep_db_prepare_input($HTTP_POST_VARS['comments']);
  }

// load the selected payment module
  require(DIR_WS_CLASSES . 'payment.php');
  $payment_modules = new payment($payment);

  require(DIR_WS_CLASSES . 'order.php');
  $order = new order;

  $payment_modules->update_status();

  if ( ( is_array($payment_modules->modules) && (sizeof($payment_modules->modules) > 1) && !is_object($$payment) ) || (is_object($$payment) && ($$payment->enabled == false)) ) {
    tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(ERROR_NO_PAYMENT_MODULE_SELECTED), 'SSL'));
  }

  if (is_array($payment_modules->modules)) {
    $payment_modules->pre_confirmation_check();
  }

// load the selected shipping module
  require(DIR_WS_CLASSES . 'shipping.php');
  $shipping_modules = new shipping($shipping);

  require(DIR_WS_CLASSES . 'order_total.php');
  $order_total_modules = new order_total;

// Stock Check
  $any_out_of_stock = false;
  if (STOCK_CHECK == 'true') {
    for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
      if (tep_check_stock($order->products[$i]['id'], $order->products[$i]['qty'])) {
        $any_out_of_stock = true;
      }
    }
    // Out of Stock
    if ( (STOCK_ALLOW_CHECKOUT != 'true') && ($any_out_of_stock == true) ) {
      tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
    }
  }

  require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CHECKOUT_CONFIRMATION);

  $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
  $breadcrumb->add(NAVBAR_TITLE_2);
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="3" cellpadding="3">
  <tr>
    <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
    </table></td>
<!-- body_text //-->
    <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
            <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_confirmation.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
      <tr>
        <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
          <tr class="infoBoxContents">
<?php
  if ($sendto != false) {
?>
            <td width="30%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
              <tr>
                <td class="main"><?php echo '<b>' . HEADING_DELIVERY_ADDRESS . '</b> <a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING_ADDRESS, '', 'SSL') . '"><span class="orderEdit">(' . TEXT_EDIT . ')</span></a>'; ?></td>
              </tr>
              <tr>
                <td class="main"><?php echo tep_address_format($order->delivery['format_id'], $order->delivery, 1, ' ', '<br>'); ?></td>
              </tr>
<?php
    if ($order->info['shipping_method']) {
?>
              <tr>
                <td class="main"><?php echo '<b>' . HEADING_SHIPPING_METHOD . '</b> <a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '"><span class="orderEdit">(' . TEXT_EDIT . ')</span></a>'; ?></td>
              </tr>
              <tr>
                <td class="main"><?php echo $order->info['shipping_method']; ?></td>
              </tr>
<?php
    }
?>
            </table></td>
<?php
  }
?>
            <td width="<?php echo (($sendto != false) ? '70%' : '100%'); ?>" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
              <tr>
                <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
<?php
  if (sizeof($order->info['tax_groups']) > 1) {
?>
                  <tr>
                    <td class="main" colspan="2"><?php echo '<b>' . HEADING_PRODUCTS . '</b> <a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '"><span class="orderEdit">(' . TEXT_EDIT . ')</span></a>'; ?></td>
                    <td class="smallText" align="right"><b><?php echo HEADING_TAX; ?></b></td>
                    <td class="smallText" align="right"><b><?php echo HEADING_TOTAL; ?></b></td>
                  </tr>
<?php
  } else {
?>
                  <tr>
                    <td class="main" colspan="3"><?php echo '<b>' . HEADING_PRODUCTS . '</b> <a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '"><span class="orderEdit">(' . TEXT_EDIT . ')</span></a>'; ?></td>
                  </tr>
<?php
  }

  for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
    echo '          <tr>' . "\n" .
         '            <td class="main" align="right" valign="top" width="30">' . $order->products[$i]['qty'] . '&nbsp;x</td>' . "\n" .
         '            <td class="main" valign="top">' . $order->products[$i]['name'];

    if (STOCK_CHECK == 'true') {
      echo tep_check_stock($order->products[$i]['id'], $order->products[$i]['qty']);
    }

    if ( (isset($order->products[$i]['attributes'])) && (sizeof($order->products[$i]['attributes']) > 0) ) {
      for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {
        echo '<br><nobr><small>&nbsp;<i> - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'] . '</i></small></nobr>';
      }
    }

    echo '</td>' . "\n";

    if (sizeof($order->info['tax_groups']) > 1) echo '            <td class="main" valign="top" align="right">' . tep_display_tax_value($order->products[$i]['tax']) . '%</td>' . "\n";

    echo '            <td class="main" align="right" valign="top">' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . '</td>' . "\n" .
         '          </tr>' . "\n";
  }
?>
                </table></td>
              </tr>
            </table></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
      <tr>
        <td class="main"><b><?php echo HEADING_BILLING_INFORMATION; ?></b></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
      <tr>
        <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
          <tr class="infoBoxContents">
            <td width="30%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
              <tr>
                <td class="main"><?php echo '<b>' . HEADING_BILLING_ADDRESS . '</b> <a href="' . tep_href_link(FILENAME_CHECKOUT_PAYMENT_ADDRESS, '', 'SSL') . '"><span class="orderEdit">(' . TEXT_EDIT . ')</span></a>'; ?></td>
              </tr>
              <tr>
                <td class="main"><?php echo tep_address_format($order->billing['format_id'], $order->billing, 1, ' ', '<br>'); ?></td>
              </tr>
              <tr>
                <td class="main"><?php echo '<b>' . HEADING_PAYMENT_METHOD . '</b> <a href="' . tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL') . '"><span class="orderEdit">(' . TEXT_EDIT . ')</span></a>'; ?></td>
              </tr>
              <tr>
                <td class="main"><?php echo $order->info['payment_method']; ?></td>
              </tr>
            </table></td>
            <td width="70%" valign="top" align="right"><table border="0" cellspacing="0" cellpadding="2">
<?php
  if (MODULE_ORDER_TOTAL_INSTALLED) {
    $order_total_modules->process();
    echo $order_total_modules->output();
  }
?>
            </table></td>
          </tr>
        </table></td>
      </tr>
<?php
  if (is_array($payment_modules->modules)) {
    if ($confirmation = $payment_modules->confirmation()) {
?>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
      <tr>
        <td class="main"><b><?php echo HEADING_PAYMENT_INFORMATION; ?></b></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
      <tr>
        <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
          <tr class="infoBoxContents">
            <td><table border="0" cellspacing="0" cellpadding="2">
              <tr>
                <td class="main" colspan="4"><?php echo $confirmation['title']; ?></td>
              </tr>
<?php
      for ($i=0, $n=sizeof($confirmation['fields']); $i<$n; $i++) {
?>
              <tr>
                <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                <td class="main"><?php echo $confirmation['fields'][$i]['title']; ?></td>
                <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                <td class="main"><?php echo $confirmation['fields'][$i]['field']; ?></td>
              </tr>
<?php
      }
?>
            </table></td>
          </tr>
        </table></td>
      </tr>
<?php
    }
  }
?>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
<?php
  if (tep_not_null($order->info['comments'])) {
?>
      <tr>
        <td class="main"><?php echo '<b>' . HEADING_ORDER_COMMENTS . '</b> <a href="' . tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL') . '"><span class="orderEdit">(' . TEXT_EDIT . ')</span></a>'; ?></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
      <tr>
        <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
          <tr class="infoBoxContents">
            <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
              <tr>
                <td class="main"><?php echo nl2br(tep_output_string_protected($order->info['comments'])) . tep_draw_hidden_field('comments', $order->info['comments']); ?></td>
              </tr>
            </table></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
<?php
  }
?>
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td align="right" class="main">
<?php
  if (isset($$payment->form_action_url)) {
    $form_action_url = $$payment->form_action_url;
  } else {
    $form_action_url = tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL');
  }

  echo tep_draw_form('checkout_confirmation', $form_action_url, 'post');

  if (is_array($payment_modules->modules)) {
    echo $payment_modules->process_button();
  }

  echo tep_image_submit('button_confirm_order.gif', IMAGE_BUTTON_CONFIRM_ORDER) . '</form>' . "\n";
?>
            </td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td width="25%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
              <tr>
                <td width="50%" align="right"><?php echo tep_draw_separator('pixel_silver.gif', '1', '5'); ?></td>
                <td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
              </tr>
            </table></td>
            <td width="25%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
            <td width="25%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
              <tr>
                <td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
                <td><?php echo tep_image(DIR_WS_IMAGES . 'checkout_bullet.gif'); ?></td>
                <td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
              </tr>
            </table></td>
            <td width="25%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
              <tr>
                <td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
                <td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '1', '5'); ?></td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td align="center" width="25%" class="checkoutBarFrom"><?php echo '<a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '" class="checkoutBarFrom">' . CHECKOUT_BAR_DELIVERY . '</a>'; ?></td>
            <td align="center" width="25%" class="checkoutBarFrom"><?php echo '<a href="' . tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL') . '" class="checkoutBarFrom">' . CHECKOUT_BAR_PAYMENT . '</a>'; ?></td>
            <td align="center" width="25%" class="checkoutBarCurrent"><?php echo CHECKOUT_BAR_CONFIRMATION; ?></td>
            <td align="center" width="25%" class="checkoutBarTo"><?php echo CHECKOUT_BAR_FINISHED; ?></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
<!-- body_text_eof //-->
    <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- right_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
<!-- right_navigation_eof //-->
    </table></td>
  </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

Re: What the heck am i doing with php and xml???

Posted: Sun Jun 24, 2007 8:12 am
by superdezign
stew_g4 wrote:Basically i have started developing a site and chosen oscommerce to save time and because i have no php knowledge as its due to go live in 2 weeks
[...]
Please note i have now started teaching myself php in the unfortunate event that i ever need to do something like this again
You don't know any PHP, but you're using it to develop an e-commerce website? That hardly seems like a smart decision.


Anyway, you haven't asked a question yet. What is it that you need help with?

Posted: Sun Jun 24, 2007 9:04 am
by stew_g4
Thanks for the reply, Perhaps not the smartest but I can work my way around oscommerce and for the most part if i get stuck i can find the answers within the usual places but this is a bit more bespoke than im used to. This is a very optimistic step to complete :D

The question i have is how do i make the above code for the stockandpricechecker.class.php file work in conjunction with the checkout_confirmation page so that when you click submit it completes all the behind the scenes work to submit the xml data feed?

Posted: Sun Jun 24, 2007 11:02 am
by superdezign
Ehh. That's a lot of code to read, and too many tables. You'll have to be more specific than that. Maybe pull out the snippets you're interested in, then what you want to do with them, and what you've tried so far.

Posted: Sun Jun 24, 2007 11:18 am
by stew_g4
Hi superdezign thanks for replying so fast:

Basically this is the part of code in the checkout_confirmation page where you click "submit order"

Code: Select all

<?php 
  if (isset($$payment->form_action_url)) { 
    $form_action_url = $$payment->form_action_url; 
  } else { 
    $form_action_url = tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL'); 
  } 

  echo tep_draw_form('checkout_confirmation', $form_action_url, 'post'); 

  if (is_array($payment_modules->modules)) { 
    echo $payment_modules->process_button(); 
  } 

  echo tep_image_submit('button_confirm_order.gif', IMAGE_BUTTON_CONFIRM_ORDER) . '</form>' . "\n"; 
?>
Whilst in that process of clicking to submit the order i would like to use the functions available in the stockandpricechecker file such as

Code: Select all

function StockAndPriceChecker() 
{ 
$this->xPath = new XPath(); 
$this->xPath->bDebugXmlParse=$this->debug; 
}
and so far i only know (i think) that i need to place

Code: Select all

require('StockAndPriceChecker.class.php');
into the head of the document then use some code to call the functions to work,

(this is where my understanding is a little rubish for want of a better expression)

Thanks anyway for your help it saves me from smacking myself over the head with a large bar lol.

Posted: Sun Jun 24, 2007 11:32 am
by superdezign
That doesn't sound like something that the developers of the product shouldn't have some sort of documentation on if it's already a part of the system. Have you checked their docs?

Posted: Sun Jun 24, 2007 1:00 pm
by stew_g4
I have just checked and there is nothing specific, but i have now emailed for extra support, just hope they can give it.

This is where my noobie shows but ill ask anyway.

When you "require" a page (stockand pricechecker) in the code of your existing page (checkout) are all of the "functions" supposed to complete automatically or do i have to have to add some code in the exisitng page to make these functions work?

Posted: Sun Jun 24, 2007 1:39 pm
by superdezign
If the included page already performs actions, then yes. If it's just a class or library of functions, then no.

Posted: Sun Jun 24, 2007 2:00 pm
by stew_g4
Wow its never simple is it:

So in my example the file extension is class.php so will it ignore any actions within it unless i specifically ask for them to be completed?

If so how do i call on the

Code: Select all

function StockAndPriceChecker() 
{ 
$this->xPath = new XPath(); 
$this->xPath->bDebugXmlParse=$this->debug; 
}
part of the code to action?


I have prepared the large bar just in case lol

Posted: Sun Jun 24, 2007 3:04 pm
by superdezign
stew_g4 wrote:I have prepared the large bar just in case lol
Then keep it out. You'll need it.


That code that you posted looks like a PHP4 class constructor. Calling on the function would do nothing, but making an object out of that class constructor will allow you to use the functions in the class.

Code: Select all

$pObject = new StockAndPriceChecker();

Posted: Sun Jun 24, 2007 4:27 pm
by stew_g4
Then keep it out. You'll need it.
You are so right.

Im guessing but if i put the

Code: Select all

$pObject = new StockAndPriceChecker();
part of the code within the clicking part of the order confirmation like so it will work???

Code: Select all

<?php 
  if (isset($$payment->form_action_url)) { 
    $form_action_url = $$payment->form_action_url; 
  } else { 
    $form_action_url = tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL'); 
  } 
$pObject = new StockAndPriceChecker()

  echo tep_draw_form('checkout_confirmation', $form_action_url, 'post'); 

  if (is_array($payment_modules->modules)) { 
    echo $payment_modules->process_button(); 
  } 

  echo tep_image_submit('button_confirm_order.gif', IMAGE_BUTTON_CONFIRM_ORDER) . '</form>' . "\n"; 
?>
Im willing to bet im overdue that hit with the bar,lol

Posted: Sun Jun 24, 2007 5:07 pm
by superdezign
An object is useless if you it doesn't do anything. That's like havin an employee that stand at the water cooler. Not even drinking either, just standing there.

Is it safe to assume that you are no familiar with object-oriented programming?

Posted: Sun Jun 24, 2007 5:23 pm
by stew_g4
safe as houses,

I feel like i cant use the water dispenser lol

normally pretty quick to learn though, but there doesnt seem to be anywhere where i can find this info on forums etc.

i know this is asking a lot but i have enclosed the documentation due to me urinating in the wind:
Document Notes

1. This does not provide specifications of the schema used, DTDs are supplied in the documentation for the appropriate message.

2. While the current documentation details all the message types, some trading partners will not require all services.

3. This specification is unique to Supplier. Thus, this is the definitive guide to using Supplier's XML services.

4. The XML services are only available to current Supplier customers.
Contacts

If you require any further information on this document or XML trading with Supplier, please contact edi.admin@supplier.com

To request use of XML services please contact your Sales Representative with the information requested on page 4.

System Overview

Using XML messages you can submit your orders either as you take them, say on your web site, or batch them up and submit them later. The best way is to submit your order as soon as possible as this allocates stock and agrees the price.

From your web site you can check stock, price and availability in real time from your checkout page using an ORDVAL message. This also returns delivery charges and checks if fill or kill options can be met. The older QUERY message only supplies stock levels.

When you submit the XML order Supplier will validate it and immediately pass back a GENRSP message which validates the XML and checks stock availability and prices.

Orders “accepted” at this stage are normally successfully processed into our ERP System but changes may occur as stock can be taken by other orders or prices could changes before the order is processed.

The order is then processed onto Supplier’s system.

Messages for the customer relating to order acceptance/rejection and subsequent progress through the delivery cycle are generated automatically once an hour and are placed on our server ready to be collected using the AVMESS message format.

If your web site allows a cooling off period before you take payment, typically 30 minutes, you can submit orders that will not be despatched until you release them. During this period you can cancel order lines or the entire order. Then once this period has expired and you have obtained transaction confirmation of credit card payment you release the order for picking and despatch. You can also use this process if high value orders must be internally approved.

At regular intervals you can request any available messages, this returns a list of messages held on our server. Using this list you can read each message and process them according to your business needs. When you have finished with each message you delete them from our server.

As the order progresses through stock allocation, picking, despatch confirmation etc additional messages are generated by Supplier and placed on our server ready for you to collect. To get a list of these messages you send in an AVMESS request. You then retrieve each message listed and once you have updated your system delete the message from ours. Each message will remain on our server until you send through a message to delete it.

After an order has been completed you may query for specific PODs (proof of deliveries) using the Supplier order number.

Application Process

Contact your Account Manager at Supplier. They will decide if Supplier will trade electronically with you.

If you only wish to check Stock and Prices then providing the Account Manger agrees you only need to provide the IP address from which your queries will be sent.

Whereas for XML ordering you should email your Account Manager with the following information (sales@supplier.com quoting your customer no and marked Attn : Account Manager if you do not know who they are.)

Questions Answers
Your account no with Supplier 0000
The date you wish to commence testing.
The IP on the Internet address from which you will submit your TEST orders. To find this, browse to http://www.supplier.com/myip.php on the server that will be submitting the orders.
The email address of the person who will deal with any technical problems.
The email address of the purchaser who supervises your account with Supplier. They will be informed of all orders where an order has been rejected for any reason. This is in addition to the address you can provide as part of the order submission.
Do you run a cooling off period on your web site (i.e. allow your customers to cancel items on the order for say 1hr after the order is placed)? No
Do you wish Supplier to contact you before rejecting orders (for example; if you order a non-existent part)? No
Do you wish Supplier update your order lines with the correct costs? No
Next Day Delivery Charge
Pre 9
Pre 10
Pre 12
Saturday Delivery
Saturday Pre 9
Saturday Pre 10
Saturday Pre 12

Supplier will then supply you with the following credentials and other information that you will require to send XML messages, schedule message collection and subsequent processing: -

Trading partner ID (Customer No)
A password
Trading name
Postcode of your invoicing address
Time when your AVMESS message is updated with the messages generated in the last hour.

To allow your developers to access all the documentation and some free code that will assist in understanding how our XML ordering system works and includes free code that will reduce the time required to integrate our data onto your systems we have a Developer’s Corner at

http://www.supplier.com/feeds/myfeed/dc_xml.php


You will need to provide your developers with your Supplier Account No and the postcode of your invoicing address so they can register and log on to http://www.supplier.com.

From this area your developer can also request and configure the data feeds that you will require to populate your web site. Explanations of how you can obtain images for your web site and some free code can also be obtained using the above link. There is also an XML validation tool to assist in the development of your ORDERS XML message.

Testing

• When you have completed your development you can submit test orders and monitor the responses. For each order submitted a GENRSP is returned but the order is not taken into the system and no further messages are generated.

• Where there is a problem debug emails are sent to the technical contact specified in the message. These contain the xml received, if you sent over well-formed messages containing line breaks it is much easier for you to debug the problem.

o If you wish to carry further testing to get ORDRESP messages and process AVMESS messages, but do not wish the goods to be sent out, then this can be accomplished.

o Talk to your Account Manager and let them know you wish to do this. They will contact edi.administration@supplier.com to request this service who will reply directly to you when you can start this phase of testing. Please do not submit any orders until you have received this email.

o Each order must have a status of LIVE, forcehold set to TRUE and a delivery address of

K and N,
Gate No 3,
Saltwells Road,
Dudley
DY2 0BY

o You can then retrieve ORDRSP messages through the AVMESS messages that contain information on your orders. AVMESS information can be displayed by posting URLs, as explained later in this document, in a web browser.

o Each day, by 15:00 contact your Account Manager and tell them of any test orders so they can be deleted.

o Once you are happy with this stage of testing you can then let real orders through by setting the delivery address to the customer’s address and omitting the forcehold element.

• Otherwise when you are satisfied with your testing, email edi.administration@supplier.com who will active your account and will let you know when it is correctly configured. We will also update our system with the Purchasing contact you have already given us. Then all orders submitted with a status of LIVE will be processed in to our system automatically.

• If you will be submitting your live orders from a different server email edi.administration@supplier.com with this IP address as our firewall will block “unknown” addresses.

• If any of the email contact addresses need to change email the new ones to edi.administration@supplier.com.

• If you want, we can monitor with you the progress of your first few orders, contact us at edi.admin@supplier.com, with a subject “Ready to Place XML Orders”. Remember orders should now be submitted with a message status of LIVE.

The Order Submission Process

The following sections describe how orders are placed and subsequently tracked and processed. A table showing messages you send and the expected response, in a tabular form, is included at the end of this document.

Querying Stock and Price information

The usual sequence of events follows:

Your customer goes to the checkout page and your web site queries Supplier to ensure stock and prices are correct and to get any delivery charges.

http://xmledi.supplier.com:8090/xmledi. ... AR&debug=0

http://xmledi.supplier.com:8090/xmledi. ... AR&debug=1

http://xmledi.supplier.com:8090/xmledi. ... AR&debug=1

These queries should be submitted prior to submitting an order to verify the latest situation. Even so, please note that it is possible that prices and stock levels can change between receiving the information and an order being submitted and order being processed into our system. Order responses must be checked and processed according to your business model.

The QUERY message is still available and can be used if required. This is recommended for querying single product stock and price when an accessory list is required.

Using the credentials provided by Supplier in the following command, stock and price information and all accessories for the part number supplied is returned

http://xmledi.supplier.com:8090/xmledi. ... pppppppppp

Using the QUERY message to populate your web site is expressly forbidden and will result in this message being turned off for you.
Order submission
Once you have processed your customer’s credit card details and funds have been obtained, you can place the order by sending the xml stream to….

Once you have processed your customer’s credit card details and funds have been obtained, you can place the order.

Trading partners can use different methods to submit XML orders. Sample methods are shown below:-

Via a web page:-

Note: Its is assumed that a textarea is used to hold the XML for the order.

<form method="POST" action="http://xmledi.supplier.com:8090/xmledi.php">
<textarea name="XMLDATA" rows="35" cols="100" </textarea>
<input type="submit" value="Click here to submit the Order" >
</form>

Using curl:-

• Set the URL to http://xmledi.supplier.com:8090/xmledi.php?
• Set the method to POST
• Send POST data as an array e.g. array(‘XMLDATA’ => $str)

The order is validated and the generic response (GENRSP) is passed back. The contents of the element in the ORDER message should only contain alphanumeric characters (A-Z, a-z, 0-9 , normal punctuation).

The ORDER message should not contain < > & ^ ; : | + - / \ within the TAG

Where orders are rejected at this stage no further messages are generated. Order rejection can be because of, but not limited to, format errors, fill or kill, or price discrepancies. Please read the GENRSP documentation for more information on possible acceptance and rejection reasons. You should cater for the fact that new error status values may be added in future.

GENRSP messages for rejected orders contain a message section that can be formatted and displayed to your customers.

Once the order has passed this validation, it is then placed on an import queue ready for further processing

It is possible to put an agreement in place where rejected orders are manually reviewed by your Account Manager at Supplier, who can correct erroneous data and resubmit the order on your behalf.

Once the order is processed by our backend system an ORDRSP message is generated, and you have to request an AVMESS to get information that enables you to access this message.

By default the line number passed back in various messages will now retain the line numbers passed in. Should you wish us to allocate line number it can be arranged. If delivery charges are added by Supplier it will be line 900 or 9000.
Querying for available messages

Every hour the AVMESS message is updated and it is best if you schedule a request to get this message at the time agreed when we sent over your credentials, as it will then be current.

Due the possible delay between submission and ORDRSPs being available in the AVMESS accepted orders can be viewed on the web site before they appear in the AVMESS.

If for some reason your account is in a state that prevents orders being accepted and dispatched, e.g. on credit hold or stop, then the order is processed onto our system but an ORDERRSP is not generated until the account is in good order.

Using the credentials provided by Supplier in the following command, the next 100 available messages are returned.

http://xmledi.supplier.com:8090/xmledi. ... ss=xxxxxxx

Then using each url in the message, append &action-view and post it back as a get request e.g.

<uri>http://xmledi.supplier.com:8090/xmledi. ... xxxxx</uri>

becomes

http://xmledi.supplier.com:8090/xmledi. ... ction=view

In this case you would get back information on a despatch advice and you can update your system with the results.

Once you have processed a message and are entirely finished with it you should delete it otherwise it will appear in the next list returned by an AVMESS request, once again an example is shown below.

http://xmledi.supplier.com:8090/xmledi. ... ion=delete

If you do not delete messages eventually you will not be able to retrieve information on your most recent orders.

Messages are presented by AVMESS grouped by message type.

Information on orders placed by your company with Supplier by other methods, e.g. via the web or over the phone will also generate messages and these must be processed and deleted by you.

You should request AVMESS messages until an empty list or one containing less than 100 is returned.

ORDRSP messages must be read to check the status of the submitted order (your account may be on hold, there may be a problem with the stock etc).

Once orders are on our system should you need to amend it for any reason you should to contact your Account Manager.

You should cater for the fact that new status values may be added in future to the ORDRSP message.

Releasing Orders

If you submitted an order as “do not despatch until released” then you must either delete the order or release it once you are ready for the order to be shipped e.g. you have received cleared funds from your customer.

When you process the ORDRSP for each order, you get the Supplier Order number, which is used in the RELORD message to release the order.

http://xmledi.supplier.com:8090/xmledi. ... f=Syyyyyyy

This message generates a RELRSP, which shows the results of validating the message. The actual result of the message being actioned will appear as a RELADV that can be accessed once it appears in the AVMESS message.

Cancelling Lines or Entire Orders

If you submitted an order as “do not despatch until released” then you can cancel order lines or even the entire order prior to releasing the order.

The Supplier Order no is used along with the appropriate line number(s) to cancel order lines. By specifying every line in the order the entire order can be cancelled. You could also delete some lines and then send through a RELORD for the remainder.

http://xmledi.supplier.com:8090/xmledi. ... &lineno=30

This will generate a DELRSP, which shows the results of validating the message. The result of the message being actioned will appear as a DELADV that can be accessed once it appears in the AVMESS message.

The example below shows how to delete an entire 3-line order

http://xmledi.supplier.com:8090/xmledi. ... o=10,20,30

Delivery charge lines will be automatically adjusted and the revised charge contained in the response can then be used to credit your customer.

Querying for POD messages

When an order has been completed and dispatched you can query for a POD (proof of delivery):

Using the credentials provided by Supplier in the following command, proof of delivery details for the order number supplied would be returned

http://xmledi.supplier.com:8090/podrequ ... f=xxxxxxxx

Where “midw_ref” is the Supplier order reference of the order you require a POD.
GET parameters

Before you can make any request from, or submissions to the XML interface, you will require the following details, as they must be supplied for all GET requests. Supplier will supply these details when we have agreed to trade using XML.

Parameter Applies To Meaning Format
Tpid All The trading partner ID. This is used to link the trading partner to our details stored in our back end system. Fixed length 10 digit String. E.g. “0000123456”.
Pass All Mixed case password. The system is case sensitive, so PaSSword is not the same as Password. Arbitrary length String. E.g. “781PassWoRd”.
Trading Name ORDERS You must use this case sensitive name when submitting orders. Arbitrary length String. E.g. “The Trading Company Ltd”

Control parameters

The following list contains all the possible parameters that can be returned after requesting XML messages via the GET protocol. Most XML messages only use a subset of these. For instance, there's little point specifying a product part number when requesting an order response message!

Parameter Applies To Meaning Format
Accessorylist QUERY If given the value FALSE, then the accessory list provided in a stock/price query will be suppressed. Boolean, can be TRUE or FALSE. If not specified, then defaults to TRUE.
uid ORDRSP ORDSTAT DESADV The unique identifier. This is used to pull down specific despatch advice, order response and order status messages. Arbitrary length String. E.g. “0000123456”.
manupn QUERY The manufacturer part number (also known as the OEM number). Arbitrary length String, of max 40 characters.
midwpn QUERY The Supplier part number. This should be used whenever possible as the manufacturer part number alone might relate to more than one product. If both the manupn and midwpn are specified, then the midwpn is used. Arbitrary length String of max 15 characters.
action ORDRSP ORDSTAT DESADV DELRSP RELRSP The action to take with the message. This is used to view or delete waiting messages from our system. These would usually be used sequentially on the same message uid (client would first view the message, and then delete it). Enumerated value, can be one of “VIEW” or “DELETE”. No default value so must be specified.
midw_ref PODRSP DELORD RELORD The Supplier sales order reference number. Fixed length string of 8 digits currently starting with an “S”
MidwpnQty - Supplier part number and quantity required for that product. More than on product/quantity can be requested at one time; in this case each Supplier part number and associated quantity couple should be separated by a comma e.g. IXUS50,3 Comma separated string of Supplier part numbers and quantities
Postcode - The delivery address postcode. Must be supplied in the format “IP22 4YT” remembering that the space should be encoded as “%20”
countrycode - ISO 3166-1-alpha-2 country code Appendix C in ORDVAL documentation
carrier - Supplier code for courier Appendix B in ORDVAL documentation
deliveryType - Supplier code for courier service level Appendix B in ORDVAL documentation
debug - Switch for extra information on the delivery charge, information not always available (1=show debug, 0=hide debug)
lineno DELORD List of order lines to be deleted. Comma separated list

XML Interface

System details

The Supplier XML interface is a web-based front-end to our commercial systems. It communicates with our back end systems in an asynchronous manner, which means that order imports and responses are also asynchronous.

Requesting and submitting information

Although you can request any of the message types available at any time (with the exception of a GENRSP message), in practice you would only request an AVMESS (available messages), ORDVAL, QUERY (stock and price query) or make an ORDER submission at the start of a session. The AVMESS will list the messages that are available for the trading partner to request. This helps reduce bandwidth usage, and decreases the server load.

Request format

The interface accepts GET requests and POSTed data. Most Trading Partners use curl to send and read the response. A simple HTTP form post will work but display the result (XML) in the resultant window. Our interface does not accept SOAP or RPC/XML input, or any other form of communication. Any attempt to use another protocol will result in a GENRSP error response. The type of request used for the various messages is detailed below:

Message Type Description Protocol
AVMESS Available messages GET
BACKORD Back Order Response GET
DESADV Despatch advice GET
DELADV Order Line Deletion advice GET
DELORD Order Line Deletion submission GET
DELRSP Order Line Deletion response GET
GENRSP Generic response N/A (cannot request this message type)
ORDERS Order submission POST
ORDRSP Order responses GET
ORDSTAT Order status GET
ORDVAL Stock, price and delivery charge info. GET
PODRSP Proof of Delivery response GET
QUERY Stock and price info. GET
RELADV Order Release advice GET
RELORD Order Release submission GET
RELRSP Order Release response GET

Content types

The interface will only return XML data to the client. The content type will be set to the following, depending upon the capability of the client connecting to the server (assuming the client supplies this information in the HTTP_ACCEPT header during a session):

Client type Content type returned
application/xhtml+xml Application/xhtml+xml
(Other, e.g. Internet Explorer browser) text/html

The interface itself ignores the content type submitted by the client, and always assumes application/xhtml+xml (plain text with XML content).

For POSTed data, the content should be contained in a single data item, containing only XML data.

For GET requests, the normal conventions apply (& delimiter between = separated key and value pairs).

Messages And Responses

To try and show what happens in a simple way please refer to the following table.

Every message is initiated by a message being sent by you. The first column shows the message we would expect you to send and the second column the response you should expect.

You Send Reply Comments
You place a normal order.

ORDVAL ORDVAL Validate order before placing
ORDER GENRSP Normal order placed

At the time specified to pick up AVMESS

AVMESS AVMESS Response contains all the messages to process. You should access each message using the view action and process into your system
ORDRSP ORDRSP View action, the response contains order information which you use to update your system.
ORDRSP ORDRSP Delete action, message is successfully deleted and will not appear in the AVMESS list again.

When the order is confirmed at our warehouse

AVMESS AVMESS Response contains all the messages to process. You should access each message using the view action and process into your system
DESADV DESADV View action, the response contains despatch information, which you use to update your system.
DESADV DESADV Delete action, message is successfully deleted and will not appear in the AVMESS list again.
ORDSTAT ORDSTAT
ORDSTAT ORDSTAT Delete action

Sequence if you place an order and some items go on back order.

ORDVAL ORDVAL
ORDER GENRSP
AVMESS AVMESS
ORDRSP ORDRSP Shows products on back order
ORDRSP ORDRSP Delete action
BACKORD BACKORD Provides information on items placed on back order, including expected delivery schedule to our warehouse.
BACKORD BACKORD Delete action

When the back order item comes into the warehouse and is allocated to your order.

AVMESS AVMESS
ORDSTAT ORDSTAT
ORDSTAT ORDSTAT Delete action
DESADV DESADV
DESADV DESADV Delete action

You place an order with FORCEHOLD = TRUE.

ORDVAL ORDVAL Validate order before placing
ORDER GENRSP Normal order placed

At the time specified to pick up AVMESS

AVMESS AVMESS Response contains all the messages to process. You should access each message using the view action and process into your system
ORDRSP ORDRSP View action, the response contains order information which you use to update your system.
ORDRSP ORDRSP Delete action

You delete a line

DELORD DELRSP

AVMESS AVMESS
ORDSTAT ORDSTAT Shows result of the line deletion.
ORDSTAT ORDSTAT Delete action

You want to release the order to be picked.

RELORD RELRSP

If picking is not operational at the time you will only get an ORDSTAT when you next collect the AVMESS.

AVMESS AVMESS
ORDSTAT ORDSTAT
ORDSTAT ORDSTAT Delete action

If picking is operational you should get an ORDSTAT and DELADV in the next AVMESS but the DELADV could be in the subsequent AVMESS.

AVMESS AVMESS
ORDSTAT ORDSTAT
ORDSTAT ORDSTAT Delete action
DESADV DESADV
DESADV DESADV Delete action

Posted: Sun Jun 24, 2007 5:36 pm
by superdezign
No way I'm reading it. That's up to you to do. :P

I'd suggest you look in the PHP manual if you want a quick (and I mean quick) overview of the usage of classes. Just search for "object oriented programming."

Posted: Mon Jun 25, 2007 7:35 am
by revocause
...wow that's funny : )