Changeset 3480704
- Timestamp:
- 03/11/2026 11:02:15 PM (3 weeks ago)
- Location:
- sendbox-shipping
- Files:
-
- 17 deleted
- 8 edited
- 13 copied
-
tags/5.5.5 (copied) (copied from sendbox-shipping/trunk)
-
tags/5.5.5/README.md (copied) (copied from sendbox-shipping/trunk/README.md)
-
tags/5.5.5/README.txt (copied) (copied from sendbox-shipping/trunk/README.txt) (1 diff)
-
tags/5.5.5/admin/class-wooss-admin.php (deleted)
-
tags/5.5.5/admin/css (deleted)
-
tags/5.5.5/admin/images (deleted)
-
tags/5.5.5/admin/js (deleted)
-
tags/5.5.5/admin/partials (deleted)
-
tags/5.5.5/assets (copied) (copied from sendbox-shipping/trunk/assets)
-
tags/5.5.5/assets/js/admin-order.js (modified) (2 diffs)
-
tags/5.5.5/assets/js/admin-settings.js (copied) (copied from sendbox-shipping/trunk/assets/js/admin-settings.js)
-
tags/5.5.5/includes/assets (deleted)
-
tags/5.5.5/includes/class-wooss-activator.php (deleted)
-
tags/5.5.5/includes/class-wooss-deactivator.php (deleted)
-
tags/5.5.5/includes/class-wooss-i18n.php (deleted)
-
tags/5.5.5/includes/class-wooss-loader.php (deleted)
-
tags/5.5.5/includes/class-wooss-sendbox-shipping-api.php (deleted)
-
tags/5.5.5/includes/class-wooss-shipping-method.php (deleted)
-
tags/5.5.5/includes/class-wooss.php (deleted)
-
tags/5.5.5/public/class-wooss-public.php (deleted)
-
tags/5.5.5/public/css (deleted)
-
tags/5.5.5/public/js (deleted)
-
tags/5.5.5/public/partials (deleted)
-
tags/5.5.5/src (copied) (copied from sendbox-shipping/trunk/src)
-
tags/5.5.5/src/Admin/Ajax.php (copied) (copied from sendbox-shipping/trunk/src/Admin/Ajax.php)
-
tags/5.5.5/src/Admin/OrderMetabox.php (modified) (2 diffs)
-
tags/5.5.5/src/Admin/SettingsPage.php (copied) (copied from sendbox-shipping/trunk/src/Admin/SettingsPage.php)
-
tags/5.5.5/src/Api/Client.php (copied) (copied from sendbox-shipping/trunk/src/Api/Client.php)
-
tags/5.5.5/src/Plugin.php (copied) (copied from sendbox-shipping/trunk/src/Plugin.php)
-
tags/5.5.5/src/ShippingMethod.php (modified) (1 diff)
-
tags/5.5.5/uninstall.php (copied) (copied from sendbox-shipping/trunk/uninstall.php)
-
tags/5.5.5/wooss-reset.php (copied) (copied from sendbox-shipping/trunk/wooss-reset.php)
-
tags/5.5.5/wooss.php (copied) (copied from sendbox-shipping/trunk/wooss.php) (2 diffs)
-
trunk/README.txt (modified) (1 diff)
-
trunk/assets/js/admin-order.js (modified) (2 diffs)
-
trunk/src/Admin/OrderMetabox.php (modified) (2 diffs)
-
trunk/src/ShippingMethod.php (modified) (1 diff)
-
trunk/wooss.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sendbox-shipping/tags/5.5.5/README.txt
r3478501 r3480704 5 5 Requires at least: 6.0 6 6 Tested up to: 6.9 7 Stable tag: 5.5. 47 Stable tag: 5.5.5 8 8 Requires PHP: 7.4 9 9 License: GPLv2 or later -
sendbox-shipping/tags/5.5.5/assets/js/admin-order.js
r3478358 r3480704 12 12 13 13 // Courier selection: update fee display 14 $("#wooss_selected_courier").on("change", function () { 15 var option = this.options[this.selectedIndex]; 14 function updateCourierFee() { 15 var select = document.getElementById("wooss_selected_courier"); 16 if (!select) return; 17 var option = select.options[select.selectedIndex]; 16 18 var price = option ? option.getAttribute("data-courier-price") : ""; 17 19 var feeEl = document.getElementById("dabs"); … … 20 22 feeEl.style.color = "#ed2f59"; 21 23 } 22 }); 24 } 25 26 // Show fee on load if a courier is pre-selected 27 updateCourierFee(); 28 29 $("#wooss_selected_courier").on("change", updateCourierFee); 23 30 24 31 // Country dropdown change: load states -
sendbox-shipping/tags/5.5.5/src/Admin/OrderMetabox.php
r3478358 r3480704 156 156 } 157 157 158 // Get the rate code the customer selected at checkout. 159 $selected_rate_code = ''; 160 $selected_rate_key = ''; 161 foreach ( $order->get_items( 'shipping' ) as $shipping_item ) { 162 $code = $shipping_item->get_meta( 'wooss_rate_code' ); 163 $key = $shipping_item->get_meta( 'wooss_rate_key' ); 164 if ( ! empty( $code ) ) { 165 $selected_rate_code = $code; 166 $selected_rate_key = $key; 167 break; 168 } 169 } 170 158 171 $wc_countries = WC()->countries->get_countries(); 159 172 $dest_country_code = ! empty( $dest_country ) ? $dest_country : 'NG'; … … 189 202 <select id="wooss_selected_courier"> 190 203 <option value=""><?php esc_html_e( 'Select a courier...', 'wooss' ); ?></option> 191 <?php foreach ( $rates as $rate ) : ?> 204 <?php foreach ( $rates as $rate ) : 205 $rate_code_val = isset( $rate->code ) ? $rate->code : ''; 206 ?> 192 207 <option data-courier-price="<?php echo esc_attr( isset( $rate->fee ) ? $rate->fee : '' ); ?>" 193 208 data-courier-key="<?php echo esc_attr( isset( $rate->key ) ? $rate->key : '' ); ?>" 194 value="<?php echo esc_attr( isset( $rate->code ) ? $rate->code : '' ); ?>"> 209 value="<?php echo esc_attr( $rate_code_val ); ?>" 210 <?php selected( $selected_rate_code, $rate_code_val ); ?>> 195 211 <?php echo esc_html( sprintf( 196 212 '%s - %s%s', -
sendbox-shipping/tags/5.5.5/src/ShippingMethod.php
r3478358 r3480704 159 159 } 160 160 161 $wooss_rates_type = isset( $sendbox_data['wooss_rates_type'] ) ? $sendbox_data['wooss_rates_type'] : 'maximum';162 161 $wooss_extra_fees = isset( $sendbox_data['wooss_extra_fees'] ) ? (float) $sendbox_data['wooss_extra_fees'] : 0; 163 $quotes_fee = $this->extract_fee( $response, $wooss_rates_type ); 164 $quoted_fee = $quotes_fee + $wooss_extra_fees; 165 166 if ( (int) $quoted_fee === 0 ) { 167 $response = $client->get_delivery_quote( $payload ); 168 $quotes_fee = $this->extract_fee( $response, $wooss_rates_type ); 169 $quoted_fee = $quotes_fee + $wooss_extra_fees; 170 } 171 172 // Debug: log fee extraction details. 173 if ( function_exists( 'wc_get_logger' ) ) { 174 $body = $response && isset( $response->body ) ? $response->body : null; 175 wc_get_logger()->debug( sprintf( 176 'Fee extraction: rates_type=%s, has_body=%s, has_rates=%s, rates_is_array=%s, has_rate=%s, quotes_fee=%s, quoted_fee=%s, body_keys=%s', 177 $wooss_rates_type, 178 $body ? 'yes' : 'no', 179 isset( $body->rates ) ? 'yes' : 'no', 180 isset( $body->rates ) && is_array( $body->rates ) ? 'yes' : 'no', 181 isset( $body->rate ) ? 'yes' : 'no', 182 $quotes_fee, 183 $quoted_fee, 184 $body ? wp_json_encode( array_keys( (array) $body ) ) : 'null' 185 ), array( 'source' => 'sendbox-shipping' ) ); 186 } 187 188 $this->add_rate( array( 189 'id' => $this->id, 190 'label' => $this->title, 191 'cost' => $quoted_fee, 192 'package' => $package, 193 ) ); 194 } 195 196 private function extract_fee( $response, $rates_type ) { 162 $rates = $this->extract_rates( $response ); 163 164 // Retry once if no rates returned. 165 if ( empty( $rates ) ) { 166 $response = $client->get_delivery_quote( $payload ); 167 $rates = $this->extract_rates( $response ); 168 } 169 170 if ( empty( $rates ) ) { 171 $this->log( 'No shipping rates returned from Sendbox API.' ); 172 return; 173 } 174 175 foreach ( $rates as $index => $rate ) { 176 $fee = isset( $rate->fee ) ? (float) $rate->fee : 0; 177 $name = isset( $rate->name ) ? $rate->name : ''; 178 $code = isset( $rate->code ) ? $rate->code : ''; 179 180 if ( $fee <= 0 ) { 181 continue; 182 } 183 184 $label = ! empty( $name ) ? $name : $this->title; 185 $cost = $fee + $wooss_extra_fees; 186 $rate_id = $this->id . '_' . ( ! empty( $code ) ? sanitize_title( $code ) : $index ); 187 188 $this->add_rate( array( 189 'id' => $rate_id, 190 'label' => $label, 191 'cost' => $cost, 192 'package' => $package, 193 'meta_data' => array( 194 'wooss_rate_code' => $code, 195 'wooss_rate_key' => isset( $rate->key ) ? $rate->key : '', 196 ), 197 ) ); 198 } 199 } 200 201 private function extract_rates( $response ) { 197 202 if ( ! $response || ! isset( $response->body ) ) { 198 return 0;203 return array(); 199 204 } 200 205 201 206 $body = $response->body; 202 207 203 // Legacy fields. 204 if ( 'maximum' === $rates_type && isset( $body->max_quoted_fee ) ) { 205 return (float) $body->max_quoted_fee; 206 } 207 if ( 'minimum' === $rates_type && isset( $body->min_quoted_fee ) ) { 208 return (float) $body->min_quoted_fee; 209 } 210 211 // Current API returns rates as an array of rate objects with a fee field. 208 // Current API returns rates as an array of rate objects. 212 209 if ( ! empty( $body->rates ) && is_array( $body->rates ) ) { 213 $fees = array_map( function ( $rate ) { 214 return isset( $rate->fee ) ? (float) $rate->fee : 0; 215 }, $body->rates ); 216 217 $fees = array_filter( $fees ); 218 if ( ! empty( $fees ) ) { 219 return 'maximum' === $rates_type ? max( $fees ) : min( $fees ); 220 } 221 } 222 223 // Single rate object. 224 if ( isset( $body->rate->fee ) ) { 225 return (float) $body->rate->fee; 226 } 227 228 return 0; 210 return $body->rates; 211 } 212 213 // Single rate object — wrap in array. 214 if ( isset( $body->rate ) && isset( $body->rate->fee ) ) { 215 return array( $body->rate ); 216 } 217 218 return array(); 229 219 } 230 220 -
sendbox-shipping/tags/5.5.5/wooss.php
r3478501 r3480704 4 4 * Plugin URI: https://sendbox.co/ 5 5 * Description: WooCommerce shipping integration with Sendbox — ship from your store to anywhere in the world. 6 * Version: 5.5. 46 * Version: 5.5.5 7 7 * Author: Sendbox 8 8 * Author URI: https://sendbox.co/ … … 23 23 } 24 24 25 define( 'WOOSS_VERSION', '5.5. 4' );25 define( 'WOOSS_VERSION', '5.5.5' ); 26 26 define( 'WOOSS_PLUGIN_FILE', __FILE__ ); 27 27 define( 'WOOSS_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); -
sendbox-shipping/trunk/README.txt
r3478501 r3480704 5 5 Requires at least: 6.0 6 6 Tested up to: 6.9 7 Stable tag: 5.5. 47 Stable tag: 5.5.5 8 8 Requires PHP: 7.4 9 9 License: GPLv2 or later -
sendbox-shipping/trunk/assets/js/admin-order.js
r3478358 r3480704 12 12 13 13 // Courier selection: update fee display 14 $("#wooss_selected_courier").on("change", function () { 15 var option = this.options[this.selectedIndex]; 14 function updateCourierFee() { 15 var select = document.getElementById("wooss_selected_courier"); 16 if (!select) return; 17 var option = select.options[select.selectedIndex]; 16 18 var price = option ? option.getAttribute("data-courier-price") : ""; 17 19 var feeEl = document.getElementById("dabs"); … … 20 22 feeEl.style.color = "#ed2f59"; 21 23 } 22 }); 24 } 25 26 // Show fee on load if a courier is pre-selected 27 updateCourierFee(); 28 29 $("#wooss_selected_courier").on("change", updateCourierFee); 23 30 24 31 // Country dropdown change: load states -
sendbox-shipping/trunk/src/Admin/OrderMetabox.php
r3478358 r3480704 156 156 } 157 157 158 // Get the rate code the customer selected at checkout. 159 $selected_rate_code = ''; 160 $selected_rate_key = ''; 161 foreach ( $order->get_items( 'shipping' ) as $shipping_item ) { 162 $code = $shipping_item->get_meta( 'wooss_rate_code' ); 163 $key = $shipping_item->get_meta( 'wooss_rate_key' ); 164 if ( ! empty( $code ) ) { 165 $selected_rate_code = $code; 166 $selected_rate_key = $key; 167 break; 168 } 169 } 170 158 171 $wc_countries = WC()->countries->get_countries(); 159 172 $dest_country_code = ! empty( $dest_country ) ? $dest_country : 'NG'; … … 189 202 <select id="wooss_selected_courier"> 190 203 <option value=""><?php esc_html_e( 'Select a courier...', 'wooss' ); ?></option> 191 <?php foreach ( $rates as $rate ) : ?> 204 <?php foreach ( $rates as $rate ) : 205 $rate_code_val = isset( $rate->code ) ? $rate->code : ''; 206 ?> 192 207 <option data-courier-price="<?php echo esc_attr( isset( $rate->fee ) ? $rate->fee : '' ); ?>" 193 208 data-courier-key="<?php echo esc_attr( isset( $rate->key ) ? $rate->key : '' ); ?>" 194 value="<?php echo esc_attr( isset( $rate->code ) ? $rate->code : '' ); ?>"> 209 value="<?php echo esc_attr( $rate_code_val ); ?>" 210 <?php selected( $selected_rate_code, $rate_code_val ); ?>> 195 211 <?php echo esc_html( sprintf( 196 212 '%s - %s%s', -
sendbox-shipping/trunk/src/ShippingMethod.php
r3478358 r3480704 159 159 } 160 160 161 $wooss_rates_type = isset( $sendbox_data['wooss_rates_type'] ) ? $sendbox_data['wooss_rates_type'] : 'maximum';162 161 $wooss_extra_fees = isset( $sendbox_data['wooss_extra_fees'] ) ? (float) $sendbox_data['wooss_extra_fees'] : 0; 163 $quotes_fee = $this->extract_fee( $response, $wooss_rates_type ); 164 $quoted_fee = $quotes_fee + $wooss_extra_fees; 165 166 if ( (int) $quoted_fee === 0 ) { 167 $response = $client->get_delivery_quote( $payload ); 168 $quotes_fee = $this->extract_fee( $response, $wooss_rates_type ); 169 $quoted_fee = $quotes_fee + $wooss_extra_fees; 170 } 171 172 // Debug: log fee extraction details. 173 if ( function_exists( 'wc_get_logger' ) ) { 174 $body = $response && isset( $response->body ) ? $response->body : null; 175 wc_get_logger()->debug( sprintf( 176 'Fee extraction: rates_type=%s, has_body=%s, has_rates=%s, rates_is_array=%s, has_rate=%s, quotes_fee=%s, quoted_fee=%s, body_keys=%s', 177 $wooss_rates_type, 178 $body ? 'yes' : 'no', 179 isset( $body->rates ) ? 'yes' : 'no', 180 isset( $body->rates ) && is_array( $body->rates ) ? 'yes' : 'no', 181 isset( $body->rate ) ? 'yes' : 'no', 182 $quotes_fee, 183 $quoted_fee, 184 $body ? wp_json_encode( array_keys( (array) $body ) ) : 'null' 185 ), array( 'source' => 'sendbox-shipping' ) ); 186 } 187 188 $this->add_rate( array( 189 'id' => $this->id, 190 'label' => $this->title, 191 'cost' => $quoted_fee, 192 'package' => $package, 193 ) ); 194 } 195 196 private function extract_fee( $response, $rates_type ) { 162 $rates = $this->extract_rates( $response ); 163 164 // Retry once if no rates returned. 165 if ( empty( $rates ) ) { 166 $response = $client->get_delivery_quote( $payload ); 167 $rates = $this->extract_rates( $response ); 168 } 169 170 if ( empty( $rates ) ) { 171 $this->log( 'No shipping rates returned from Sendbox API.' ); 172 return; 173 } 174 175 foreach ( $rates as $index => $rate ) { 176 $fee = isset( $rate->fee ) ? (float) $rate->fee : 0; 177 $name = isset( $rate->name ) ? $rate->name : ''; 178 $code = isset( $rate->code ) ? $rate->code : ''; 179 180 if ( $fee <= 0 ) { 181 continue; 182 } 183 184 $label = ! empty( $name ) ? $name : $this->title; 185 $cost = $fee + $wooss_extra_fees; 186 $rate_id = $this->id . '_' . ( ! empty( $code ) ? sanitize_title( $code ) : $index ); 187 188 $this->add_rate( array( 189 'id' => $rate_id, 190 'label' => $label, 191 'cost' => $cost, 192 'package' => $package, 193 'meta_data' => array( 194 'wooss_rate_code' => $code, 195 'wooss_rate_key' => isset( $rate->key ) ? $rate->key : '', 196 ), 197 ) ); 198 } 199 } 200 201 private function extract_rates( $response ) { 197 202 if ( ! $response || ! isset( $response->body ) ) { 198 return 0;203 return array(); 199 204 } 200 205 201 206 $body = $response->body; 202 207 203 // Legacy fields. 204 if ( 'maximum' === $rates_type && isset( $body->max_quoted_fee ) ) { 205 return (float) $body->max_quoted_fee; 206 } 207 if ( 'minimum' === $rates_type && isset( $body->min_quoted_fee ) ) { 208 return (float) $body->min_quoted_fee; 209 } 210 211 // Current API returns rates as an array of rate objects with a fee field. 208 // Current API returns rates as an array of rate objects. 212 209 if ( ! empty( $body->rates ) && is_array( $body->rates ) ) { 213 $fees = array_map( function ( $rate ) { 214 return isset( $rate->fee ) ? (float) $rate->fee : 0; 215 }, $body->rates ); 216 217 $fees = array_filter( $fees ); 218 if ( ! empty( $fees ) ) { 219 return 'maximum' === $rates_type ? max( $fees ) : min( $fees ); 220 } 221 } 222 223 // Single rate object. 224 if ( isset( $body->rate->fee ) ) { 225 return (float) $body->rate->fee; 226 } 227 228 return 0; 210 return $body->rates; 211 } 212 213 // Single rate object — wrap in array. 214 if ( isset( $body->rate ) && isset( $body->rate->fee ) ) { 215 return array( $body->rate ); 216 } 217 218 return array(); 229 219 } 230 220 -
sendbox-shipping/trunk/wooss.php
r3478501 r3480704 4 4 * Plugin URI: https://sendbox.co/ 5 5 * Description: WooCommerce shipping integration with Sendbox — ship from your store to anywhere in the world. 6 * Version: 5.5. 46 * Version: 5.5.5 7 7 * Author: Sendbox 8 8 * Author URI: https://sendbox.co/ … … 23 23 } 24 24 25 define( 'WOOSS_VERSION', '5.5. 4' );25 define( 'WOOSS_VERSION', '5.5.5' ); 26 26 define( 'WOOSS_PLUGIN_FILE', __FILE__ ); 27 27 define( 'WOOSS_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
Note: See TracChangeset
for help on using the changeset viewer.