Plugin Directory

Changeset 2430827


Ignore:
Timestamp:
12/03/2020 10:51:04 AM (5 years ago)
Author:
sendbox
Message:

new version 3.2.2 updated JS to use jqueryserilize

Location:
sendbox-shipping/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • sendbox-shipping/trunk/README.txt

    r2341519 r2430827  
    5959
    6060
    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
     63settings on you sendbox dashboard, scroll and find your API Key.</p>
    6764
    6865<h3>How do i use the API Key? </h3>
     
    7875<h3>Documentation</h3>
    7976<b> You can find documentaiton for this plugin by
    80 clicking <a href = "https://docs.sendbox.co/third-party-intergations/woo-commerce-plugin">Here</a> </b>
     77clicking <a href = "http://bit.ly/sendbox-shipping-docs">Here</a> </b>
    8178
    8279
     
    110107
    111108<b>3.1.0</b>
    112 <p>fixed some bugs with the javascript</p>
     109<p>fixed some bugs with the javascript</p> 
    113110
    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>
    119113
    120114
  • sendbox-shipping/trunk/admin/class-wooss-admin.php

    r2341519 r2430827  
    108108        );
    109109
    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);
    111112        wp_localize_script(
    112113            'wooss_shipping_method_js_script',
     
    237238            $api_call                   = new Wooss_Sendbox_Shipping_API();
    238239            //$auth_header                = get_option('wooss_basic_auth');
    239             $auth_header = $api_call->checkAuth();
     240            $auth_header = Wooss_Sendbox_Shipping_API::checkAuth();
    240241            $args                       = array(
    241242                'headers' => array(
     
    257258            $wc_city             = get_option('woocommerce_store_city');
    258259            $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'];
    261262            if (null == $wooss_origin_city) {
    262263                $wooss_origin_city = $wc_city;
     
    265266                $wooss_origin_street = $wc_store_address;
    266267            }
    267             $wooss_origin_states_selected = get_option('wooss_states_selected');
     268            $wooss_origin_states_selected = get_option('sendbox_data')['wooss_state_dropdown'];
    268269            if (null == $wooss_origin_states_selected) {
    269270                $wooss_origin_states_selected = '';
     
    274275            }
    275276
    276             $wooss_pickup_type = get_option('wooss_pickup_type');
     277            $wooss_pickup_type = get_option('sendbox_data')['wooss_pickup_type'];
    277278            if (null == $wooss_pickup_type) {
    278279                $wooss_pickup_type = 'pickup';
    279280            }
    280281
    281             $incoming_option_code = get_option('wooss_pickup_type');
     282            $incoming_option_code = get_option('sendbox_data')['wooss_pickup_type'];
    282283            if (null == $incoming_option_code) {
    283284                return;
     
    378379                    $payload_data                         = new stdClass();
    379380                    $payload_data->origin_name      = $wooss_origin_name;
    380                     $payload_data->destination_country    = $destination_country;
     381                    //$payload_data->destination_country    = $destination_country;
    381382                    $payload_data->destination_country_code = $destination_country;
    382383                    //$payload_data->destination_state_code = ' ';
     
    399400                    $payload_data->incoming_option_code  = $incoming_option_code;
    400401                    $payload_data->payment_option_code   = 'prepaid';
    401                     //$payload_data->deliver_type_code     = 'last_mile';
     402                    //$payload_data->deliver_type_code     = 'last_mile';
     403                   
    402404
    403405                    $payload_data_json = wp_json_encode($payload_data);
     
    410412                   
    411413                    );
    412                     //print_r($delivery_args);
     414                    //print_r($payload_data_json);
    413415                   
    414416                       
     
    661663                $payload_data = new stdClass();
    662664
    663                 $payload_data->selected_courier_id = $courier_selected;
     665                //$payload_data->selected_courier_id = $courier_selected;
    664666
    665667                $payload_data->destination_name    = $destination_name;
     
    689691
    690692                $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               
    692697
    693698                $api_call    = new Wooss_Sendbox_Shipping_API();
    694699                //$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); 
    698703
    699704                $shipments_args = array(
  • sendbox-shipping/trunk/admin/js/wooss-admin.js

    r2335894 r2430827  
    7474     /*  var wooss_destination_country = $(
    7575        "input[name = 'wooss_destination_country']"
    76       ).val(); 
     76      ).val();
    7777      var wooss_destination_state = $(
    7878        "input[name = 'wooss_destination_state']"
     
    9898      var wooss_destination_state = $("select#wooss_destination_state").val();
    9999      $("select#wooss_destination_state").change(function(){
    100           wooss_destination_state = $(this).val();
     100          wooss_destination_state = $(this).val()
    101101      })
    102102     
     
    130130        wooss_order_id: wooss_order_id
    131131      };
     132      //console.log(wooss_destination_state);
    132133
    133134      $.post(
  • sendbox-shipping/trunk/includes/assets/js/script.js

    r2341519 r2430827  
    5454      var sendbox_refresh_token;
    5555      var sendbox_app_id;
    56       var sendbox_client_secret;
     56      var sendbox_client_secret; 
    5757      var wooss_connect_btn = $("button.wooss-connect-sendbox");
    5858      var wooss_errors_message_span = $("span.wooss_errors_pages");
     
    6363
    6464      wooss_connect_btn.on("click", function (e) {
    65         e.preventDefault();
     65        e.preventDefault();
     66        var formDetails = $('form').serializeJSON();
     67      console.log(formDetails.wooss);
    6668        //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)
    6973        sendbox_app_id = $("input[name='sendbox_app_id']").val();
    7074        sendbox_client_secret = $("input[name='sendbox_client_secret']").val();
    71 
     75 */
    7276        function reloadPage() {
    7377          window.location.reload();
    7478        }
    7579        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
    8383        $.post(
    8484          wooss_ajax_object.wooss_ajax_url,
  • sendbox-shipping/trunk/includes/class-wooss-sendbox-shipping-api.php

    r2341519 r2430827  
    9494 */
    9595
    96 public function checkAuth(){
     96public static function checkAuth(){
    9797
    98     $api_key = get_option('sendbox_auth_token');
     98    $api_key = get_option('sendbox_data')['sendbox_auth_token'];
    9999    $profile_url = "https://live.sendbox.co/oauth/profile";
    100100
    101101    $profile_res = wp_remote_get( $profile_url ,
    102     array( 'timeout' => 10,
     102    array( 'timeout' => 40,
    103103   'headers' => array( 'Content-Type' => 'application/json',
    104104                      'Authorization'=> $api_key )
    105105    ));
     106    //var_dump($profile_res);
    106107    $profile_obj = json_decode($profile_res['body']);
    107108
     
    110111   //make a new request to oauth
    111112   $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'];
    114116   $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'];
    116118
    117119   $oauth_res = wp_remote_get( $url_oauth,
     
    122124    $oauth_obj = json_decode($oauth_res['body']);
    123125   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       
    126131   }
    127132   if(isset($oauth_obj->refresh_token)){
    128133       $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);
    130137   }
    131138   
     
    133140
    134141else{
    135    $api_key = get_option('sendbox_auth_token');
     142   $api_key = get_option('sendbox_data')['sendbox_auth_token'];
    136143}
    137144
  • sendbox-shipping/trunk/includes/class-wooss-shipping-method.php

    r2341519 r2430827  
    116116
    117117                    //$auth_header = get_option('wooss_basic_auth');
    118                     $auth_header = $api_call->checkAuth();
     118                    $auth_header = Wooss_Sendbox_Shipping_API::checkAuth();
    119119
    120120                    if (!$auth_header){
     
    124124                    $origin_country = "Nigeria";//get_option('wooss_country');
    125125
    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'];
    133133
    134134                    $profile_url                    = $api_call->get_sendbox_api_url('profile');
     
    141141                    $response_code_from_profile_api = $api_call->get_api_response_code($profile_url, $profile_args, 'GET');
    142142                    $response_body_from_profile_api = $api_call->get_api_response_body($profile_url, $profile_args, 'GET');
    143                    
    144143                    if (200 === $response_code_from_profile_api) {
    145144                        $origin_name  = $response_body_from_profile_api->name;
     
    213212                    );
    214213
    215                            
     214                        //var_dump($payload_array_data);   
    216215                    $delivery_quotes_details = wooss_calculate_shipping($api_call,$payload_array_data,$auth_header);
    217216                   
    218                     //var_dump($delivery_quotes_details);
     217                //  var_dump($delivery_quotes_details);
    219218                    //die();
    220                     $wooss_rates_type = get_option('wooss_rates_type');
     219                    $wooss_rates_type = get_option('sendbox_data')['wooss_rates_type'];
    221220                    if ("maximum" == $wooss_rates_type && isset($delivery_quotes_details->max_quoted_fee) ) {
    222221                        $quotes_fee = $delivery_quotes_details->max_quoted_fee;
     
    287286function wooss_form_fields()
    288287{
     288    $sendbox_auth_header = Wooss_Sendbox_Shipping_API::checkAuth();
    289289    $shipping_methods_enabled = get_option('wooss_option_enable');
    290290    if (isset($_GET['tab']) && $_GET['tab'] == 'shipping' &&  isset($_GET['section']) && $_GET['section'] == 'wooss' && $shipping_methods_enabled == 'yes') {
    291291        $api_call                   = new Wooss_Sendbox_Shipping_API();
    292292        //$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;
    294295        $args                       = array(
    295296            'headers' => array(
     
    311312        $wc_city             = get_option('woocommerce_store_city');
    312313        $wc_store_address    = get_option('woocommerce_store_address');
    313         $wooss_city          = get_option('wooss_city');
     314        $wooss_city          = get_option('sendbox_data')['wooss_city'];
    314315        $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'];
    317318
    318319        if (null == $wooss_city) {
     
    331332        }
    332333        //$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       
    335338        if (null != $wooss_connection_status) {
    336339            $custom_styles = 'display:none';
    337340        }
    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);
    339344        if ( $wooss_display_fields) {
    340345            $display_fields = 'display : inline';
    341346            $hide_button    = 'display : none';
    342347        }
    343         $wooss_pickup_type = get_option('wooss_pickup_type');
     348        $wooss_pickup_type = get_option('sendbox_data')['wooss_pickup_type'];
    344349        if (null == $wooss_pickup_type) {
    345350            $wooss_pickup_type = 'pickup';
     
    350355        }
    351356
    352         $wooss_rates_type = get_option('wooss_rates_type');
     357        $wooss_rates_type = get_option('sendbox_data')['wooss_rates_type'];
    353358        if (null == $wooss_rates_type) {
    354359            $wooss_rates_type = 'maximum';
     
    356361        $wooss_rate_type = array("maximum", "minimum");
    357362
    358 
    359 
    360 
    361 
    362 
    363 
    364 
    365 
    366363        $wooss_pickup_types = array('pickup', 'drop-off');
    367364        $nigeria_states     = $api_call->get_nigeria_states();
    368365
    369366
     367        //var_dump($wooss_display_fields);
    370368        ?>
    371369
     
    374372
    375373            <!-- <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 />
    381379            <button type="submit" class="button-primary wooss-connect-sendbox wooss_fields"><?php esc_attr_e('Connect to Sendbox', 'wooss'); ?></button><br />
    382380           
     
    390388                        </td>
    391389                        <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>
    393391                        </td>
    394392                    </tr>
     
    400398                        </td>
    401399                        <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>
    403401                        </td>
    404402                    </tr>
     
    409407                        </td>
    410408                        <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>
    412410                        </td>
    413411                    </tr>
     
    429427                        </td>
    430428                        <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); ?>">
    432430                        </td>
    433431                    </tr>
     
    440438                        <td>
    441439                            <?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]'>";
    443441                            foreach ($nigeria_states as $state) {
    444442                                $states_selected = (preg_match("/$wooss_states_selected/", $state) == true) ? 'selected="selected"' : '';
     
    456454                        <td>
    457455                            <?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]'>";
    459457                            foreach ($wooss_pickup_types as $pickup_types) {
    460458                                $types_selected = (preg_match("/$wooss_pickup_type/", $pickup_types) == true) ? 'selected="selected"' : '';
     
    472470                        <td>
    473471                            <?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]'>";
    475473
    476474                            foreach ($wooss_rate_type as $rates_type) {
     
    488486                        </td>
    489487                        <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); ?>">
    491489                        </td>
    492490                    </tr>
     
    497495                        </td>
    498496                        <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); ?>">
    500498                        </td>
    501499                    </tr>
     
    520518function connect_to_sendbox()
    521519{
     520    //var_dump($_POST);
    522521    $response_code    = 0;
    523522    if (isset($_POST['data'])) {
     
    525524        //$wooss_basic_auth = $data['wooss_basic_auth'];
    526525        $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'];
    530529
    531530        $api_call               = new Wooss_Sendbox_Shipping_API();
     
    538537            ),
    539538        );
    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);
    541542        if (200 === $response_code_from_api) {
    542543            $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);
    544547            //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);
    549552
    550553        }
     
    565568    if (isset($_POST['data']) &&  wp_verify_nonce($_POST['security'], 'wooss-ajax-security-nonce')) {
    566569        $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
    638577    esc_attr_e($operation_success);
    639578    wp_die();
  • sendbox-shipping/trunk/wooss.php

    r2341519 r2430827  
    3535 * Rename this for your plugin and update it as you release new versions.
    3636 */
    37 define('WOOSS_VERSION', '3.2.1');
     37define('WOOSS_VERSION', '3.2.2');
    3838
    3939/**
Note: See TracChangeset for help on using the changeset viewer.