Commit bc365d10c26fe013d05ae020647c113634ef02f4
1 parent
29d4a3f1
changed popular items in pageController itemAction, and added links to addresses
Showing
4 changed files
with
42 additions
and
33 deletions
Show diff stats
src/app/frontend/controllers/MenuController.php
... | ... | @@ -32,10 +32,11 @@ class MenuController extends \controllers\ControllerBase |
32 | 32 | $err = 0; |
33 | 33 | |
34 | 34 | $cities_ = $this->novaposhta->city(); |
35 | - | |
36 | - foreach( $cities_->city as $c ) | |
35 | + | |
36 | + foreach( $cities_->item as $c ) | |
37 | 37 | { |
38 | - $cities[strval($c->id)] = strval($c->nameUkr); | |
38 | + | |
39 | + $cities[strval($c->CityID)] = strval($c->Description); | |
39 | 40 | } |
40 | 41 | |
41 | 42 | if ( !empty( $in_cart ) ) |
... | ... | @@ -318,18 +319,18 @@ class MenuController extends \controllers\ControllerBase |
318 | 319 | $length = strlen($term); |
319 | 320 | $cities_ = $this->novaposhta->city(); |
320 | 321 | |
321 | - foreach( $cities_->city as $c ) | |
322 | + foreach( $cities_->item as $c ) | |
322 | 323 | { |
323 | - $cities[strval($c->id)] = strval($c->nameUkr); | |
324 | + $cities[strval($c->CityID)] = strval($c->Description); | |
324 | 325 | |
325 | - if( mb_strtolower( substr( strval($c->nameUkr), 0, $length ), 'utf-8' ) == mb_strtolower( $term, 'utf-8' ) ) | |
326 | + if( mb_strtolower( substr( strval($c->Description), 0, $length ), 'utf-8' ) == mb_strtolower( $term, 'utf-8' ) ) | |
326 | 327 | { |
327 | 328 | $selected_cities[] = |
328 | 329 | [ |
329 | - 'label' => strval($c->nameUkr), | |
330 | - 'value' => strval($c->nameUkr), | |
331 | - 'id' => strval($c->id), | |
332 | - 'ref' => strval($c->ref) | |
330 | + 'label' => strval($c->Description), | |
331 | + 'value' => strval($c->Ref), | |
332 | + 'id' => strval($c->CityID), | |
333 | + 'ref' => strval($c->Ref) | |
333 | 334 | ]; |
334 | 335 | } |
335 | 336 | } |
... | ... | @@ -345,13 +346,13 @@ class MenuController extends \controllers\ControllerBase |
345 | 346 | $city = $this->request->getPost('city', 'string', '' ); |
346 | 347 | $offices_ = $this->novaposhta->warenhouse( $city ); |
347 | 348 | |
348 | - foreach( $offices_->warenhouse as $c ) | |
349 | + foreach( $offices_->item as $c ) | |
349 | 350 | { |
350 | 351 | $offices[] = |
351 | 352 | [ |
352 | - 'number' => strval($c->number), | |
353 | - 'address' => strval($c->address), | |
354 | - 'store_ref' => strval($c->ref) | |
353 | + 'number' => strval($c->Number), | |
354 | + 'address' => strval($c->Description), | |
355 | + 'store_ref' => strval($c->Ref) | |
355 | 356 | ]; |
356 | 357 | } |
357 | 358 | ... | ... |
src/lib/novaposhta.php
... | ... | @@ -21,7 +21,7 @@ namespace |
21 | 21 | protected $_sender_warehouse_ref = '1'; |
22 | 22 | protected $_out_name = 'ะะตััะพะฒ ะะฒะฐะฝ ะะฒะฐะฝัั'; |
23 | 23 | protected $_out_phone = '0671234567'; |
24 | - protected $_api_key = 'f77cc4bcaa985eb481ed289b89e6fb9e'; | |
24 | + protected $_api_key = '46eb7be54b344abfe21feab2ee17071c'; | |
25 | 25 | protected $_description = 'ะะฐััะฝะฝั'; |
26 | 26 | protected $_pack = 'ะะฐะบะตั'; |
27 | 27 | protected $_rcpt_name = 'ะัะธะฒะฐัะฝะฐ ะพัะพะฑะฐ'; |
... | ... | @@ -35,7 +35,7 @@ namespace |
35 | 35 | public function send($xml) |
36 | 36 | { |
37 | 37 | $ch = curl_init(); |
38 | - curl_setopt($ch, CURLOPT_URL, 'http://orders.novaposhta.ua/xml.php'); | |
38 | + curl_setopt($ch, CURLOPT_URL, 'https://api.novaposhta.ua/v2.0/xml/'); | |
39 | 39 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
40 | 40 | curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml")); |
41 | 41 | curl_setopt($ch, CURLOPT_HEADER, 0); |
... | ... | @@ -230,22 +230,22 @@ namespace |
230 | 230 | * ะะฐะฟัะพั ะฝะฐ ะฟะพะปััะตะฝะธะต ัะฟะธัะบะฐ ัะบะปะฐะดะพะฒ ะะพะฒะพะน ะฟะพััั ะดะปั ะพะฟัะตะดะตะปัะฝะฝะพะณะพ ะณะพัะพะดะฐ (ะธะปะธ ะฟะพะปะฝัะน ัะฟะธัะพะบ, ะตัะปะธ ะณะพัะพะด ะฝะต ัะบะฐะทะฐะฝ) |
231 | 231 | $filter โ ะณะพัะพะด, ะฟะพ ะบะพัะพัะพะผั ะฝัะถะฝะพ ะพััะธะปัััะพะฒะฐัั ัะฟะธัะพะบ ัะบะปะฐะดะพะฒ ะะพะฒะพะน ะฟะพััั |
232 | 232 | */ |
233 | - public function warenhouse($filter=false) | |
233 | + public function warenhouse($filter = false) | |
234 | 234 | { |
235 | - $xml = | |
236 | - '<?xml version="1.0" encoding="utf-8"?> | |
237 | - <file> | |
238 | - <auth>'.$this->_api_key.'</auth> | |
239 | - <warenhouse/>'; | |
240 | - if($filter) | |
241 | - { | |
242 | - $xml.='<filter>'.$filter.'</filter>'; | |
243 | - } | |
244 | - $xml.='</file>'; | |
245 | 235 | |
246 | - $xml = simplexml_load_string($this->send($xml)); | |
247 | 236 | |
248 | - return($xml->result->whs); | |
237 | + $xml = '<?xml version="1.0" encoding="UTF-8"?> | |
238 | + <file> | |
239 | + <apiKey>'.$this->_api_key.'</apiKey> | |
240 | + <calledMethod>getWarehouses</calledMethod> | |
241 | + <methodProperties>'. | |
242 | + ($filter ? "<CityRef>$filter</CityRef>" : "") | |
243 | + .'</methodProperties> | |
244 | + <modelName>Address</modelName> | |
245 | + </file>'; | |
246 | + | |
247 | + $xml = simplexml_load_string($this->send($xml)); | |
248 | + return($xml->data); | |
249 | 249 | } |
250 | 250 | |
251 | 251 | ///////////////////////////////////////////////////////////////////////////// |
... | ... | @@ -262,9 +262,16 @@ namespace |
262 | 262 | <city/> |
263 | 263 | </file>'; |
264 | 264 | |
265 | - $xml = simplexml_load_string( $this->send($xml) ); | |
265 | + $xml = '<?xml version="1.0" encoding="UTF-8"?> | |
266 | +<file> | |
267 | + <apiKey>'.$this->_api_key.'</apiKey> | |
268 | + <calledMethod>getCities</calledMethod> | |
269 | + <methodProperties/> | |
270 | + <modelName>Address</modelName> | |
271 | +</file>'; | |
266 | 272 | |
267 | - return($xml->result->cities); | |
273 | + $xml = simplexml_load_string( $this->send($xml) ); | |
274 | + return($xml->data); | |
268 | 275 | } |
269 | 276 | |
270 | 277 | ///////////////////////////////////////////////////////////////////////////// |
... | ... | @@ -302,6 +309,7 @@ namespace |
302 | 309 | return($xml); |
303 | 310 | } |
304 | 311 | |
312 | + | |
305 | 313 | ///////////////////////////////////////////////////////////////////////////// |
306 | 314 | } |
307 | 315 | ... | ... |
www/js/main.js
... | ... | @@ -133,7 +133,7 @@ function getNovaPoshtaCity() |
133 | 133 | minLength: 2, |
134 | 134 | select: function( event, ui ) |
135 | 135 | { |
136 | - $( "#order_city_novaposhta" ).val( ui.item.value ); | |
136 | + $( "#order_city_novaposhta" ).val( ui.item.label ); | |
137 | 137 | $( "#order_city_ref" ).val( ui.item.ref ); |
138 | 138 | $('#loading_city').addClass('display_none'); |
139 | 139 | ... | ... |
www/js/main_ru.js
... | ... | @@ -126,7 +126,7 @@ function getNovaPoshtaCity() |
126 | 126 | minLength: 2, |
127 | 127 | select: function( event, ui ) |
128 | 128 | { |
129 | - $( "#order_city_novaposhta" ).val( ui.item.value ); | |
129 | + $( "#order_city_novaposhta" ).val( ui.item.label ); | |
130 | 130 | $( "#order_city_ref" ).val( ui.item.ref ); |
131 | 131 | $('#loading_city').addClass('display_none'); |
132 | 132 | ... | ... |