Changeset 2761181
- Timestamp:
- 07/25/2022 12:53:59 PM (4 years ago)
- Location:
- invelity-gls-parcelshop/trunk
- Files:
-
- 5 edited
-
README.txt (modified) (2 diffs)
-
includes/WC_Gls_Parcel_Shop_Shipping_Method.php (modified) (1 diff)
-
invelity-gls-parcelshop.php (modified) (1 diff)
-
invelityGlsParcelShopShops.php (modified) (9 diffs)
-
public/js/invelity-gls-parcel-shop-public.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
invelity-gls-parcelshop/trunk/README.txt
r2547468 r2761181 5 5 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=38W6PN4WHLK32 6 6 Requires at least: 5.0.0 7 Tested up to: 5. 7.28 Stable tag: 5. 3.29 Requires PHP: 7. 27 Tested up to: 5.8.1 8 Stable tag: 5.8.1 9 Requires PHP: 7.4 10 10 WC requires at least: 4.0 11 11 License: GPLv2 or later … … 50 50 renamed default shipping method 51 51 fixed notices 52 53 = 1.0.2 = 54 invelityGlsParcelShopGetShops prevent fatal error -
invelity-gls-parcelshop/trunk/includes/WC_Gls_Parcel_Shop_Shipping_Method.php
r2399263 r2761181 4 4 if (!class_exists('WC_Shipping_Method')) 5 5 return; 6 7 6 if (!class_exists('WC_Gls_Parcel_Shop_Shipping_Method')) { 8 7 class WC_Gls_Parcel_Shop_Shipping_Method extends WC_Shipping_Method -
invelity-gls-parcelshop/trunk/invelity-gls-parcelshop.php
r2399263 r2761181 8 8 Author: Invelity 9 9 Author URI: https://www.invelity.com 10 Version: 1.0. 110 Version: 1.0.2 11 11 */ 12 12 -
invelity-gls-parcelshop/trunk/invelityGlsParcelShopShops.php
r2394221 r2761181 4 4 function invelityGlsParcelShopCronAction() 5 5 { 6 $log = fopen(__DIR__ .'/log.txt', 'a+');6 $log = fopen(__DIR__.'/log.txt', 'a+'); 7 7 fwrite($log, date('d.m.Y H:i:s')); 8 8 9 9 $response_data = invelityGlsParcelShopGetShops(); 10 invelityUpdateInvelityGlsParcelShopTable($response_data); 11 fwrite($log, 'GLS Parcel Shop updated'); 12 fclose($log); 10 if($response_data){ 11 invelityUpdateInvelityGlsParcelShopTable($response_data); 12 fwrite($log, 'GLS Parcel Shop updated'); 13 fclose($log); 14 }else{ 15 fwrite($log, 'GLS Parcel Shop not updated'); 16 fclose($log); 17 } 18 13 19 } 14 20 15 21 function invelityGlsParcelShopFirstInitShops() 16 22 { 17 18 if (!$_POST['method_id']) { 23 if ( ! $_POST['method_id']) { 19 24 return; 20 25 } 21 26 if ($_POST['method_id'] == 'inv_gls_parcel_shop') { 22 23 27 $response_data = invelityGlsParcelShopGetShops(); 24 28 … … 32 36 </div>'; 33 37 }); 34 35 38 } 36 39 } 37 38 40 } 39 41 } … … 41 43 function invelityGlsParcelShopGetShops() 42 44 { 45 $url = 'https://datarequester.gls-hungary.com/glsconnect/getDropoffPoints.php?ctrcode=sk'; 46 $remote = wp_remote_get($url, ['timeout' => 120, 'method' => 'POST', 'redirection' => 5]); 43 47 44 $url = 'https://datarequester.gls-hungary.com/glsconnect/getDropoffPoints.php?ctrcode=sk'; 45 $remote = wp_remote_get($url, ['timeout' => 120, 'method' => 'POST','redirection' =>5]); 46 $xmlContent = simplexml_load_string(gzdecode($remote['body'])); 48 try { 49 $xmlContent = simplexml_load_string(gzdecode($remote['body'])); 50 if (isset($xmlContent->Data)) { 51 return get_object_vars($xmlContent->Data); 52 } else { 53 return false; 54 } 55 } catch (Exception $e) { 56 echo $e->getMessage(); 47 57 48 return get_object_vars($xmlContent->Data); 49 50 58 return false; 59 } 51 60 } 52 61 53 62 function invelityUpdateInvelityGlsParcelShopTable($response_data) 54 63 { 55 56 57 64 global $wpdb; 58 65 59 $table = $wpdb->prefix .'inv_gls_parcel_shop';60 $wpdb->delete($table, array('country' => 'SK'));66 $table = $wpdb->prefix.'inv_gls_parcel_shop'; 67 $wpdb->delete($table, ['country' => 'SK']); 61 68 62 69 foreach ($response_data['DropoffPoint'] as $item) { 63 $data = array();70 $data = []; 64 71 $openHours = []; 65 72 66 73 $serializedOpenHours = ''; 67 74 foreach ($item->Openings as $opening) { 68 69 75 foreach ($opening as $open) { 70 $toArray = (array)$open;76 $toArray = (array)$open; 71 77 $openHours[] = $toArray; 72 78 } 73 79 $serializedOpenHours = serialize($openHours); 74 75 80 } 76 81 77 82 78 83 foreach ($item->attributes() as $a => $b) { 79 80 81 84 if ($a == 'ID') { 82 $data['ID_PARCEL_SHOP'] = (string)$b;85 $data['ID_PARCEL_SHOP'] = (string)$b; 83 86 $data['GLS_PARCEL_SHOP'] = (string)$b; 84 87 } elseif ($a == 'Name') { … … 102 105 } 103 106 $data['CP'] = '-'; 107 } 108 109 $data['PARCEL_SHOP'] = (string)$data['ADDRESS'].' '.$data['CITY'].' '.$data['ZIP']; 110 $data['COUNTRY'] = 'SK'; 111 $data['DATA'] = $serializedOpenHours; 104 112 105 113 106 } 107 108 $data['PARCEL_SHOP'] = (string)$data['ADDRESS'] . ' ' . $data['CITY'] . ' ' . $data['ZIP']; 109 $data['COUNTRY'] = 'SK'; 110 $data['DATA'] = $serializedOpenHours; 111 112 113 $wpdb->insert($wpdb->prefix . 'inv_gls_parcel_shop', $data); 114 114 $wpdb->insert($wpdb->prefix.'inv_gls_parcel_shop', $data); 115 115 } 116 117 116 } 118 117 … … 120 119 { 121 120 global $wpdb; 122 $table_name = $wpdb->prefix . 'inv_gls_parcel_shop'; 123 $result = $wpdb->get_results('SELECT * FROM ' . $table_name . ''); 121 $table_name = $wpdb->prefix.'inv_gls_parcel_shop'; 122 $result = $wpdb->get_results('SELECT * FROM '.$table_name.''); 123 124 124 return $result; 125 126 127 125 } 128 126 … … 130 128 function displayParcelShopData($data) 131 129 { 132 133 130 $array = unserialize($data); 134 131 $hours = []; 135 132 136 133 foreach ($array as $key => $value) { 137 $day = $value['@attributes']['Day'];138 $open = $value['@attributes']['OpenHours'];134 $day = $value['@attributes']['Day']; 135 $open = $value['@attributes']['OpenHours']; 139 136 $break = $value['@attributes']['MidBreak']; 140 137 … … 144 141 145 142 $day_map = [ 146 'Monday' => 'Pondelok',147 'Tuesday' => 'Utorok',143 'Monday' => 'Pondelok', 144 'Tuesday' => 'Utorok', 148 145 'Wednesday' => 'Streda', 149 'Thursday' => 'Štvrtok',150 'Friday' => 'Piatok',151 'Saturday' => 'Sobota',152 'Sunday' => 'Nedeľa'146 'Thursday' => 'Štvrtok', 147 'Friday' => 'Piatok', 148 'Saturday' => 'Sobota', 149 'Sunday' => 'Nedeľa' 153 150 ]; 154 151 155 $result = array();152 $result = []; 156 153 157 154 foreach ($hours as $i => $array2) { 158 159 $translatedKey = array_key_exists($i, $day_map) ? 155 $translatedKey = array_key_exists($i, $day_map) ? 160 156 $day_map[$i] : 161 157 $i; 162 158 $result[$translatedKey] = $array2; 163 164 159 } 165 160 … … 168 163 169 164 return $result; 170 171 165 } 172 166 173 167 function sortResultByDays(array $array, array $orderArray) 174 168 { 175 $ordered = array();169 $ordered = []; 176 170 foreach ($orderArray as $key) { 177 171 if (array_key_exists($key, $array)) { … … 180 174 } 181 175 } 176 182 177 return $ordered + $array; 183 178 } -
invelity-gls-parcelshop/trunk/public/js/invelity-gls-parcel-shop-public.js
r2547468 r2761181 33 33 custom.map.mapObject.setView([gps_lat, gps_long], 15); 34 34 } 35 36 35 37 36 for (let index = 0; index < vendors.length; index++) { … … 42 41 .on('click', selectShop, vendors[index].id) 43 42 .addTo(custom.map.mapObject); 44 45 43 } 46 44
Note: See TracChangeset
for help on using the changeset viewer.