示例#1
0
 public function getDeliveryDateAll($vendor, $address, $weight, $value, $shipDate)
 {
     $reqKey = implode('-', array($vendor->getId(), $address->getId(), $weight, $value, $shipDate));
     if (isset($this->_deliveryDatesCache[$reqKey])) {
         return $this->_deliveryDatesCache[$reqKey];
     }
     $this->setVendor($vendor);
     $currencyCode = $address->getQuote()->getBaseCurrencyCode();
     $request = new Varien_Simplexml_Element('<TimeInTransitRequest/>');
     $request->setNode('Request/TransactionReference/CustomerContext', '1');
     $request->setNode('Request/TransactionReference/XpciVersion', '1.0');
     $request->setNode('Request/RequestAction', 'TimeInTransit');
     $request->setNode('TransitFrom/AddressArtifactFormat/PoliticalDivision1', $vendor->getRegionCode());
     $request->setNode('TransitFrom/AddressArtifactFormat/PoliticalDivision2', $vendor->getCity());
     $request->setNode('TransitFrom/AddressArtifactFormat/PostcodePrimaryLow', $vendor->getZip());
     $request->setNode('TransitFrom/AddressArtifactFormat/CountryCode', $vendor->getCountryId());
     $request->setNode('TransitTo/AddressArtifactFormat/PoliticalDivision1', $address->getRegionCode());
     $request->setNode('TransitTo/AddressArtifactFormat/PoliticalDivision2', $address->getCity());
     $request->setNode('TransitTo/AddressArtifactFormat/PostcodePrimaryLow', $address->getPostcode());
     $request->setNode('TransitTo/AddressArtifactFormat/CountryCode', $address->getCountryId());
     $request->setNode('PickupDate', date('Ymd', strtotime($shipDate)));
     $request->setNode('InvoiceLineTotal/CurrencyCode', $currencyCode);
     $request->setNode('InvoiceLineTotal/MonetaryValue', round($value, 2));
     $request->setNode('ShipmentWeight/UnitOfMeasurement/Code', $address->getQuote()->getStore()->getConfig('carriers/ups/unit_of_measure'));
     $request->setNode('ShipmentWeight/Weight', $weight);
     $xmlRequest = '<?xml version="1.0"?>' . $request->asNiceXml();
     $this->setXMLAccessRequest();
     $xmlResponse = $this->_callShippingXml('TimeInTransit', $xmlRequest);
     $response = new Varien_Simplexml_Element($xmlResponse);
     $result = array();
     try {
         $this->_validateResponse($response, false);
         $arr = $response->xpath("//TimeInTransitResponse/TransitResponse/ServiceSummary");
         foreach ($arr as $a) {
             if (isset($a->Service->Code) && isset($a->EstimatedArrival->Date)) {
                 $result[(string) $a->Service->Code] = (string) $a->EstimatedArrival->Date;
             }
         }
     } catch (Exception $e) {
         $result = array();
     }
     $this->_deliveryDatesCache[$reqKey] = $result;
     return $result;
 }
示例#2
0
 /**
  * Create node by $path and set its value.
  *
  * @param string $path separated by slashes
  * @param string $value
  * @param boolean $overwrite
  * @return Varien_Simplexml_Config
  */
 public function setNode($path, $value, $overwrite = true)
 {
     $xml = $this->_xml->setNode($path, $value, $overwrite);
     return $this;
 }
示例#3
0
 public function voidLabel($track)
 {
     if (!Mage::getStoreConfig('udropship/vendor/void_labels')) {
         return $this;
     }
     $request = new Varien_Simplexml_Element('<VoidShipmentRequest/>');
     $request->setNode('Request/TransactionReference/CustomerContext', $orderId);
     $request->setNode('Request/TransactionReference/XpciVersion', '1.0');
     $request->setNode('Request/RequestAction', '1');
     $request->setNode('Request/RequestOption', '1');
     $request->setNode('ShipmentIdentificationNumber', $track->getNumber());
     $xmlRequest = '<?xml version="1.0"?>' . $request->asNiceXml();
     $this->setXMLAccessRequest();
     $xmlResponse = $this->_callShippingXml('Void', $xmlRequest);
     $response = new Varien_Simplexml_Element($xmlResponse);
     $this->_validateResponse($response, false);
     return $this;
 }