/** * Display order tracking info * * @param array $params (order, cart) * @return string template rendering */ public function hookOrderDetailDisplayed($params) { global $smarty; $kiala_order = KialaOrder::getByOrder($params['order']->id); if (!Validate::isLoadedObject($kiala_order)) { return false; } $address = new Address($params['order']->id_address_delivery); $kiala_country = KialaCountry::getByIdCountry($address->id_country); $search_by = Configuration::get('KIALA_SEARCH_BY'); if ($search_by == 'customer') { $id = $kiala_order->id_customer; } elseif ($search_by == 'order') { $id = Configuration::get('KIALA_NUMBER_PREFIX') . $kiala_order->id; } else { return false; } $kiala_request = new KialaRequest(); $url = $kiala_request->getTrackingRequest($address, $kiala_country, $params['order']->id_lang, $id, $search_by); $smarty->assign('url_tracking', Tools::safeOutput($url)); return $this->display(__FILE__, 'orderDetail.tpl'); }
/** * Export a batch of records * * @param array $kiala_orders */ public function exportBatch($kiala_orders) { if (!$kiala_orders || !is_array($kiala_orders)) { die("Wrong argument"); } $this->openExportFile($kiala_country->dspid); $success = true; foreach ($kiala_orders as $kiala_order) { // DEACTIVATED BY REQUEST FROM KIALA // If pickup country and delivery country are different, we need to write 2 lines with different DSPID /*if ($kiala_order->id_country_pickup != $kiala_order->id_country_delivery) { $kiala_country_pickup = KialaCountry::getByIdCountry($kiala_order->id_country_pickup); $fields = $this->initRecordData($kiala_order, $kiala_country_pickup->dspid); if (!$success = $this->writeRecord($fields)) break; }*/ $kiala_country = KialaCountry::getByIdCountry($kiala_order->id_country_delivery); $fields = $this->initRecordData($kiala_order, $kiala_country->dspid); if (!($success = $this->writeRecord($fields))) { break; } $kiala_order->exported = 1; $kiala_order->save(); Configuration::updateValue('KIALA_LAST_EXPORT_FILE', basename($this->path)); } $this->closeExportFile(); return $success; }
/** * Build the locate&select point list url * * @param int $max_result * @param string $point_short_id */ public function getPointRequest($max_result, $point_short_id = null) { global $cart; $address = new Address($cart->id_address_delivery); $kiala_country = KialaCountry::getByIdCountry($address->id_country); if (!Validate::isLoadedObject($kiala_country) || !$kiala_country->isActive()) { return false; } $params = array('dspid' => $kiala_country->dspid, 'country' => Country::getIsoById($address->id_country), 'language' => Language::getIsoById($cart->id_lang), 'preparation_delay' => $kiala_country->preparation_delay, 'street' => $address->address1, 'zip' => $address->postcode, 'city' => $address->city, 'sort-method' => 'ACTIVE_ONLY' . ($point_short_id ? ' ' . $point_short_id : ''), 'max-result' => (int) $max_result); return $this->list_url . $this->prepareParams($params); }