Changeset 2945241
- Timestamp:
- 07/31/2023 07:24:59 AM (2 years ago)
- Location:
- bosta-woocommerce
- Files:
-
- 15 added
- 3 edited
-
tags/3.0.6 (added)
-
tags/3.0.6/Css (added)
-
tags/3.0.6/Css/main.css (added)
-
tags/3.0.6/assets (added)
-
tags/3.0.6/assets/images (added)
-
tags/3.0.6/assets/images/bosta.svg (added)
-
tags/3.0.6/assets/images/refresh.png (added)
-
tags/3.0.6/assets/images/refreshIcon.png (added)
-
tags/3.0.6/bosta-woocommerce.php (added)
-
tags/3.0.6/components (added)
-
tags/3.0.6/components/pickups (added)
-
tags/3.0.6/components/pickups/pickups.css (added)
-
tags/3.0.6/components/pickups/pickups.php (added)
-
tags/3.0.6/readme.txt (added)
-
tags/3.0.6/uninstall.php (added)
-
trunk/bosta-woocommerce.php (modified) (18 diffs)
-
trunk/components/pickups/pickups.php (modified) (15 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
bosta-woocommerce/trunk/bosta-woocommerce.php
r2925746 r2945241 5 5 * Author: Bosta 6 6 * Author URI: https://www.bosta.co/ 7 * Version: 3.0. 57 * Version: 3.0.6 8 8 * Requires at least: 5.0 9 9 * php version 7.0 … … 24 24 25 25 const BOSTA_ENV_URL = 'https://app.bosta.co/api/v0'; 26 const PLUGIN_VERSION = '3.0.6'; 26 27 const bosta_cache_duration = 86400; 27 28 const bosta_country_id_duration = 604800; … … 52 53 'Content-Type' => 'application/json', 53 54 'X-Requested-By' => 'WooCommerce', 55 'X-Plugin-Version' => PLUGIN_VERSION 54 56 ), 55 57 )); … … 104 106 'X-Requested-By' => 'WooCommerce', 105 107 'Accept-Language' => get_locale() === 'ar' ? 'ar' : 'en', 108 'X-Plugin-Version' => PLUGIN_VERSION 106 109 ), 107 110 )); … … 154 157 'X-Requested-By' => 'WooCommerce', 155 158 'Accept-Language' => get_locale() === 'ar' ? 'ar' : 'en', 159 'X-Plugin-Version' => PLUGIN_VERSION 156 160 ), 157 161 )); … … 572 576 573 577 add_filter('handle_bulk_actions-edit-shop_order', 'bosta_sync_handle', 10, 3); 574 function bosta_sync_handle($redirect_to, $action, $order_ids )578 function bosta_sync_handle($redirect_to, $action, $order_ids, $page_num) 575 579 { 576 580 if ($action != 'sync_to_bosta' && $action != 'sync_cash_collection_orders') { … … 708 712 'authorization' => $APIKey, 709 713 'X-Requested-By' => 'WooCommerce', 714 'X-Plugin-Version' => PLUGIN_VERSION 710 715 ), 711 716 'body' => json_encode($formatedOrders[$i]), … … 746 751 } 747 752 } 748 $redirect_url = admin_url('edit.php?') . 'post_type=shop_order&paged=1'; 753 $page_num = $page_num ? $page_num : 1; 754 $redirect_url = admin_url('edit.php?') . 'post_type=shop_order&paged=' . $page_num; 749 755 wp_redirect($redirect_url); 750 756 } … … 758 764 ?> 759 765 <div class="alignleft actions custom"> 766 <?php wp_nonce_field('bosta_send_all_nonce', 'bosta_send_all_nonce_field'); ?> 767 <input type="hidden" name="page_num" value="<?php echo esc_attr($_GET['paged']); ?>"> 760 768 <button type="submit" name="send_all_orders" style="height:32px;" class="orders-button" value="yes"> 761 769 <?php … … 770 778 } 771 779 if ('shop_order' === $typenow && 'edit.php' === $pagenow && isset($_GET['send_all_orders']) && $_GET['send_all_orders'] === 'yes') { 772 $sendAllOrders = sanitize_text_field($_GET['send_all_orders']); 773 echo esc_html($sendAllOrders); 774 $orders = wc_get_orders(array( 775 'limit' => -1, 776 'return' => 'ids', 777 )); 778 bosta_sync_handle('', 'sync_to_bosta', $orders); 779 } 780 // Verify the nonce before processing the form 781 if (isset($_GET['bosta_send_all_nonce_field']) && check_admin_referer('bosta_send_all_nonce', 'bosta_send_all_nonce_field')) { 782 $page_num = isset($_GET['page_num']) ? $_GET['page_num'] : 1; 783 $sendAllOrders = sanitize_text_field($_GET['send_all_orders']); 784 echo esc_html($sendAllOrders); 785 $orders = wc_get_orders(array( 786 'limit' => 25, 787 'paged' => $page_num, 788 'return' => 'ids', 789 )); 790 bosta_sync_handle('', 'sync_to_bosta', $orders, $page_num); 791 } else { 792 echo "Invalid nonce! Something went wrong."; 793 } 794 } 780 795 781 796 } … … 785 800 { 786 801 global $pagenow, $typenow; 787 788 802 if ('shop_order' === $typenow && 'edit.php' === $pagenow && 'top' === $which) { 789 ?> 790 <div class="alignright actions custom"> 791 <button type="submit" name="fetch_status" style="height:32px;" class="danger-button" value="yes"> <?php 792 echo __('Refresh status ', 'woocommerce') . '<img src=' . esc_url(plugins_url('assets/images/refreshIcon.png', __FILE__)) . ' alt="Bosta" style="height:17px; width:20px;">'; ?></button> 793 </div> 794 <br> 795 <br> 796 <?php 803 ?> 804 <div class="alignright actions custom"> 805 <?php wp_nonce_field('bosta_fetch_status_nonce', 'bosta_fetch_status_nonce_field'); ?> 806 <input type="hidden" name="page_num" value="<?php echo esc_attr($_GET['paged']); ?>"> 807 <button type="submit" name="fetch_status" style="height:32px;" class="danger-button" value="yes"> <?php 808 echo __('Refresh status ', 'woocommerce') . '<img src=' . esc_url(plugins_url('assets/images/refreshIcon.png', __FILE__)) . ' alt="Bosta" style="height:17px; width:20px;">'; ?></button> 809 </div> 810 <br> 811 <br> 812 <?php 797 813 } 798 814 if ('shop_order' === $typenow && 'edit.php' === $pagenow && isset($_GET['fetch_status']) && $_GET['fetch_status'] === 'yes') { 799 $fetchStatus = sanitize_text_field($_GET['fetch_status']); 800 echo esc_html($fetchStatus); 801 $orders = wc_get_orders(array( 802 'limit' => -1, 803 'return' => 'ids', 804 )); 805 bosta_fetch_latest_status_action('fetch_latest_status', $orders); 806 } 807 } 808 809 function bosta_fetch_latest_status_action($action, $order_ids) 815 // Verify the nonce before processing the form 816 if (isset($_GET['bosta_fetch_status_nonce_field']) && check_admin_referer('bosta_fetch_status_nonce', 'bosta_fetch_status_nonce_field')) { 817 $page_num = isset($_GET['page_num']) ? $_GET['page_num'] : 1; 818 $fetchStatus = sanitize_text_field($_GET['fetch_status']); 819 echo esc_html($fetchStatus); 820 $orders = wc_get_orders(array( 821 'limit' => 25, 822 'paged' => $page_num, 823 'return' => 'ids', 824 )); 825 bosta_fetch_latest_status_action('fetch_latest_status', $orders, $page_num); 826 } else { 827 echo "Invalid nonce! Something went wrong."; 828 } 829 } 830 } 831 832 function bosta_fetch_latest_status_action($action, $order_ids, $page_num) 810 833 { 811 834 if ($action != 'fetch_latest_status') { … … 841 864 'authorization' => $APIKey, 842 865 'X-Requested-By' => 'WooCommerce', 866 'X-Plugin-Version' => PLUGIN_VERSION 843 867 ), 844 868 )); … … 871 895 } 872 896 } 873 $redirect_url = admin_url('edit.php?') . 'post_type=shop_order&paged=1'; 897 $page_num = $page_num ? $page_num : 1; 898 $redirect_url = admin_url('edit.php?') . 'post_type=shop_order&paged=' . $page_num; 874 899 wp_redirect($redirect_url); 900 exit; 875 901 } 876 902 } … … 937 963 'authorization' => $APIKey, 938 964 'X-Requested-By' => 'WooCommerce', 965 'X-Plugin-Version' => PLUGIN_VERSION 939 966 ), 940 967 )); … … 1036 1063 'authorization' => $APIKey, 1037 1064 'X-Requested-By' => 'WooCommerce', 1065 'X-Plugin-Version' => PLUGIN_VERSION 1038 1066 ), 1039 1067 'body' => json_encode($newOrder), … … 1073 1101 'authorization' => $APIKey, 1074 1102 'X-Requested-By' => 'WooCommerce', 1103 'X-Plugin-Version' => PLUGIN_VERSION 1075 1104 ), 1076 1105 )); … … 1122 1151 'authorization' => $APIKey, 1123 1152 'X-Requested-By' => 'WooCommerce', 1153 'X-Plugin-Version' => PLUGIN_VERSION 1124 1154 ), 1125 1155 )); … … 1237 1267 'authorization' => $APIKey, 1238 1268 'X-Requested-By' => 'WooCommerce', 1269 'X-Plugin-Version' => PLUGIN_VERSION 1239 1270 ), 1240 1271 )); -
bosta-woocommerce/trunk/components/pickups/pickups.php
r2925746 r2945241 15 15 'authorization' => $APIKey, 16 16 'X-Requested-By' => 'WooCommerce', 17 'X-Plugin-Version' => PLUGIN_VERSION 17 18 ), 18 19 )); 19 20 20 if (is_wp_error($result)) { 21 $error_message = $result->get_error_message(); 21 if (is_wp_error($result) || $result['response']['code'] != 200) { 22 $result = json_decode($result['body']); 23 $error_message = $result->message; 22 24 echo "Something went wrong: " .esc_html($error_message); 25 return; 23 26 } else { 24 27 $result = json_decode($result['body'])->data; … … 35 38 'authorization' => $APIKey, 36 39 'X-Requested-By' => 'WooCommerce', 40 'X-Plugin-Version' => PLUGIN_VERSION 37 41 ), 38 42 )); … … 87 91 88 92 </style>"; 89 if ( $_GET['pickupId']) {93 if (isset($_GET['pickupId'])) { 90 94 91 95 echo "<p class='create-pickup-title'>Edit Pickup"; … … 129 133 <td> 130 134 <label>Pickup Date</label>"; 131 if ( $pickupEditData->scheduledDate) {135 if (isset($pickupEditData) && $pickupEditData->scheduledDate) { 132 136 133 137 $date = date('Y-m-d', strtotime($pickupEditData->scheduledDate)); … … 147 151 ?> 148 152 <select required class='data' name='scheduledTimeSlot' > 149 <option <?php esc_attr(selectdCheck($pickupEditData->scheduledTimeSlot, '10:00 to 13:00'));?> value='10:00 to 13:00'>10:00AM to 01:00PM</option>150 <option <?php esc_attr(selectdCheck($pickupEditData->scheduledTimeSlot, '13:00 to 16:00'));?>value='13:00 to 16:00' >01:00PM to 04:00PM</option>153 <option <?php if(isset($pickupEditData)){esc_attr(selectdCheck($pickupEditData->scheduledTimeSlot, '10:00 to 13:00'));}?> value='10:00 to 13:00'>10:00AM to 01:00PM</option> 154 <option <?php if(isset($pickupEditData)){esc_attr(selectdCheck($pickupEditData->scheduledTimeSlot, '13:00 to 16:00'));}?>value='13:00 to 16:00' >01:00PM to 04:00PM</option> 151 155 </select> 152 156 <?php … … 155 159 </tbody> 156 160 </table>"; 157 if ( $_GET['pickupId']) {161 if (isset($_GET['pickupId'])) { 158 162 159 163 echo "<input class='primary-button' type='submit' name='create' value='Edit pickup'/>"; … … 201 205 $pickupData->scheduledTimeSlot = $scheduledTimeSlot; 202 206 $pickupData->businessLocationId = $businessLocationId; 203 if ( $_GET['pickupId']) {207 if (isset($_GET['pickupId'])) { 204 208 $pickupId = sanitize_text_field($_GET['pickupId']); 205 209 $result = wp_remote_request(BOSTA_ENV_URL . '/pickups/' . esc_html($pickupId), array( … … 210 214 'authorization' => $APIKey, 211 215 'X-Requested-By' => 'WooCommerce', 216 'X-Plugin-Version' => PLUGIN_VERSION 212 217 ), 213 218 'body' => json_encode($pickupData), … … 229 234 'authorization' => $APIKey, 230 235 'X-Requested-By' => 'WooCommerce', 236 'X-Plugin-Version' => PLUGIN_VERSION 231 237 ), 232 238 'body' => json_encode($pickupData), … … 255 261 } 256 262 257 if ('admin.php' === $pagenow && $_GET['page'] = 'bosta-woocommerce-view-pickups' && $_GET['pickupId']) {263 if ('admin.php' === $pagenow && $_GET['page'] = 'bosta-woocommerce-view-pickups' && isset($_GET['pickupId'])) { 258 264 259 265 echo "<p class='create-pickup-title'>Pickup Info … … 271 277 'authorization' => $APIKey, 272 278 'X-Requested-By' => 'WooCommerce', 279 'X-Plugin-Version' => PLUGIN_VERSION 273 280 ), 274 281 'body' => json_encode($pickupData), … … 352 359 'authorization' => $APIKey, 353 360 'X-Requested-By' => 'WooCommerce', 361 'X-Plugin-Version' => PLUGIN_VERSION 354 362 ), 355 363 'body' => json_encode($pickupData), … … 386 394 387 395 } 388 } else if ('admin.php' === $pagenow && $_GET['page'] = 'bosta-woocommerce-view-pickups' && ! $_GET['pickupId']) {396 } else if ('admin.php' === $pagenow && $_GET['page'] = 'bosta-woocommerce-view-pickups' && !isset($_GET['pickupId'])) { 389 397 ?> <button class="primary-button" onClick="document.location.href='admin.php?page=bosta-woocommerce-create-edit-pickup'">Create Pickup</button><?php 390 if ( $_GET['state'] == 'history-pickups') {398 if (isset($_GET['state']) && $_GET['state'] == 'history-pickups') { 391 399 ?> 392 400 … … 404 412 <?php 405 413 } 406 if ( $_GET['state'] != 'history-pickups'|| !isset($_GET['state'])) {414 if ((isset($_GET['state']) && $_GET['state'] != 'history-pickups') || !isset($_GET['state'])) { 407 415 $url = BOSTA_ENV_URL . '/pickups/search?state=Requested,Arrived at business,Route Assigned,Picking up,Receiving&pageId=-1'; 408 416 } else { 409 417 $url = BOSTA_ENV_URL . '/pickups/search?state=Canceled,Picked up&pageId=-1'; 410 418 } 419 420 if(!isset($pickupData)) return; 411 421 $result = wp_remote_post($url, array( 412 422 'timeout' => 30, … … 416 426 'authorization' => $APIKey, 417 427 'X-Requested-By' => 'WooCommerce', 428 'X-Plugin-Version' => PLUGIN_VERSION 418 429 ), 419 430 'body' => json_encode($pickupData), -
bosta-woocommerce/trunk/readme.txt
r2925746 r2945241 7 7 Requires PHP: 7.0 8 8 Tested up to: 6.1.1 9 Stable tag: 3.0. 59 Stable tag: 3.0.6 10 10 WC requires at least: 2.6 11 11 WC tested up to: 7.2.2 … … 166 166 * fixing mapping issues 167 167 168 = 3.0.3 168 = 3.0.3 = 169 169 * fixing no APIKEY and no "Allow New Zones" option issues 170 170 171 = 3.0.4 171 = 3.0.4 = 172 172 * fixing KSA zones 173 173 174 = 3.0.5 174 = 3.0.5 = 175 175 * allow clear caching 176 176 * fixing missing districts 177 178 = 3.0.6 = 179 * Fixed refresh status timeout 180 * Performance enhancements
Note: See TracChangeset
for help on using the changeset viewer.