Plugin Directory

Changeset 3347015


Ignore:
Timestamp:
08/19/2025 12:45:13 PM (8 months ago)
Author:
sendbox
Message:

update

Location:
sendbox-shipping
Files:
46 added
3 edited

Legend:

Unmodified
Added
Removed
  • sendbox-shipping/tags/5.2/includes/class-wooss-sendbox-shipping-api.php

    r3255662 r3347015  
    9898        $api_key         = $sendbox_data_db['sendbox_auth_token'];
    9999        $profile_url     = 'https://live.sendbox.co/oauth/profile';
    100 
    101         $profile_res = wp_remote_get(
    102             $profile_url,
    103             array(
    104                 'timeout' => 40,
    105                 'headers' => array(
    106                     'Content-Type'  => 'application/json',
    107                     'Authorization' => $api_key,
    108                 ),
    109             )
    110         );
    111         //var_dump($sendbox_data_db);
    112         $class_name  = 'WP_Error';
    113         if ( ! ( $profile_res instanceof $class_name ) && isset( $profile_res['body'] )  ) {
    114             $profile_obj = json_decode( $profile_res['body'] );
    115         } else {
    116             $profile_obj = null;
    117         }
    118 
    119         if ( isset( $profile_obj->title ) ) {
    120 
    121             $s_url         = 'https://live.sendbox.co/oauth/access/access_token/refresh?';
    122             $app_id        = $sendbox_data_db['sendbox_app_id'];
    123             $client_secret = $sendbox_data_db['sendbox_client_secret'];
    124             $url_oauth     = $s_url . 'app_id=' . $app_id . '&client_secret=' . $client_secret;
    125             $refresh_token = $sendbox_data_db['sendbox_refresh_token'];
    126 
    127             $oauth_res = wp_remote_get(
    128                 $url_oauth,
    129                 array(
    130                     'timeout' => 10,
    131                     'headers' => array(
    132                         'Content-Type'  => 'application/json',
    133                         'Refresh-Token' => $refresh_token,
    134                     ),
    135                 )
    136             );
    137             $oauth_obj = json_decode( $oauth_res['body'] );
    138             if ( ! ( $oauth_res instanceof $class_name ) && ! isset( $oauth_res['body'] ) ) {
    139                 return $api_key;
    140             }
    141 
    142             if ( isset( $oauth_obj->access_token ) ) {
    143                 $new_auth                              = $oauth_obj->access_token;
    144                 $sendbox_data_db['sendbox_auth_token'] = $new_auth;
    145                 update_option( 'sendbox_data', $sendbox_data_db );
    146 
    147             }
    148             if ( isset( $oauth_obj->refresh_token ) ) {
    149                 $new_refresh                              = $oauth_obj->refresh_token;
    150                 $sendbox_data_db['sendbox_refresh_token'] = $new_refresh;
    151                 update_option( 'sendbox_data', $sendbox_data_db );
    152             }
    153         }
    154 
    155100        return $api_key;
    156 
    157101    }
    158102
  • sendbox-shipping/tags/5.2/includes/class-wooss-shipping-method.php

    r3255662 r3347015  
    9696                    $output->value             = round( $values['line_total'] );
    9797                    $output->amount_to_receive = round( $values['line_total'] );
    98                     $output->item_type         = $values['data']->get_categories();
     98                    $output->item_type = "other";
    9999                    $items_lists[]             = $output;
    100100                }
    101101
     102                // var_dump($items_lists);
    102103                // Retrieve sendbox settings and API authentication
    103104                $sendbox_data     = get_option( 'sendbox_data' );
     
    186187
    187188                        // Build label with optional service details
    188                         $label = $this->title;
    189                         if ( ! empty( $rate->service_code ) ) {
    190                             $label .= ' - ' . $rate->service_code;
    191                         } elseif ( ! empty( $rate->description ) ) {
    192                             $label .= ' - ' . $rate->description;
    193                         }
    194 
     189                        $label = $rate->name;
    195190                        // Create a unique rate ID (append index or service code)
    196191                        $rate_id = $this->id . '_' . $index;
     
    214209                    $this->add_rate( $new_rate );
    215210                } else {
     211                        error_log( 'Sendbox API Key: ' . $api_key );
     212                        var_dump("some ssusuus");
    216213                    wc_add_notice( __( 'No shipping rates available.', 'wooss' ), 'error' );
    217214                }
     
    340337        $states_data_obj = wp_remote_get( $states_api_url, $args );
    341338        $states_body = json_decode( wp_remote_retrieve_body( $states_data_obj ));
    342        
    343    
    344        
     339
     340
     341
    345342        //$nigeria_states= $api_call->get_nigeria_states();
    346343
     
    437434                                    }
    438435
    439                                    
     436
    440437                                }
    441                                  
     438
    442439                            }
    443440                            echo '</select>';
     
    506503
    507504            </div>
    508            
     505
    509506            <span class="wooss_errors_pages wooss_fields"></span>
    510507        </div>
     
    605602
    606603
     604            case 'items_list':
     605                $payload_data->items = $value;
     606                break;
     607
    607608            case 'weight':
    608609                $payload_data->weight = $value;
  • sendbox-shipping/trunk/includes/class-wooss-shipping-method.php

    r3255662 r3347015  
    9696                    $output->value             = round( $values['line_total'] );
    9797                    $output->amount_to_receive = round( $values['line_total'] );
    98                     $output->item_type         = $values['data']->get_categories();
     98                    $output->item_type = "other";
    9999                    $items_lists[]             = $output;
    100100                }
    101101
     102                // var_dump($items_lists);
    102103                // Retrieve sendbox settings and API authentication
    103104                $sendbox_data     = get_option( 'sendbox_data' );
     
    186187
    187188                        // Build label with optional service details
    188                         $label = $this->title;
    189                         if ( ! empty( $rate->service_code ) ) {
    190                             $label .= ' - ' . $rate->service_code;
    191                         } elseif ( ! empty( $rate->description ) ) {
    192                             $label .= ' - ' . $rate->description;
    193                         }
    194 
     189                        $label = $rate->name;
    195190                        // Create a unique rate ID (append index or service code)
    196191                        $rate_id = $this->id . '_' . $index;
     
    214209                    $this->add_rate( $new_rate );
    215210                } else {
     211                        error_log( 'Sendbox API Key: ' . $api_key );
     212                        var_dump("some ssusuus");
    216213                    wc_add_notice( __( 'No shipping rates available.', 'wooss' ), 'error' );
    217214                }
     
    340337        $states_data_obj = wp_remote_get( $states_api_url, $args );
    341338        $states_body = json_decode( wp_remote_retrieve_body( $states_data_obj ));
    342        
    343    
    344        
     339
     340
     341
    345342        //$nigeria_states= $api_call->get_nigeria_states();
    346343
     
    437434                                    }
    438435
    439                                    
     436
    440437                                }
    441                                  
     438
    442439                            }
    443440                            echo '</select>';
     
    506503
    507504            </div>
    508            
     505
    509506            <span class="wooss_errors_pages wooss_fields"></span>
    510507        </div>
     
    605602
    606603
     604            case 'items_list':
     605                $payload_data->items = $value;
     606                break;
     607
    607608            case 'weight':
    608609                $payload_data->weight = $value;
Note: See TracChangeset for help on using the changeset viewer.