Changeset 2643801
- Timestamp:
- 12/14/2021 10:43:00 AM (4 years ago)
- Location:
- abrestan/trunk
- Files:
-
- 1 deleted
- 2 edited
-
abrestan.php (modified) (3 diffs)
-
abrestan_logs.log (deleted)
-
inc/Api/abrestan_sync_orders.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
abrestan/trunk/abrestan.php
r2643408 r2643801 4 4 * Plugin URI: abrestan.com 5 5 * Description: Using this web service, you can connect your store to abrestan cloud accounting software. 6 * Version: 2.2. 16 * Version: 2.2.2 7 7 * Author: KTE 8 8 * WC requires at least: 4.1.0 … … 135 135 return $results; 136 136 } 137 function abrestanGetOrder ByCompanyId()137 function abrestanGetOrder($order_id,$company_id) 138 138 { 139 139 global $wpdb; 140 140 $table_name = $wpdb->prefix . 'abrestan_order'; 141 $q = $wpdb->prepare("SELECT * FROM $table_name where company_id=%d ", get_option("abrestan_company")['companyCode']);141 $q = $wpdb->prepare("SELECT * FROM $table_name where company_id=%d AND order_id=%d ", $company_id,$order_id ); 142 142 $results = $wpdb->get_results($q); 143 143 return $results; … … 252 252 253 253 } 254 254 add_action('wp_ajax_abrestan_send_again_orders_action', 'abrestan_send_again_orders_action'); 255 add_action('wp_ajax_nopriv_abrestan_send_again_orders_action', 'abrestan_send_again_orders_action'); 256 function abrestan_send_again_orders_action() 257 { 258 259 $orders = isset($_REQUEST['orders']) ? 260 wp_unslash($_REQUEST['orders']) : 261 array(); 262 263 $order = array(); 264 265 if (is_array($orders)) { 266 foreach ($orders as $orderKey => $orderVAL) { 267 $order[$orderKey] = sanitize_text_field($orderVAL); 268 } 269 } 270 $Data = 271 [ 272 'company_id' => get_option("abrestan_company")['companyCode'], 273 ]; 274 $abrestanApi = new abrestan_api(); 275 $wp_remote_post = $abrestanApi->getOrders($Data); 276 277 $abrestanFactors = json_decode(wp_remote_retrieve_body($wp_remote_post), true)['factors']; 278 function searchForId($id, $array) { 279 foreach ($array as $key => $val) { 280 if ($val['generation_id'] === $id) { 281 return true; 282 } 283 } 284 return null; 285 } 286 var_dump($order); 287 var_dump($abrestanFactors); 288 die(); 289 290 $sync_order = new \ABR\Api\abrestan_sync_orders(); 291 echo json_encode($sync_order->Send_orders($order)); 292 wp_die(); 293 294 } 255 295 add_action('wp_ajax_abrestan_save_setting_action', 'abrestan_save_setting_action'); 256 296 add_action('wp_ajax_nopriv_abrestan_save_setting_action', 'abrestan_save_setting_action'); -
abrestan/trunk/inc/Api/abrestan_sync_orders.php
r2643408 r2643801 66 66 array_push($all_orders, $order->get_id()); 67 67 } 68 69 68 $oldSent=abrestanGetOrderByOrderIds($all_orders); 70 69 $oldorders=[]; … … 72 71 if(!searchForId($sent->factor_id,$abrestanFactors)){ 73 72 abrestanDeleteOrderByOrderId($sent->order_id,get_option("abrestan_company")['companyCode']); 73 }else{ 74 74 array_push($oldorders,$sent->order_id); 75 75 } 76 77 76 } 78 77 79 return array_ intersect($oldorders,$all_orders);78 return array_values(array_diff($all_orders,$oldorders)); 80 79 } 81 80
Note: See TracChangeset
for help on using the changeset viewer.