Exemple #1
0
 /**
  * @param array $basket
  * @return int
  */
 private function getMaxDeliveryTime($basket)
 {
     // get the SwagTrustedShop config
     $config = $this->tsConfig->getSettings($this->shop->getId());
     $deliveryTime = $config['trustedShopsInStockDeliveryTime'];
     $notInStockDeliveryTime = $config['trustedShopsNotInStockDeliveryTime'];
     // if trustedShopsNotInStockDeliveryTime is defined check if any
     // article is not in stock
     if ($notInStockDeliveryTime > 0) {
         if ($this->isArticleNotInStock($basket)) {
             return $notInStockDeliveryTime;
         }
     }
     // if trustedShopsInStockDeliveryTime is defined return it
     if ($deliveryTime > 0) {
         return $deliveryTime;
     }
     $defaultReturn = 2;
     if (!$basket) {
         return $defaultReturn;
     }
     $shippingTimes = array_column($basket, 'shippingtime');
     if (!$shippingTimes) {
         return $defaultReturn;
     }
     $maxDeliveryTime = (int) max($shippingTimes);
     if (!$maxDeliveryTime) {
         return $defaultReturn;
     }
     return $maxDeliveryTime;
 }
Exemple #2
0
 /**
  * implements and performs the general soap request to Trusted Shops
  *
  * @param string $soapFunction
  * @param array $soapData
  * @param $shopId
  * @internal param $requestURLSuffix
  * @return string or int | soap resonse data
  */
 private function sendSoapRequest($soapFunction, array $soapData = null, $shopId)
 {
     define('SOAP_ERROR', -1);
     $settings = $this->tsConfig->getSettings($shopId);
     $ts_url = $settings['trustedShopsTestSystem'] ? 'protection-qa.trustedshops.com' : 'protection.trustedshops.com';
     //special url for protection request on save order
     $wsdlUrl = 'https://' . $ts_url . '/ts/protectionservices/ApplicationRequestService?wsdl';
     try {
         $client = new \Zend_Soap_Client($wsdlUrl);
         $returnValue = $client->__call($soapFunction, $soapData);
     } catch (\SoapFault $fault) {
         $returnValue = $fault->faultcode . ' ' . $fault->faultstring;
     }
     return $returnValue;
 }