/** * @param array $address * @param string $lang * * @return bool|mixed * * @author Panagiotis Vagenas <*****@*****.**> * @since ${VERSION} */ public function validateAddress(array $address, $lang = 'GR') { $customerOptions = ACSWSOptions::getInstance()->getCustomerOptions(); unset($customerOptions['customerId']); $loc = TransLit::getInstance()->translate($this->addressArrayToLocation($address)); $params = array('lang' => $lang, 'address' => $loc); $call = $this->cache->hasCall(new ACSWSCall(__METHOD__, $params, null)); if ($call) { return $call->result; } $soap = new ACSSoapAddressService($customerOptions); $soap->setParams($params); $res = $soap->validateAddress(); $this->cache->storeCall(new ACSWSCall(__METHOD__, $params, $res)); return $res; }
/** * @return string * * @author Panagiotis Vagenas <*****@*****.**> * @since ${VERSION} */ public function hookDisplayCarrierList($params) { $cart = $params['cart']; $dp = $this->packageShippingCost($cart, true); if (!$dp) { return ''; } $addressObj =& $params['address']; $soap = \acsws\classes\ACSWS::getInstance(); $storeInfo = $soap->validateAddress(array('street' => $addressObj->address1 . ($addressObj->address2 ? $addressObj->address2 : ''), 'number' => null, 'pc' => $addressObj->postcode, 'area' => $addressObj->city)); if (!isset($storeInfo[0])) { return ''; } // var_dump($storeInfo);die; return ' <script type="text/javascript"> var storeInfo = ' . json_encode($this->object_to_array($storeInfo[0])) . '; var dpCarrierId = ' . Configuration::get('ACS_DP') . '; var carrierId = ' . Configuration::get('ACS_CLDE') . '; var googleQ = "' . \XDaRk\TransLit::getInstance()->translateElEn($storeInfo[0]->station_address . ', ' . $storeInfo[0]->station_description) . '"; console.log(storeInfo); ' . file_get_contents(dirname(__FILE__) . '/assets/dp.js') . ' </script> '; }