/**
  * {@inheritDoc}
  * 
  * Format:
  * 
  * <Product>                                       (required)
  *      <Code>p1</Code>                             (required)
  *      <Quantity>1</Quantity>                      (required)
  *      <DateInStock>                               (optional)
  *          <Day>01</Day>                                   (required)
  *          <Month>01</Month>                               (required)
  *          <Year>1970</Year>                               (required)
  *          <Hour>00</Hour>                                 (optional)
  *          <Minute>01</Minute>                             (optional)
  *       </DateInStock>
  * </Product>
  */
 public function toXml($version = Version::CURRENT, array $options = array())
 {
     $xmlObject = new SimpleXMLElement('<Product />');
     $xmlObject->addChild('Code', $this->getCode());
     $xmlObject->addChild('Quantity', $this->getQuantity());
     if ($this->getDateInStock() instanceof \DateTime) {
         $dateInStockXml = $xmlObject->addChild('DateInStock');
         XmlHelper::dateTimeToXml($dateInStockXml, $this->getDateInStock());
     }
     return $xmlObject;
 }
 /**
  * {@inheritDoc}
  * 
  * Format:
  * 
  * <OrderShipment_SetStatus code="SHIPMENT_CODE">
  *       <MarkAsShipped>1</MarkAsShipped>                (Optional)
  *       <TrackingNumber>0123456</TrackingNumber>        (Optional)
  *       <TrackingType>FedEx</TrackingType>              (Optional)
  *       <ShipDate>                                      (Optional)
  *           <Day>01</Day>                                   (required)
  *           <Month>01</Month>                               (required)
  *           <Year>1970</Year>                               (required)
  *           <Minute>30</Minute>                             (optional)
  *           <Hour>12</Hour>                                 (optional)
  *       </ShipDate>
  *   </OrderShipment_SetStatus>
  *
  */
 public function toXml($version = Version::CURRENT, array $options = array())
 {
     $xmlObject = new SimpleXMLElement('<OrderShipment_SetStatus />');
     $xmlObject->addAttribute('code', $this->getCode());
     if ($this->getMarkAsShipped()) {
         $xmlObject->addChild('MarkAsShipped', $this->getMarkAsShipped());
     }
     if ($this->getTrackingNumber()) {
         $xmlObject->addChild('TrackingNumber', $this->getTrackingNumber());
     }
     if ($this->getTrackingType()) {
         $xmlObject->addChild('TrackingType', $this->getTrackingType());
     }
     if ($this->getShipDate() instanceof \DateTime) {
         $shipDateXml = $xmlObject->addChild('ShipDate');
         XmlHelper::dateTimeToXml($shipDateXml, $this->getShipDate());
     }
     return $xmlObject;
 }
