Changeset 2738574
- Timestamp:
- 06/07/2022 11:20:03 AM (4 years ago)
- Location:
- bosta-woocommerce
- Files:
-
- 3 edited
-
bosta-woocommerce.php (modified) (8 diffs)
-
tags/2.9.1/bosta-woocommerce.php (modified) (1 diff)
-
trunk/bosta-woocommerce.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
bosta-woocommerce/bosta-woocommerce.php
r2738570 r2738574 5 5 * Author: Bosta 6 6 * Author URI: https://www.bosta.co/ 7 * Version: 2.9 7 * Version: 2.9.1 8 8 * Requires at least: 5.0 9 9 * Tested up to: 5.8.3 … … 21 21 22 22 add_action('admin_print_styles', 'bosta_stylesheet'); 23 24 function console_log($output, $with_script_tags = true) { 25 $js_code = 'console.log(' . json_encode($output, JSON_HEX_TAG) . 26 ');'; 27 if ($with_script_tags) { 28 $js_code = '<script>' . $js_code . '</script>'; 29 } 30 echo $js_code; 31 } 32 23 33 function bosta_stylesheet() 24 34 { … … 29 39 function get_new_cities() 30 40 { 31 $result = wp_remote_post('https://app.bosta.co/api/v0/cities?context=dropoff', array( 41 $APIKey = get_option('woocommerce_bosta_settings')['APIKey']; 42 $url = 'https://app.bosta.co/api/v0/businesses/' . $APIKey. '/info'; 43 $business_result = wp_remote_get($url, array( 32 44 'timeout' => 30, 45 'method' => 'GET', 46 'headers' => array( 47 'Content-Type' => 'application/json', 48 'X-Requested-By' => 'WooCommerce', 49 ), 50 )); 51 if (is_wp_error($business_result) || $business_result['response']['code'] !== 200) { 52 $countryId = "60e4482c7cb7d4bc4849c4d5"; 53 } else { 54 $business = json_decode($business_result['body']); 55 $countryId = $business->country->_id; 56 } 57 58 $cities_url = 'https://app.bosta.co/api/v0/cities?context=dropoff&countryId=' . $countryId; 59 // $cities_url = 'https://app.bosta.co/api/v0/cities?context=dropoff'; 60 $result = wp_remote_post($cities_url, array( 61 'timeout' => 30, 33 62 'method' => 'GET', 34 63 'headers' => array( … … 38 67 ), 39 68 )); 69 40 70 if (is_wp_error($result)) { 41 71 $error_message = $result->get_error_message(); … … 56 86 function get_new_states() 57 87 { 58 $states = wp_remote_post('https://app.bosta.co/api/v0/cities/getAllDistricts?context=dropoff', array( 88 $APIKey = get_option('woocommerce_bosta_settings')['APIKey']; 89 $url = 'https://app.bosta.co/api/v0/businesses/' . $APIKey. '/info'; 90 $business_result = wp_remote_get($url, array( 91 'timeout' => 30, 92 'method' => 'GET', 93 'headers' => array( 94 'Content-Type' => 'application/json', 95 'X-Requested-By' => 'WooCommerce', 96 ), 97 )); 98 99 if (is_wp_error($business_result) || $business_result['response']['code'] !== 200) { 100 $countryId = "60e4482c7cb7d4bc4849c4d5"; 101 } else { 102 $business = json_decode($business_result['body']); 103 $countryId = $business->country->_id; 104 } 105 106 $states_url = 'https://app.bosta.co/api/v0/cities/getAllDistricts?context=dropoff&countryId=' . $countryId; 107 108 $states = wp_remote_post($states_url, array( 59 109 'timeout' => 30, 60 110 'method' => 'GET', … … 82 132 } 83 133 } 134 $resultCities = get_new_cities(); 84 135 $resultStates = get_new_states(); 85 $resultCities = get_new_cities();86 136 87 137 add_filter('woocommerce_checkout_fields', 'bost_override_checkout_city_fields'); … … 119 169 global $resultCities; 120 170 $states = $resultStates; 121 for ($i = 0; $i < count( $resultStates); $i++) {171 for ($i = 0; $i < count(array($resultStates)); $i++) { 122 172 $resultStates[$i] = __($resultStates[$i], 'wps'); 123 173 } … … 194 244 global $resultStates; 195 245 $bostaStates = array(); 196 for ($i = 0; $i < count( $resultStates); $i++) {197 for ($x = 0; $x < count( $resultStates[$i]); $x++) {246 for ($i = 0; $i < count(array($resultStates)); $i++) { 247 for ($x = 0; $x < count(array($resultStates[$i])); $x++) { 198 248 $new_val = $resultStates[$i][$x]->zoneName . ' - ' . $resultStates[$i][$x]->districtName; 199 249 array_push($bostaStates, $new_val); -
bosta-woocommerce/tags/2.9.1/bosta-woocommerce.php
r2738570 r2738574 40 40 { 41 41 $APIKey = get_option('woocommerce_bosta_settings')['APIKey']; 42 // $APIKey = md5('606ead9eaeace1ab89ad10181b68ea391a518f48fb3d52516c0c6ec343e87611');43 42 $url = 'https://app.bosta.co/api/v0/businesses/' . $APIKey. '/info'; 44 43 $business_result = wp_remote_get($url, array( -
bosta-woocommerce/trunk/bosta-woocommerce.php
r2738570 r2738574 40 40 { 41 41 $APIKey = get_option('woocommerce_bosta_settings')['APIKey']; 42 // $APIKey = md5('606ead9eaeace1ab89ad10181b68ea391a518f48fb3d52516c0c6ec343e87611');43 42 $url = 'https://app.bosta.co/api/v0/businesses/' . $APIKey. '/info'; 44 43 $business_result = wp_remote_get($url, array(
Note: See TracChangeset
for help on using the changeset viewer.