Changeset 2430827
- Timestamp:
- 12/03/2020 10:51:04 AM (5 years ago)
- Location:
- sendbox-shipping/trunk
- Files:
-
- 7 edited
-
README.txt (modified) (3 diffs)
-
admin/class-wooss-admin.php (modified) (10 diffs)
-
admin/js/wooss-admin.js (modified) (3 diffs)
-
includes/assets/js/script.js (modified) (2 diffs)
-
includes/class-wooss-sendbox-shipping-api.php (modified) (4 diffs)
-
includes/class-wooss-shipping-method.php (modified) (23 diffs)
-
wooss.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
sendbox-shipping/trunk/README.txt
r2341519 r2430827 59 59 60 60 61 <h3>How do i get my access tpken?</h3> 62 <p> To get your access token, you should go to <a href = "https://developers.sendbox.co/">sendbox</a>, create an account.</p> 63 <br/> 64 <p>Proceed to create a new app, enter app name can be your site name, description, and your site url to serve as app url. </p> 65 <p>Your access token and other important keys are generated for you. </p> 66 61 <h3>How do i get my API Key </h3> 62 <p> To get your key, you should go to <a href = "https://sendbox.co/">sendbox</a>, create an account, navigate to 63 settings on you sendbox dashboard, scroll and find your API Key.</p> 67 64 68 65 <h3>How do i use the API Key? </h3> … … 78 75 <h3>Documentation</h3> 79 76 <b> You can find documentaiton for this plugin by 80 clicking <a href = "http s://docs.sendbox.co/third-party-intergations/woo-commerce-plugin">Here</a> </b>77 clicking <a href = "http://bit.ly/sendbox-shipping-docs">Here</a> </b> 81 78 82 79 … … 110 107 111 108 <b>3.1.0</b> 112 <p>fixed some bugs with the javascript</p> 109 <p>fixed some bugs with the javascript</p> 113 110 114 <b>3.2.0</b> 115 <p>fixed some bugs with the api</p> 116 117 <b>3.2.1</b> 118 <p>Updated sendbox access token for user authentication</p> 111 <b>3.2.2</b> 112 <p>bugs fixes and JS upgrade to use jqueryserilize</p> 119 113 120 114 -
sendbox-shipping/trunk/admin/class-wooss-admin.php
r2341519 r2430827 108 108 ); 109 109 110 wp_enqueue_script('wooss_shipping_method_js_script', plugin_dir_url(__FILE__) . '../includes/assets/js/script.js', array('jquery'), $this->version, false); 110 wp_enqueue_script('wooss_shipping_method_serilizejson_script', plugin_dir_url(__FILE__) . '../includes/assets/js/jqueryserilize.js', array('jquery'), $this->version, false); 111 wp_enqueue_script('wooss_shipping_method_js_script', plugin_dir_url(__FILE__) . '../includes/assets/js/script.js', array('jquery','wooss_shipping_method_serilizejson_script'), $this->version, false); 111 112 wp_localize_script( 112 113 'wooss_shipping_method_js_script', … … 237 238 $api_call = new Wooss_Sendbox_Shipping_API(); 238 239 //$auth_header = get_option('wooss_basic_auth'); 239 $auth_header = $api_call->checkAuth();240 $auth_header = Wooss_Sendbox_Shipping_API::checkAuth(); 240 241 $args = array( 241 242 'headers' => array( … … 257 258 $wc_city = get_option('woocommerce_store_city'); 258 259 $wc_store_address = get_option('woocommerce_store_address'); 259 $wooss_origin_city = get_option(' wooss_origin_city');260 $wooss_origin_street = get_option(' wooss_origin_street');260 $wooss_origin_city = get_option('sendbox_data')['wooss_city']; 261 $wooss_origin_street = get_option('sendbox_data')['wooss_street']; 261 262 if (null == $wooss_origin_city) { 262 263 $wooss_origin_city = $wc_city; … … 265 266 $wooss_origin_street = $wc_store_address; 266 267 } 267 $wooss_origin_states_selected = get_option(' wooss_states_selected');268 $wooss_origin_states_selected = get_option('sendbox_data')['wooss_state_dropdown']; 268 269 if (null == $wooss_origin_states_selected) { 269 270 $wooss_origin_states_selected = ''; … … 274 275 } 275 276 276 $wooss_pickup_type = get_option(' wooss_pickup_type');277 $wooss_pickup_type = get_option('sendbox_data')['wooss_pickup_type']; 277 278 if (null == $wooss_pickup_type) { 278 279 $wooss_pickup_type = 'pickup'; 279 280 } 280 281 281 $incoming_option_code = get_option(' wooss_pickup_type');282 $incoming_option_code = get_option('sendbox_data')['wooss_pickup_type']; 282 283 if (null == $incoming_option_code) { 283 284 return; … … 378 379 $payload_data = new stdClass(); 379 380 $payload_data->origin_name = $wooss_origin_name; 380 $payload_data->destination_country = $destination_country;381 //$payload_data->destination_country = $destination_country; 381 382 $payload_data->destination_country_code = $destination_country; 382 383 //$payload_data->destination_state_code = ' '; … … 399 400 $payload_data->incoming_option_code = $incoming_option_code; 400 401 $payload_data->payment_option_code = 'prepaid'; 401 //$payload_data->deliver_type_code = 'last_mile'; 402 //$payload_data->deliver_type_code = 'last_mile'; 403 402 404 403 405 $payload_data_json = wp_json_encode($payload_data); … … 410 412 411 413 ); 412 //print_r($ delivery_args);414 //print_r($payload_data_json); 413 415 414 416 … … 661 663 $payload_data = new stdClass(); 662 664 663 $payload_data->selected_courier_id = $courier_selected;665 //$payload_data->selected_courier_id = $courier_selected; 664 666 665 667 $payload_data->destination_name = $destination_name; … … 689 691 690 692 $payload_data->deliver_priority_code = 'next_day'; 691 $payload_data->pickup_date = $pickup_date; 693 $payload_data->pickup_date = $pickup_date; 694 $payload_data->channel_code ='api'; 695 $payload_data->rate_code ="standard" ; 696 692 697 693 698 $api_call = new Wooss_Sendbox_Shipping_API(); 694 699 //$auth_header = get_option('wooss_basic_auth'); 695 $auth_header = $api_call->checkAuth();696 697 $payload_data_json = wp_json_encode($payload_data); 700 $auth_header = Wooss_Sendbox_Shipping_API::checkAuth();; 701 702 $payload_data_json = wp_json_encode($payload_data); 698 703 699 704 $shipments_args = array( -
sendbox-shipping/trunk/admin/js/wooss-admin.js
r2335894 r2430827 74 74 /* var wooss_destination_country = $( 75 75 "input[name = 'wooss_destination_country']" 76 ).val(); 76 ).val(); 77 77 var wooss_destination_state = $( 78 78 "input[name = 'wooss_destination_state']" … … 98 98 var wooss_destination_state = $("select#wooss_destination_state").val(); 99 99 $("select#wooss_destination_state").change(function(){ 100 wooss_destination_state = $(this).val() ;100 wooss_destination_state = $(this).val() 101 101 }) 102 102 … … 130 130 wooss_order_id: wooss_order_id 131 131 }; 132 //console.log(wooss_destination_state); 132 133 133 134 $.post( -
sendbox-shipping/trunk/includes/assets/js/script.js
r2341519 r2430827 54 54 var sendbox_refresh_token; 55 55 var sendbox_app_id; 56 var sendbox_client_secret; 56 var sendbox_client_secret; 57 57 var wooss_connect_btn = $("button.wooss-connect-sendbox"); 58 58 var wooss_errors_message_span = $("span.wooss_errors_pages"); … … 63 63 64 64 wooss_connect_btn.on("click", function (e) { 65 e.preventDefault(); 65 e.preventDefault(); 66 var formDetails = $('form').serializeJSON(); 67 console.log(formDetails.wooss); 66 68 //wooss_basic_auth = $("input[name='wooss_basic_auth'").val(); 67 sendbox_auth_token = $("input[name='sendbox_auth_token']").val(); 68 sendbox_refresh_token = $("input[name='sendbox_refresh_token']").val(); 69 //sendbox_auth_token = formDetails.sendbox_auth_token 70 //console.log($('form').serializeJSON()); 71 /* sendbox_refresh_token = $("input[name='sendbox_refresh_token']").val(); 72 console.log(sendbox_auth_token, sendbox_refresh_token) 69 73 sendbox_app_id = $("input[name='sendbox_app_id']").val(); 70 74 sendbox_client_secret = $("input[name='sendbox_client_secret']").val(); 71 75 */ 72 76 function reloadPage() { 73 77 window.location.reload(); 74 78 } 75 79 wooss_loader.show(); 76 var data = { 77 //wooss_basic_auth: wooss_basic_auth 78 sendbox_auth_token: sendbox_auth_token, 79 sendbox_refresh_token: sendbox_refresh_token, 80 sendbox_app_id: sendbox_app_id, 81 sendbox_client_secret: sendbox_client_secret, 82 }; 80 var data = formDetails.wooss 81 console.log(data) 82 83 83 $.post( 84 84 wooss_ajax_object.wooss_ajax_url, -
sendbox-shipping/trunk/includes/class-wooss-sendbox-shipping-api.php
r2341519 r2430827 94 94 */ 95 95 96 public function checkAuth(){96 public static function checkAuth(){ 97 97 98 $api_key = get_option('sendbox_ auth_token');98 $api_key = get_option('sendbox_data')['sendbox_auth_token']; 99 99 $profile_url = "https://live.sendbox.co/oauth/profile"; 100 100 101 101 $profile_res = wp_remote_get( $profile_url , 102 array( 'timeout' => 10,102 array( 'timeout' => 40, 103 103 'headers' => array( 'Content-Type' => 'application/json', 104 104 'Authorization'=> $api_key ) 105 105 )); 106 //var_dump($profile_res); 106 107 $profile_obj = json_decode($profile_res['body']); 107 108 … … 110 111 //make a new request to oauth 111 112 $s_url = 'https://live.sendbox.co/oauth/access/access_token/refresh?'; 112 $app_id = get_option('sendbox_app_id'); 113 $client_secret = get_option('sendbox_client_secret'); 113 //('sendbox_data')['sendbox_auth_token'] 114 $app_id = get_option('sendbox_data')['sendbox_app_id']; 115 $client_secret = get_option('sendbox_data')['sendbox_client_secret']; 114 116 $url_oauth = $s_url.'app_id='.$app_id.'&client_secret='.$client_secret; 115 $refresh_token = get_option('sendbox_ refresh_token');117 $refresh_token = get_option('sendbox_data')['sendbox_refresh_token']; 116 118 117 119 $oauth_res = wp_remote_get( $url_oauth, … … 122 124 $oauth_obj = json_decode($oauth_res['body']); 123 125 if(isset($oauth_obj->access_token)){ 124 $new_auth = $oauth_obj->access_token; 125 update_option('sendbox_auth_token', $new_auth); 126 $new_auth = $oauth_obj->access_token; 127 $sendbox_new_auth = get_option('sendbox_data'); 128 $sendbox_new_auth['sendbox_auth_token']= $new_auth; 129 update_option('sendbox_data',$sendbox_new_auth); 130 126 131 } 127 132 if(isset($oauth_obj->refresh_token)){ 128 133 $new_refresh = $oauth_obj->refresh_token; 129 update_option('sendbox_refresh_token', $new_refresh); 134 $sendbox_new_refresh = get_option('sendbox_data'); 135 $sendbox_new_refresh['sendbox_refresh_token'] = $new_refresh; 136 update_option('sendbox_data', $sendbox_new_refresh); 130 137 } 131 138 … … 133 140 134 141 else{ 135 $api_key = get_option('sendbox_ auth_token');142 $api_key = get_option('sendbox_data')['sendbox_auth_token']; 136 143 } 137 144 -
sendbox-shipping/trunk/includes/class-wooss-shipping-method.php
r2341519 r2430827 116 116 117 117 //$auth_header = get_option('wooss_basic_auth'); 118 $auth_header = $api_call->checkAuth();118 $auth_header = Wooss_Sendbox_Shipping_API::checkAuth(); 119 119 120 120 if (!$auth_header){ … … 124 124 $origin_country = "Nigeria";//get_option('wooss_country'); 125 125 126 $origin_state = get_option(' wooss_states_selected');127 128 $origin_street = get_option(' wooss_store_address');129 130 $origin_city = get_option(' wooss_city');131 132 $incoming_option_code = get_option(' wooss_pickup_type');126 $origin_state = get_option('sendbox_data')['wooss_state_dropdown']; 127 128 $origin_street = get_option('sendbox_data')['wooss_street']; 129 130 $origin_city = get_option('sendbox_data')['wooss_city']; 131 132 $incoming_option_code = get_option('sendbox_data')['wooss_pickup_type']; 133 133 134 134 $profile_url = $api_call->get_sendbox_api_url('profile'); … … 141 141 $response_code_from_profile_api = $api_call->get_api_response_code($profile_url, $profile_args, 'GET'); 142 142 $response_body_from_profile_api = $api_call->get_api_response_body($profile_url, $profile_args, 'GET'); 143 144 143 if (200 === $response_code_from_profile_api) { 145 144 $origin_name = $response_body_from_profile_api->name; … … 213 212 ); 214 213 215 214 //var_dump($payload_array_data); 216 215 $delivery_quotes_details = wooss_calculate_shipping($api_call,$payload_array_data,$auth_header); 217 216 218 //var_dump($delivery_quotes_details);217 // var_dump($delivery_quotes_details); 219 218 //die(); 220 $wooss_rates_type = get_option(' wooss_rates_type');219 $wooss_rates_type = get_option('sendbox_data')['wooss_rates_type']; 221 220 if ("maximum" == $wooss_rates_type && isset($delivery_quotes_details->max_quoted_fee) ) { 222 221 $quotes_fee = $delivery_quotes_details->max_quoted_fee; … … 287 286 function wooss_form_fields() 288 287 { 288 $sendbox_auth_header = Wooss_Sendbox_Shipping_API::checkAuth(); 289 289 $shipping_methods_enabled = get_option('wooss_option_enable'); 290 290 if (isset($_GET['tab']) && $_GET['tab'] == 'shipping' && isset($_GET['section']) && $_GET['section'] == 'wooss' && $shipping_methods_enabled == 'yes') { 291 291 $api_call = new Wooss_Sendbox_Shipping_API(); 292 292 //$auth_header = esc_attr(get_option('wooss_basic_auth')); 293 $auth_header = esc_attr(get_option('sendbox_auth_token')); 293 //$auth_header = esc_attr(get_option('sendbox_data')['sendbox_auth_token']); 294 $auth_header = $sendbox_auth_header; 294 295 $args = array( 295 296 'headers' => array( … … 311 312 $wc_city = get_option('woocommerce_store_city'); 312 313 $wc_store_address = get_option('woocommerce_store_address'); 313 $wooss_city = get_option(' wooss_city');314 $wooss_city = get_option('sendbox_data')['wooss_city']; 314 315 $wooss_store_address = get_option('wooss_store_address'); 315 $wooss_basic_auth = get_option('wooss_basic_auth');316 $wc_extra_fees = (int) get_option(' wooss_extra_fees');316 //$wooss_basic_auth = get_option('wooss_basic_auth'); 317 $wc_extra_fees = (int) get_option('sendbox_data')['wooss_extra_fees']; 317 318 318 319 if (null == $wooss_city) { … … 331 332 } 332 333 //$wooss_connection_status = get_option('wooss_basic_auth'); 333 $wooss_connection_status = get_option('sendbox_auth_token'); 334 $custom_styles = ''; 334 $wooss_connection_status =get_option('sendbox_data')['sendbox_auth_token']; 335 //var_dump(); 336 $custom_styles = ''; 337 335 338 if (null != $wooss_connection_status) { 336 339 $custom_styles = 'display:none'; 337 340 } 338 $wooss_display_fields = get_option('wooss_connexion_status'); 341 //var_dump($custom_styles); 342 $wooss_display_fields = get_option('wooss_connection_status'); 343 //var_dump($wooss_display_fields); 339 344 if ( $wooss_display_fields) { 340 345 $display_fields = 'display : inline'; 341 346 $hide_button = 'display : none'; 342 347 } 343 $wooss_pickup_type = get_option(' wooss_pickup_type');348 $wooss_pickup_type = get_option('sendbox_data')['wooss_pickup_type']; 344 349 if (null == $wooss_pickup_type) { 345 350 $wooss_pickup_type = 'pickup'; … … 350 355 } 351 356 352 $wooss_rates_type = get_option(' wooss_rates_type');357 $wooss_rates_type = get_option('sendbox_data')['wooss_rates_type']; 353 358 if (null == $wooss_rates_type) { 354 359 $wooss_rates_type = 'maximum'; … … 356 361 $wooss_rate_type = array("maximum", "minimum"); 357 362 358 359 360 361 362 363 364 365 366 363 $wooss_pickup_types = array('pickup', 'drop-off'); 367 364 $nigeria_states = $api_call->get_nigeria_states(); 368 365 369 366 367 //var_dump($wooss_display_fields); 370 368 ?> 371 369 … … 374 372 375 373 <!-- <strong><label for="wooss_basic_auth"><?php //esc_attr_e('API KEY :', 'wooss'); ?> </label><input type="text" class="wooss-text" placeholder="Basic X0000X0000000000AH" name="wooss_basic_auth" value="<?php //esc_attr_e($wooss_basic_auth, 'wooss'); ?>"></strong> <br /> --> 376 <div style="<?php esc_attr_e($custom_styles); ?>">377 <strong><label for="sendbox_auth_token"><?php esc_attr_e('Access Token :', 'wooss'); ?> </label><input type="text" class="wooss-text" placeholder="Enter Your Access Token" name=" sendbox_auth_token" value="<?php esc_attr_e($sendbox_auth_token, 'wooss'); ?>"></strong> <br />378 <strong><label for="sendbox_refresh_token"><?php esc_attr_e('Refresh Token :', 'wooss'); ?> </label><input type="text" class="wooss-text" placeholder="Enter Your Refresh Token" name=" sendbox_auth_token" value="<?php esc_attr_e($sendbox_refresh_token, 'wooss'); ?>"></strong> <br />379 <strong><label for="sendbox_app_id"><?php esc_attr_e('App ID :', 'wooss'); ?> </label><input type="text" class="wooss-text" placeholder="Enter Your App ID" name=" sendbox_app_id" value="<?php esc_attr_e($sendbox_app_id, 'wooss'); ?>"></strong> <br />380 <strong><label for="sendbox_client_secret"><?php esc_attr_e('Client Secret :', 'wooss'); ?> </label><input type="text" class="wooss-text" placeholder="Enter Your Client Secret" name=" sendbox_app_id" value="<?php esc_attr_e($sendbox_client_secret, 'wooss'); ?>"></strong> <br />374 <div style="<?php esc_attr_e($custom_styles);?>"> 375 <strong><label for="sendbox_auth_token"><?php esc_attr_e('Access Token :', 'wooss'); ?> </label><input type="text" class="wooss-text" placeholder="Enter Your Access Token" name="wooss[sendbox_auth_token]" value="<?php esc_attr_e($sendbox_auth_token, 'wooss'); ?>"></strong> <br /> 376 <strong><label for="sendbox_refresh_token"><?php esc_attr_e('Refresh Token :', 'wooss'); ?> </label><input type="text" class="wooss-text" placeholder="Enter Your Refresh Token" name="wooss[sendbox_refresh_token]" value="<?php esc_attr_e($sendbox_refresh_token, 'wooss'); ?>"></strong> <br /> 377 <strong><label for="sendbox_app_id"><?php esc_attr_e('App ID :', 'wooss'); ?> </label><input type="text" class="wooss-text" placeholder="Enter Your App ID" name="wooss[sendbox_app_id]" value="<?php esc_attr_e($sendbox_app_id, 'wooss'); ?>"></strong> <br /> 378 <strong><label for="sendbox_client_secret"><?php esc_attr_e('Client Secret :', 'wooss'); ?> </label><input type="text" class="wooss-text" placeholder="Enter Your Client Secret" name="wooss[sendbox_client_secret]" value="<?php esc_attr_e($sendbox_client_secret, 'wooss'); ?>"></strong> <br /> 381 379 <button type="submit" class="button-primary wooss-connect-sendbox wooss_fields"><?php esc_attr_e('Connect to Sendbox', 'wooss'); ?></button><br /> 382 380 … … 390 388 </td> 391 389 <td> 392 <input readonly type="text" class="wooss-text" placeholder="John Doe" name="wooss _username" id="wooss_username" value="<?php esc_attr_e($wooss_username, 'wooss'); ?>" required>390 <input readonly type="text" class="wooss-text" placeholder="John Doe" name="wooss[wooss_username]" id="wooss_username" value="<?php esc_attr_e($wooss_username, 'wooss'); ?>" required> 393 391 </td> 394 392 </tr> … … 400 398 </td> 401 399 <td> 402 <input readonly type="tel" class="wooss-text" placeholder="+2340000000000" id="wooss_tel" name="wooss _tel" value="<?php esc_attr_e($wooss_tel, 'wooss'); ?>" required>400 <input readonly type="tel" class="wooss-text" placeholder="+2340000000000" id="wooss_tel" name="wooss[wooss_tel]" value="<?php esc_attr_e($wooss_tel, 'wooss'); ?>" required> 403 401 </td> 404 402 </tr> … … 409 407 </td> 410 408 <td> 411 <input readonly type="email" class="wooss-text" placeholder="johndoe@gmail.com" id="wooss_email" name="wooss _email" value="<?php esc_attr_e($wooss_email, 'wooss'); ?>" required>409 <input readonly type="email" class="wooss-text" placeholder="johndoe@gmail.com" id="wooss_email" name="wooss[wooss_email]" value="<?php esc_attr_e($wooss_email, 'wooss'); ?>" required> 412 410 </td> 413 411 </tr> … … 429 427 </td> 430 428 <td> 431 <input type="text" class="wooss-text" name="wooss _city" value="<?php echo esc_attr_e($wc_city); ?>">429 <input type="text" class="wooss-text" name="wooss[wooss_city]" value="<?php echo esc_attr_e($wc_city); ?>"> 432 430 </td> 433 431 </tr> … … 440 438 <td> 441 439 <?php 442 echo "<select class='wooss_state_dropdown wooss_fields wooss_selected' name='wooss _state_dropdown'>";440 echo "<select class='wooss_state_dropdown wooss_fields wooss_selected' name='wooss[wooss_state_dropdown]'>"; 443 441 foreach ($nigeria_states as $state) { 444 442 $states_selected = (preg_match("/$wooss_states_selected/", $state) == true) ? 'selected="selected"' : ''; … … 456 454 <td> 457 455 <?php 458 echo "<select class='wooss_pickup_type wooss_fields wooss_selected' name='wooss _pickup_type'>";456 echo "<select class='wooss_pickup_type wooss_fields wooss_selected' name='wooss[wooss_pickup_type]'>"; 459 457 foreach ($wooss_pickup_types as $pickup_types) { 460 458 $types_selected = (preg_match("/$wooss_pickup_type/", $pickup_types) == true) ? 'selected="selected"' : ''; … … 472 470 <td> 473 471 <?php 474 echo "<select class='wooss_rates_type wooss_fields wooss_selected' name='wooss _rates_type'>";472 echo "<select class='wooss_rates_type wooss_fields wooss_selected' name='wooss[wooss_rates_type]'>"; 475 473 476 474 foreach ($wooss_rate_type as $rates_type) { … … 488 486 </td> 489 487 <td> 490 <input type="text" size="100" class="wooss-text" name="wooss _street" value="<?php esc_attr_e($wc_store_address); ?>">488 <input type="text" size="100" class="wooss-text" name="wooss[wooss_street]" value="<?php esc_attr_e($wc_store_address); ?>"> 491 489 </td> 492 490 </tr> … … 497 495 </td> 498 496 <td> 499 <input class="wooss-text" type="number" id="wooss_extra_fees" name="wooss _extra_fees" value="<?php esc_attr_e($wc_extra_fees); ?>">497 <input class="wooss-text" type="number" id="wooss_extra_fees" name="wooss[wooss_extra_fees]" value="<?php esc_attr_e($wc_extra_fees); ?>"> 500 498 </td> 501 499 </tr> … … 520 518 function connect_to_sendbox() 521 519 { 520 //var_dump($_POST); 522 521 $response_code = 0; 523 522 if (isset($_POST['data'])) { … … 525 524 //$wooss_basic_auth = $data['wooss_basic_auth']; 526 525 $sendbox_auth_token = $data['sendbox_auth_token']; 527 $sendbox_refresh_token = $data['sendbox_refresh_token'];528 $sendbox_client_secret = $data['sendbox_client_secret'];529 $sendbox_app_id = $data['sendbox_app_id'];526 //$sendbox_refresh_token = $data['sendbox_refresh_token']; 527 //$sendbox_client_secret = $data['sendbox_client_secret']; 528 //$sendbox_app_id = $data['sendbox_app_id']; 530 529 531 530 $api_call = new Wooss_Sendbox_Shipping_API(); … … 538 537 ), 539 538 ); 540 $response_code_from_api = $api_call->get_api_response_code($api_url, $args, 'GET'); 539 $response_code_from_api = $api_call->get_api_response_code($api_url, $args, 'GET'); 540 //$response_body_from_profile_api = $api_call->get_api_response_body($api_url, $args, 'GET'); 541 //var_dump($response_body_from_profile_api); 541 542 if (200 === $response_code_from_api) { 542 543 $response_code = 1; 543 update_option('wooss_connexion_status', $response_code); 544 //update_option('wooss_connexion_status', $response_code); 545 update_option('wooss_connection_status', $response_code); 546 update_option('sendbox_data', $data); 544 547 //update_option('wooss_basic_auth', $wooss_basic_auth); 545 update_option('sendbox_auth_token', $sendbox_auth_token);546 update_option('sendbox_refresh_token', $sendbox_refresh_token);547 update_option('sendbox_app_id', $sendbox_app_id);548 update_option('sendbox_client_secret', $sendbox_client_secret);548 //update_option('sendbox_auth_token', $sendbox_auth_token); 549 //update_option('sendbox_refresh_token', $sendbox_refresh_token); 550 //update_option('sendbox_app_id', $sendbox_app_id); 551 //update_option('sendbox_client_secret', $sendbox_client_secret); 549 552 550 553 } … … 565 568 if (isset($_POST['data']) && wp_verify_nonce($_POST['security'], 'wooss-ajax-security-nonce')) { 566 569 $data = wp_unslash($_POST['data']); 567 $wooss_country = sanitize_text_field($data['wooss_country']); 568 $wooss_state = sanitize_text_field($data['wooss_state_name']); 569 $wooss_city = sanitize_text_field($data['wooss_city']); 570 $wooss_street = sanitize_text_field($data['wooss_street']); 571 //$wooss_basic_auth = sanitize_text_field($data['wooss_basic_auth']); 572 $sendbox_auth_token = sanitize_text_field($data['sendbox_auth_token']); 573 $sendbox_refresh_token = sanitize_text_field($data['sendbox_refresh_token']); 574 $sendbox_client_secret = sanitize_text_field($data['sendbox_client_secret']); 575 $sendbox_app_id = sanitize_text_field($data['sendbox_app_id']); 576 577 $wooss_pickup_type = sanitize_text_field($data['wooss_pickup_type']); 578 $wooss_extra_fees = sanitize_text_field($data['wooss_extra_fees']); 579 $wooss_rates_type = sanitize_text_field($data['wooss_rates_type']); 580 581 if (isset($wooss_city)) { 582 update_option('wooss_city', $wooss_city); 583 $operation_success = 1; 584 } 585 if (isset($wooss_extra_fees)) { 586 update_option('wooss_extra_fees', $wooss_extra_fees); 587 $operation_success = 1; 588 } 589 if (isset($wooss_country)) { 590 update_option('wooss_country', $wooss_country); 591 $operation_success = 1; 592 } 593 if (isset($wooss_state)) { 594 update_option('wooss_states_selected', $wooss_state); 595 $operation_success = 1; 596 } 597 if (isset($wooss_street)) { 598 update_option('wooss_store_address', $wooss_street); 599 $operation_success = 1; 600 } 601 /* if (isset($wooss_basic_auth)) { 602 update_option('wooss_basic_auth', $wooss_basic_auth); 603 $operation_success = 1; 604 } */ 605 606 if (isset($sendbox_auth_token)) { 607 update_option('sendbox_auth_token', $sendbox_auth_token); 608 $operation_success = 1; 609 } 610 611 if (isset($sendbox_refresh_token)) { 612 update_option('sendbox_refresh_token', $sendbox_refresh_token); 613 $operation_success = 1; 614 } 615 616 if (isset($sendbox_client_secret)) { 617 update_option('sendbox_client_secret', $sendbox_client_secret); 618 $operation_success = 1; 619 } 620 621 if (isset($sendbox_app_id)) { 622 update_option('sendbox_app_id', $sendbox_app_id); 623 $operation_success = 1; 624 } 625 626 if (isset($wooss_pickup_type)) { 627 update_option('wooss_pickup_type', $wooss_pickup_type); 628 $operation_success = 1; 629 } 630 631 632 if (isset($wooss_rates_type)) { 633 update_option('wooss_rates_type', $wooss_rates_type); 634 $operation_success = 1; 635 } 636 update_option('wooss_display_fields', $operation_success); 637 } 570 $sendbox_data = get_option("sendbox_data"); 571 $new_sendbox_data = array_merge($sendbox_data, $data); 572 update_option('sendbox_data', $new_sendbox_data); 573 574 575 } 576 638 577 esc_attr_e($operation_success); 639 578 wp_die(); -
sendbox-shipping/trunk/wooss.php
r2341519 r2430827 35 35 * Rename this for your plugin and update it as you release new versions. 36 36 */ 37 define('WOOSS_VERSION', '3.2. 1');37 define('WOOSS_VERSION', '3.2.2'); 38 38 39 39 /**
Note: See TracChangeset
for help on using the changeset viewer.