示例#3
0
 /**
  * {@inheritDoc}
  *
  * Format:
  * <Order_Update order_id="X">
  *      <CustomerLogin></CustomerLogin>
  *      <ShipFirstName></ShipFirstName>
  *      <ShipLastName></ShipLastName>
  *      <ShipEmail></ShipEmail>
  *      <ShipCompany></ShipCompany>
  *      <ShipPhone></ShipPhone>
  *      <ShipFax></ShipFax>
  *      <ShipAddress1></ShipAddress1>
  *      <ShipAddress2></ShipAddress2>
  *      <ShipCity></ShipCity>
  *      <ShipState></ShipState>
  *      <ShipZip></ShipZip>
  *      <ShipCountry></ShipCountry>
  *      <BillFirstName></BillFirstName>
  *      <BillLastName></BillLastName>
  *      <BillEmail></BillEmail>
  *      <BillCompany></BillCompany>
  *      <BillPhone></BillPhone>
  *      <BillFax></BillFax>
  *      <BillAddress1></BillAddress1>
  *      <BillAddress2></BillAddress2>
  *      <BillCity></BillCity>
  *      <BillState></BillState>
  *      <BillZip></BillZip>
  *      <BillCountry></BillCountry>
  *      <Items>
  *
  *      </Items>
  *       <Charges>
  *
  *      </Charges>
  *      <CalculateCharges>
  *          <ShippingModule></ShippingModule>
  *          <ShippingModuleData></ShippingModuleData>
  *      </CalculateCharges>
  *      <Total></Total>
  *      <OrderDate></OrderDate>
  *      <ChargeList>
  *          <!-- OPTIONAL, IF SET WILL DELETE ALL EXISTING CHARGES AS OF 9.0.0.3
  *      </ChargeList>
  *  </Order_Update>
  *
  */
 public function toXml($version = Version::CURRENT, array $options = array())
 {
     $xmlObject = new SimpleXMLElement('<Order_Update />');
     $xmlObject->addAttribute('order_id', $this->getOrderId());
     if ($this->getCustomerLogin()) {
         $xmlObject->addChild('CustomerLogin', $this->getCustomerLogin());
     }
     if ($this->getShipFirstName()) {
         $xmlObject->addChild('ShipFirstName', $this->getShipFirstName());
     }
     if ($this->getShipLastName()) {
         $xmlObject->addChild('ShipLastName', $this->getShipLastName());
     }
     if ($this->getShipEmail()) {
         $xmlObject->addChild('ShipEmail', $this->getShipEmail());
     }
     if ($this->getShipCompany()) {
         $xmlObject->addChild('ShipCompany', $this->getShipCompany());
     }
     if ($this->getShipPhone()) {
         $xmlObject->addChild('ShipPhone', $this->getShipPhone());
     }
     if ($this->getShipFax()) {
         $xmlObject->addChild('ShipFax', $this->getShipFax());
     }
     if ($this->getShipAddress1()) {
         $xmlObject->addChild('ShipAddress1', $this->getShipAddress1());
     }
     if ($this->getShipAddress2()) {
         $xmlObject->addChild('ShipAddress2', $this->getShipAddress2());
     }
     if ($this->getShipCity()) {
         $xmlObject->addChild('ShipCity', $this->getShipCity());
     }
     if ($this->getShipState()) {
         $xmlObject->addChild('ShipState', $this->getShipState());
     }
     if ($this->getShipZip()) {
         $xmlObject->addChild('ShipZip', $this->getShipZip());
     }
     if ($this->getShipCountry()) {
         $xmlObject->addChild('ShipCountry', $this->getShipCountry());
     }
     if ($this->getBillFirstName()) {
         $xmlObject->addChild('BillFirstName', $this->getBillFirstName());
     }
     if ($this->getBillLastName()) {
         $xmlObject->addChild('BillLastName', $this->getBillLastName());
     }
     if ($this->getBillEmail()) {
         $xmlObject->addChild('BillEmail', $this->getBillEmail());
     }
     if ($this->getBillCompany()) {
         $xmlObject->addChild('BillCompany', $this->getBillCompany());
     }
     if ($this->getBillPhone()) {
         $xmlObject->addChild('BillPhone', $this->getBillPhone());
     }
     if ($this->getBillFax()) {
         $xmlObject->addChild('BillFax', $this->getBillFax());
     }
     if ($this->getBillAddress1()) {
         $xmlObject->addChild('BillAddress1', $this->getBillAddress1());
     }
     if ($this->getBillAddress2()) {
         $xmlObject->addChild('BillAddress2', $this->getBillAddress2());
     }
     if ($this->getBillCity()) {
         $xmlObject->addChild('BillCity', $this->getBillCity());
     }
     if ($this->getBillState()) {
         $xmlObject->addChild('BillState', $this->getBillState());
     }
     if ($this->getBillZip()) {
         $xmlObject->addChild('BillZip', $this->getBillZip());
     }
     if ($this->getBillCountry()) {
         $xmlObject->addChild('BillCountry', $this->getBillCountry());
     }
     if (count($this->getItems())) {
         $itemsXml = $xmlObject->addChild('Items');
         foreach ($this->getItems() as $item) {
             XmlHelper::appendToParent($itemsXml, $item->toXml($version, $options));
         }
     }
     if (count($this->getCharges())) {
         $chargesXml = $xmlObject->addChild('Charges');
         foreach ($this->getCharges() as $charge) {
             XmlHelper::appendToParent($chargesXml, $charge->toXml($version, $options));
         }
     }
     if ($this->getOrderDate()) {
         $fragment = $xmlObject->addChild('OrderDate');
         XmlHelper::dateTimeToXml($fragment, $this->getOrderDate());
     }
     return $xmlObject;
 }