Plugin Directory

Changeset 3255617


Ignore:
Timestamp:
03/13/2025 09:25:56 PM (13 months ago)
Author:
sendbox
Message:

updated 5.1

Location:
sendbox-shipping
Files:
46 added
3 edited

Legend:

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

    r3217295 r3255617  
    11=== Sendbox-Shipping ===
    2 Contributors: Sendbox, Adejoke Haastrup, jastrup
     2Contributors: Sendbox, jastrup
    33Donate link: #
    44Tags: shipping, shipping zones, local shipping, international shipping
    55Requires at least:  6.5.4
    66Tested up to:  6.7
    7 Stable tag: 5.0
     7Stable tag: 5.1
    88Requires PHP: 8.0
    99License: GPLv2 or later
  • sendbox-shipping/trunk/includes/class-wooss-shipping-method.php

    r3157691 r3255617  
    220220                    );
    221221
    222                     $delivery_quotes_details = wooss_calculate_shipping( $api_call, $payload_array_data, $auth_header );
    223                
    224                
    225 
    226                     /* $wooss_rates_type = $sendbox_data['wooss_rates_type'];
    227                     if ( 'maximum' == $wooss_rates_type && isset( $delivery_quotes_details->max_quoted_fee ) ) {
    228                         $quotes_fee = $delivery_quotes_details->max_quoted_fee;
    229                     } elseif ( 'minimum' == $wooss_rates_type && isset( $delivery_quotes_details->min_quoted_fee ) ) {
    230                         $quotes_fee = $delivery_quotes_details->min_quoted_fee;
    231                     }
    232                     */
    233 
    234                 //updating based on the sendbox new change to pass service code response change now returns rate.fee September 25th 2024
    235 
    236                 $wooss_rates_type = $sendbox_data['wooss_rates_type'];
    237                 if ( 'maximum' == $wooss_rates_type && isset( $delivery_quotes_details->rate) ) {
    238                     $quotes_fee = $delivery_quotes_details->rate->fee;
    239                 } elseif ( 'minimum' == $wooss_rates_type && isset( $delivery_quotes_details->rate ) ) {
    240                     $quotes_fee = $delivery_quotes_details->rate->fee;
    241                 }
    242 
    243 
    244 
    245                     $quoted_fee = $quotes_fee + $wooss_extra_fees;
    246                    
    247 
    248                     /*
    249                      $destination_country = "United States of America";
    250                     $destination_state = "Washington";
    251                     $destination_city = "New York";
    252                     $destination_postcode = "10001"; */
    253                     $payload_array_data['destination_country'] = $destination_country;
    254                     $payload_array_data['destination_state']   = $destination_state;
    255                     $payload_array_data['destination_city']    = $destination_city;
    256                     $payload_array_data['currency'] = $currency;
    257 
    258                     /* if ( (int)$quoted_fee == 0 ) {
    259                         $delivery_quotes_details = wooss_calculate_shipping( $api_call, $payload_array_data, $auth_header );
    260                         if ( 'maximum' == $wooss_rates_type && isset( $delivery_quotes_details->max_quoted_fee ) ) {
    261                             $quotes_fee = $delivery_quotes_details->max_quoted_fee;
    262                         } elseif ( 'minimum' == $wooss_rates_type && isset( $delivery_quotes_details->min_quoted_fee ) ) {
    263                             $quotes_fee = $delivery_quotes_details->min_quoted_fee;
    264                         }
    265 
    266                         $quoted_fee = $quotes_fee + $wooss_extra_fees;
    267                     } */
    268 
    269 
    270                        
    271                     //updating based on the sendbox new change to pass service code response now returns rate.fee September 25th 2024
    272 
    273                    
    274                     if ( (int)$quoted_fee == 0 ) {
    275                         $delivery_quotes_details = wooss_calculate_shipping( $api_call, $payload_array_data, $auth_header );
    276                         if ( 'maximum' == $wooss_rates_type && isset( $delivery_quotes_details->rate ) ) {
    277                             $quotes_fee = $delivery_quotes_details->rate->fee;
    278                         } elseif ( 'minimum' == $wooss_rates_type && isset( $delivery_quotes_details->rate ) ) {
    279                             $quotes_fee = $delivery_quotes_details->rate->fee;
    280                         }
    281 
    282                         $quoted_fee = $quotes_fee + $wooss_extra_fees;
    283                     }
    284 
    285                     $new_rate = array(
    286                         'id'      => $this->id,
    287                         'label'   => $this->title,
    288                         'cost'    => $quoted_fee,
    289                         'package' => $package,
    290                     );
    291 
    292                     $this->add_rate( $new_rate );
    293                 }
     222$delivery_quotes_details = wooss_calculate_shipping( $api_call, $payload_array_data, $auth_header );
     223
     224// Check if rates is set and is an array
     225if ( isset( $delivery_quotes_details->rates ) && is_array( $delivery_quotes_details->rates ) ) {
     226
     227    // Loop through each rate option and add it as a shipping rate
     228    foreach ( $delivery_quotes_details->rates as $rate ) {
     229        // Calculate the total fee with any extra fees
     230        $quoted_fee = $rate->fee + $wooss_extra_fees;
     231
     232        // Build the label. For example, you can append the service code or name if available.
     233        // Adjust the label formatting as needed.
     234        $label = $this->title;
     235        if ( isset( $rate->service_code ) && !empty( $rate->service_code ) ) {
     236            $label .= ' - ' . $rate->service_code;
     237        } elseif ( isset( $rate->service_name ) && !empty( $rate->service_name ) ) {
     238            $label .= ' - ' . $rate->service_name;
     239        }
     240
     241        $new_rate = array(
     242            'id'      => $this->id,
     243            'label'   => $label,
     244            'cost'    => $quoted_fee,
     245            'package' => $package,
     246        );
     247
     248        $this->add_rate( $new_rate );
     249    }
     250
     251} else {
     252    // Fallback in case the API response doesn't contain a rates array
     253    $wooss_rates_type = $sendbox_data['wooss_rates_type'];
     254    if ( 'maximum' == $wooss_rates_type && isset( $delivery_quotes_details->rate ) ) {
     255        $quotes_fee = $delivery_quotes_details->rate->fee;
     256    } elseif ( 'minimum' == $wooss_rates_type && isset( $delivery_quotes_details->rate ) ) {
     257        $quotes_fee = $delivery_quotes_details->rate->fee;
     258    }
     259    $quoted_fee = $quotes_fee + $wooss_extra_fees;
     260
     261    $new_rate = array(
     262        'id'      => $this->id,
     263        'label'   => $this->title,
     264        'cost'    => $quoted_fee,
     265        'package' => $package,
     266    );
     267
     268    $this->add_rate( $new_rate );
     269}               }
    294270            }
    295271        }
  • sendbox-shipping/trunk/wooss.php

    r3217295 r3255617  
    1616 * Plugin URI:        #
    1717 * Description:       A Sendbox WooCommerce shipping plugin that enables you ship from your store to anywhere in the world.
    18  * Version:           5.0
     18 * Version:           5.1
    1919 * Author:            sendbox
    2020 * Author URI:        https://sendbox.ng/
     
    3535 * Rename this for your plugin and update it as you release new versions.
    3636 */
    37 define('WOOSS_VERSION', '5.0');
     37define('WOOSS_VERSION', '5.1');
    3838
    3939/**
Note: See TracChangeset for help on using the changeset viewer.