Exemple #1
0
 /**
  * @param bool $root
  * @return string
  */
 public function pack($root = false)
 {
     $writer = new XMLWriter();
     $writer->openMemory();
     if ($root) {
         $writer->startDocument();
     }
     $writer->startElement('order');
     if (isset($this->printCustomerInvoice)) {
         $writer->writeElement('print_customer_invoice', $this->printCustomerInvoice);
     }
     if (isset($this->tsCreated)) {
         $writer->writeElement('ts_created', $this->tsCreated->format(DateTime::RFC3339));
     }
     if (isset($this->deliveryDate)) {
         $writer->writeElement('delivery_date', $this->deliveryDate->format(DateTime::RFC3339));
     }
     if (isset($this->priority)) {
         $writer->writeElement('priority', $this->priority);
     }
     if (isset($this->shippingFee)) {
         $writer->writeElement('shipping_fee', $this->shippingFee);
     }
     if (isset($this->productDiscounts)) {
         $writer->writeElement('product_discounts', $this->productDiscounts);
     }
     if (isset($this->shippingDiscounts)) {
         $writer->writeElement('shipping_discounts', $this->shippingDiscounts);
     }
     if (isset($this->vendorId)) {
         $writer->writeElement('vendor_id', $this->vendorId);
     }
     if (isset($this->contact)) {
         $writer->writeRaw($this->contact->pack());
     }
     if (isset($this->shipType)) {
         $writer->writeRaw($this->shipType->pack());
     }
     if (isset($this->requester)) {
         $writer->writeRaw($this->requester->pack());
     }
     if (isset($this->shipAddress)) {
         $writer->writeRaw($this->shipAddress->pack());
     }
     if (isset($this->shipReturnAddress)) {
         $writer->writeRaw($this->shipReturnAddress->pack());
     }
     InkRouter_Utils_OrderProcessor::transform($this);
     $writer->startElement('order_items');
     foreach ($this->orderItems as $orderItem) {
         $writer->writeRaw($orderItem->pack());
     }
     $writer->endElement();
     $writer->endElement();
     return $writer->outputMemory();
 }