Changeset 3362619
- Timestamp:
- 09/16/2025 02:21:27 PM (5 months ago)
- Location:
- live-rates-for-shipstation
- Files:
-
- 12 edited
- 1 copied
-
tags/1.0.5 (copied) (copied from live-rates-for-shipstation/trunk)
-
tags/1.0.5/changelog.txt (modified) (1 diff)
-
tags/1.0.5/core/settings-shipstation.php (modified) (2 diffs)
-
tags/1.0.5/core/shipping-method-shipstation.php (modified) (7 diffs)
-
tags/1.0.5/core/shipstation-api.php (modified) (1 diff)
-
tags/1.0.5/live-rates-for-shipstation.php (modified) (2 diffs)
-
tags/1.0.5/readme.txt (modified) (3 diffs)
-
trunk/changelog.txt (modified) (1 diff)
-
trunk/core/settings-shipstation.php (modified) (2 diffs)
-
trunk/core/shipping-method-shipstation.php (modified) (7 diffs)
-
trunk/core/shipstation-api.php (modified) (1 diff)
-
trunk/live-rates-for-shipstation.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
live-rates-for-shipstation/tags/1.0.5/changelog.txt
r3361859 r3362619 2 2 3 3 This is a brief text document keeping track of changes to the plugin. For a full history, see the Github Repository. 4 5 = 1.0.5 = 6 7 Relase Date: September 16, 2025 8 9 * Overview 10 * Patches an issue where shipping rates would come back much higher than expected 11 * This was due to rates with multiple package types, but used the same service code. 12 * Now, only the generic 'package' rate is returned. 13 * Patches issue where disabled services would display during checkout. 14 * Patches issue where service nickname would not apply. 15 * This patch also ensures that during export/import to ShipStation it does not 16 use the nickname, but service name for clarify. 17 * Order item metadata added that breaks down: 18 * Service (sevice_code) 19 * Carrier (carrier_code) 20 * Rate [Found shipping rate] 21 * Adjustment [Any price adjustments made and whehter it's Global or Specific] 22 23 * Code Updates 24 * \IQLRSS\Core\Shipping_Method_Shipstation::labelify_meta_keys() 25 * Translatable Order Item metadata keys. 26 * \IQLRSS\Core\Shipping_Method_Shipstation::calculate_shipping() 27 * Updates to store metadata 28 * \IQLRSS\Core\Shipstation_Api::get_shipping_estimates() 29 * Adds conditional to exclude any rates that are not for generic 'package' types. 4 30 5 31 = 1.0.4 = -
live-rates-for-shipstation/tags/1.0.5/core/settings-shipstation.php
r3361859 r3362619 494 494 495 495 /** 496 * Update the WC_Order Shipping Method to match the ShipStation Carrier.497 * Ex. USPSPriorityMail498 * 499 * @link https://help.shipstation.com/hc/en-us/articles/360025856192-Custom-Store-Development-Guide496 * Update the shipping method name to be the Service. 497 * Usually not needed, but if a user updates a service name 498 * to a nickname, this will make it easier to understand 499 * once on ShipStation. 500 500 * 501 501 * @param WC_Order $order … … 516 516 // Not our shipping method. 517 517 if( $method->get_method_id() != $plugin_method_id ) continue; 518 519 $service_name = $method->get_meta( 'service_name', true ); 520 $carrier_name = $method->get_meta( 'carrier_name', true ); 521 522 // Missing metadata. 523 if( empty( $service_name ) || empty( $carrier_name ) ) continue; 524 518 519 $service_name = (string)$method->get_meta( 'service', true ); 525 520 $method->set_props( array( 526 'name' => preg_replace( '/([^a-zA-Z0-9])/', '', sprintf( '%s %s', $carrier_name, $service_name )),521 'name' => trim( explode( '(', $service_name )[0] ), 527 522 ) ); 528 523 $method->apply_changes(); // Temporarily apply changes. This does not update the database. -
live-rates-for-shipstation/tags/1.0.5/core/shipping-method-shipstation.php
r3361859 r3362619 108 108 109 109 add_action( 'woocommerce_update_options_shipping_' . $this->id, array( $this, 'process_admin_options' ) ); 110 add_filter( 'http_request_timeout', array( $this, 'increase_request_timeout' ) ); 110 add_filter( 'http_request_timeout', array( $this, 'increase_request_timeout' ) ); 111 add_filter( 'woocommerce_order_item_display_meta_key', array( $this, 'labelify_meta_keys' ) ); 111 112 112 113 } … … 137 138 public function increase_request_timeout( $timeout ) { 138 139 return ( $timeout < 20 ) ? 20 : $timeout; 140 } 141 142 143 /** 144 * Edit Order Screen 145 * Display Order Item Metadata, but labelify the $dispaly Key 146 * 147 * @param String $display 148 * 149 * @return String $display 150 */ 151 public function labelify_meta_keys( $display ) { 152 153 $matches = array( 154 'carrier' => esc_html__( 'Carrier', 'live-rates-for-shipstation' ), 155 'service' => esc_html__( 'Service', 'live-rates-for-shipstation' ), 156 'rate' => esc_html__( 'Rate', 'live-rates-for-shipstation' ), 157 'adjustment'=> esc_html__( 'Adjustment', 'live-rates-for-shipstation' ), 158 ); 159 160 return ( isset( $matches[ $display ] ) ) ? $matches[ $display ] : $display; 161 139 162 } 140 163 … … 397 420 } 398 421 399 $ saved_services = $this->get_option( 'services', array());400 if( empty( $ saved_services ) ) {422 $enabled_services = $this->get_enabled_services(); 423 if( empty( $enabled_services ) ) { 401 424 return; 402 425 } 403 426 404 $saved_carriers = array_keys( $ saved_services );427 $saved_carriers = array_keys( $enabled_services ); 405 428 if( ! empty( $saved_carriers ) && ! empty( $this->carriers ) ) { 406 429 $saved_carriers = array_values( array_intersect( $saved_carriers, $this->carriers ) ); … … 476 499 foreach( $available_rates as $shiprate ) { 477 500 478 if( ! isset( $ saved_services[ $shiprate['carrier_code'] ][ $shiprate['code'] ] ) ) {501 if( ! isset( $enabled_services[ $shiprate['carrier_code'] ][ $shiprate['code'] ] ) ) { 479 502 continue; 480 503 } 481 504 482 $service_arr = $ saved_services[ $shiprate['carrier_code'] ][ $shiprate['code'] ];505 $service_arr = $enabled_services[ $shiprate['carrier_code'] ][ $shiprate['code'] ]; 483 506 $cost = $shiprate['cost']; 507 $metadata = array( 508 'carrier' => sprintf( '%s (%s)', $shiprate['carrier_name'], $shiprate['carrier_code'] ), 509 'service' => sprintf( '%s (%s)', $shiprate['name'], $shiprate['code'] ), 510 'rate' => html_entity_decode( strip_tags( wc_price( $cost ) ) ), 511 ); 484 512 485 513 // Apply service upcharge … … 494 522 495 523 if( ! empty( $adjustment_type ) && $adjustment > 0 ) { 496 $cost += ( 'flatrate' == $adjustment_type ) ? $adjustment : ( $cost * ( $adjustment / 100 ) ); 524 525 $adjustment_cost = ( 'flatrate' == $adjustment_type ) ? $adjustment : ( $cost * ( $adjustment / 100 ) ); 526 $metadata['adjustment'] = sprintf( '%s (%s) - %s', 527 html_entity_decode( strip_tags( wc_price( $adjustment_cost ) ) ), 528 ucwords( $adjustment_type ), 529 esc_html__( 'Service Specific', 'live-rates-for-shipstation' ), 530 ); 531 $cost += $adjustment_cost; 532 497 533 } 498 534 499 535 } else if( ! empty( $global_adjustment_type ) && $global_adjustment > 0 ) { 500 $cost += ( 'flatrate' == $global_adjustment_type ) ? floatval( $global_adjustment ) : ( $cost * ( floatval( $global_adjustment ) / 100 ) ); 536 537 $adjustment_cost = ( 'flatrate' == $global_adjustment_type ) ? floatval( $global_adjustment ) : ( $cost * ( floatval( $global_adjustment ) / 100 ) ); 538 $metadata['adjustment'] = sprintf( '%s (%s) - %s', 539 html_entity_decode( strip_tags( wc_price( $adjustment_cost ) ) ), 540 ucwords( $global_adjustment_type ), 541 esc_html__( 'Global', 'live-rates-for-shipstation' ), 542 ); 543 $cost += $adjustment_cost; 544 501 545 } 502 546 … … 507 551 $rate = array( 508 552 'id' => $shiprate['code'], 509 'label' => sprintf( '%s (%s)', $shiprate['name'], $shiprate['carrier_name'] ),553 'label' => ( ! empty( $service_arr['nickname'] ) ) ? $service_arr['nickname'] : $shiprate['name'], 510 554 'package' => $packages, 511 'meta_data' => array( 512 'dimensions' => $req['dimensions'], 513 'weight' => $req['weight'], 514 'service_name' => $shiprate['name'], 515 'carrier_code' => $shiprate['carrier_code'], 516 'carrier_name' => $shiprate['carrier_name'], 517 ), 555 'meta_data' => array_merge( $metadata, array( 556 'dimensions'=> $req['dimensions'], 557 'weight' => $req['weight'], 558 ) ), 518 559 ); 519 560 … … 875 916 876 917 /** 918 * Return an m-array of enabled services grouped by carrier key. 919 * 920 * @return Array 921 */ 922 public function get_enabled_services() { 923 924 $enabled = array(); 925 $saved_services = $this->get_option( 'services', array() ); 926 if( empty( $saved_services ) ) return $enabled; 927 928 foreach( $saved_services as $c => $sa ) { 929 foreach( $sa as $sk => $s ) { 930 if( ! isset( $s['enabled'] ) || ! $s['enabled'] ) continue; 931 $enabled[ $c ][ $sk ] = $s; 932 } 933 } 934 935 return $enabled; 936 937 } 938 939 940 /** 877 941 * Log error in WooCommerce 878 942 * Passthru method - log what's given and give it back. -
live-rates-for-shipstation/tags/1.0.5/core/shipstation-api.php
r3361859 r3362619 247 247 // Sometimes rates can be cost $0, which isn't right - skip them. 248 248 if( $rate['shipping_amount']['amount'] <= 0 ) continue; 249 if( ! empty( $rate['package_type'] ) && 'package' != $rate['package_type'] ) continue; 249 250 250 251 $est = array( -
live-rates-for-shipstation/tags/1.0.5/live-rates-for-shipstation.php
r3361859 r3362619 4 4 * Plugin URI: https://iqcomputing.com/contact/ 5 5 * Description: ShipStation shipping method with live rates. 6 * Version: 1.0. 46 * Version: 1.0.5 7 7 * Requries at least: 5.9 8 8 * Author: IQComputing … … 26 26 * @var String 27 27 */ 28 protected static $version = '1.0. 4';28 protected static $version = '1.0.5'; 29 29 30 30 -
live-rates-for-shipstation/tags/1.0.5/readme.txt
r3361859 r3362619 4 4 Requires at least: 5.9 5 5 Tested up to: 6.8 6 Stable tag: 1.0. 46 Stable tag: 1.0.5 7 7 License: GPLv3 or later 8 8 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 49 49 == Changelog == 50 50 51 = 1.0.5 (2025-09-16) = 52 * Patches shipping rate price disrepencies due to rates with multiple package types. 53 * Patches disabled shipping services displaying. 54 * Patches nicknames not applying properly. 55 * Adds/Displays order item metadata to track ship rate, rate adjustment, carrier, service, and codes. 56 51 57 = 1.0.4 (2025-09-15) = 52 58 * Patches issues with shipping units not match store set units. … … 57 63 = 1.0.3 (2025-08-05) = 58 64 * Patches an issue with Shipping Method availability (Thanks to @sportswreathshop for reporting!) 59 60 = 1.0.2 (2025-08-04) =61 * Refines API caching that clears on settings save (thanks again to @dpkonofa for test/reporting!). -
live-rates-for-shipstation/trunk/changelog.txt
r3361859 r3362619 2 2 3 3 This is a brief text document keeping track of changes to the plugin. For a full history, see the Github Repository. 4 5 = 1.0.5 = 6 7 Relase Date: September 16, 2025 8 9 * Overview 10 * Patches an issue where shipping rates would come back much higher than expected 11 * This was due to rates with multiple package types, but used the same service code. 12 * Now, only the generic 'package' rate is returned. 13 * Patches issue where disabled services would display during checkout. 14 * Patches issue where service nickname would not apply. 15 * This patch also ensures that during export/import to ShipStation it does not 16 use the nickname, but service name for clarify. 17 * Order item metadata added that breaks down: 18 * Service (sevice_code) 19 * Carrier (carrier_code) 20 * Rate [Found shipping rate] 21 * Adjustment [Any price adjustments made and whehter it's Global or Specific] 22 23 * Code Updates 24 * \IQLRSS\Core\Shipping_Method_Shipstation::labelify_meta_keys() 25 * Translatable Order Item metadata keys. 26 * \IQLRSS\Core\Shipping_Method_Shipstation::calculate_shipping() 27 * Updates to store metadata 28 * \IQLRSS\Core\Shipstation_Api::get_shipping_estimates() 29 * Adds conditional to exclude any rates that are not for generic 'package' types. 4 30 5 31 = 1.0.4 = -
live-rates-for-shipstation/trunk/core/settings-shipstation.php
r3361859 r3362619 494 494 495 495 /** 496 * Update the WC_Order Shipping Method to match the ShipStation Carrier.497 * Ex. USPSPriorityMail498 * 499 * @link https://help.shipstation.com/hc/en-us/articles/360025856192-Custom-Store-Development-Guide496 * Update the shipping method name to be the Service. 497 * Usually not needed, but if a user updates a service name 498 * to a nickname, this will make it easier to understand 499 * once on ShipStation. 500 500 * 501 501 * @param WC_Order $order … … 516 516 // Not our shipping method. 517 517 if( $method->get_method_id() != $plugin_method_id ) continue; 518 519 $service_name = $method->get_meta( 'service_name', true ); 520 $carrier_name = $method->get_meta( 'carrier_name', true ); 521 522 // Missing metadata. 523 if( empty( $service_name ) || empty( $carrier_name ) ) continue; 524 518 519 $service_name = (string)$method->get_meta( 'service', true ); 525 520 $method->set_props( array( 526 'name' => preg_replace( '/([^a-zA-Z0-9])/', '', sprintf( '%s %s', $carrier_name, $service_name )),521 'name' => trim( explode( '(', $service_name )[0] ), 527 522 ) ); 528 523 $method->apply_changes(); // Temporarily apply changes. This does not update the database. -
live-rates-for-shipstation/trunk/core/shipping-method-shipstation.php
r3361859 r3362619 108 108 109 109 add_action( 'woocommerce_update_options_shipping_' . $this->id, array( $this, 'process_admin_options' ) ); 110 add_filter( 'http_request_timeout', array( $this, 'increase_request_timeout' ) ); 110 add_filter( 'http_request_timeout', array( $this, 'increase_request_timeout' ) ); 111 add_filter( 'woocommerce_order_item_display_meta_key', array( $this, 'labelify_meta_keys' ) ); 111 112 112 113 } … … 137 138 public function increase_request_timeout( $timeout ) { 138 139 return ( $timeout < 20 ) ? 20 : $timeout; 140 } 141 142 143 /** 144 * Edit Order Screen 145 * Display Order Item Metadata, but labelify the $dispaly Key 146 * 147 * @param String $display 148 * 149 * @return String $display 150 */ 151 public function labelify_meta_keys( $display ) { 152 153 $matches = array( 154 'carrier' => esc_html__( 'Carrier', 'live-rates-for-shipstation' ), 155 'service' => esc_html__( 'Service', 'live-rates-for-shipstation' ), 156 'rate' => esc_html__( 'Rate', 'live-rates-for-shipstation' ), 157 'adjustment'=> esc_html__( 'Adjustment', 'live-rates-for-shipstation' ), 158 ); 159 160 return ( isset( $matches[ $display ] ) ) ? $matches[ $display ] : $display; 161 139 162 } 140 163 … … 397 420 } 398 421 399 $ saved_services = $this->get_option( 'services', array());400 if( empty( $ saved_services ) ) {422 $enabled_services = $this->get_enabled_services(); 423 if( empty( $enabled_services ) ) { 401 424 return; 402 425 } 403 426 404 $saved_carriers = array_keys( $ saved_services );427 $saved_carriers = array_keys( $enabled_services ); 405 428 if( ! empty( $saved_carriers ) && ! empty( $this->carriers ) ) { 406 429 $saved_carriers = array_values( array_intersect( $saved_carriers, $this->carriers ) ); … … 476 499 foreach( $available_rates as $shiprate ) { 477 500 478 if( ! isset( $ saved_services[ $shiprate['carrier_code'] ][ $shiprate['code'] ] ) ) {501 if( ! isset( $enabled_services[ $shiprate['carrier_code'] ][ $shiprate['code'] ] ) ) { 479 502 continue; 480 503 } 481 504 482 $service_arr = $ saved_services[ $shiprate['carrier_code'] ][ $shiprate['code'] ];505 $service_arr = $enabled_services[ $shiprate['carrier_code'] ][ $shiprate['code'] ]; 483 506 $cost = $shiprate['cost']; 507 $metadata = array( 508 'carrier' => sprintf( '%s (%s)', $shiprate['carrier_name'], $shiprate['carrier_code'] ), 509 'service' => sprintf( '%s (%s)', $shiprate['name'], $shiprate['code'] ), 510 'rate' => html_entity_decode( strip_tags( wc_price( $cost ) ) ), 511 ); 484 512 485 513 // Apply service upcharge … … 494 522 495 523 if( ! empty( $adjustment_type ) && $adjustment > 0 ) { 496 $cost += ( 'flatrate' == $adjustment_type ) ? $adjustment : ( $cost * ( $adjustment / 100 ) ); 524 525 $adjustment_cost = ( 'flatrate' == $adjustment_type ) ? $adjustment : ( $cost * ( $adjustment / 100 ) ); 526 $metadata['adjustment'] = sprintf( '%s (%s) - %s', 527 html_entity_decode( strip_tags( wc_price( $adjustment_cost ) ) ), 528 ucwords( $adjustment_type ), 529 esc_html__( 'Service Specific', 'live-rates-for-shipstation' ), 530 ); 531 $cost += $adjustment_cost; 532 497 533 } 498 534 499 535 } else if( ! empty( $global_adjustment_type ) && $global_adjustment > 0 ) { 500 $cost += ( 'flatrate' == $global_adjustment_type ) ? floatval( $global_adjustment ) : ( $cost * ( floatval( $global_adjustment ) / 100 ) ); 536 537 $adjustment_cost = ( 'flatrate' == $global_adjustment_type ) ? floatval( $global_adjustment ) : ( $cost * ( floatval( $global_adjustment ) / 100 ) ); 538 $metadata['adjustment'] = sprintf( '%s (%s) - %s', 539 html_entity_decode( strip_tags( wc_price( $adjustment_cost ) ) ), 540 ucwords( $global_adjustment_type ), 541 esc_html__( 'Global', 'live-rates-for-shipstation' ), 542 ); 543 $cost += $adjustment_cost; 544 501 545 } 502 546 … … 507 551 $rate = array( 508 552 'id' => $shiprate['code'], 509 'label' => sprintf( '%s (%s)', $shiprate['name'], $shiprate['carrier_name'] ),553 'label' => ( ! empty( $service_arr['nickname'] ) ) ? $service_arr['nickname'] : $shiprate['name'], 510 554 'package' => $packages, 511 'meta_data' => array( 512 'dimensions' => $req['dimensions'], 513 'weight' => $req['weight'], 514 'service_name' => $shiprate['name'], 515 'carrier_code' => $shiprate['carrier_code'], 516 'carrier_name' => $shiprate['carrier_name'], 517 ), 555 'meta_data' => array_merge( $metadata, array( 556 'dimensions'=> $req['dimensions'], 557 'weight' => $req['weight'], 558 ) ), 518 559 ); 519 560 … … 875 916 876 917 /** 918 * Return an m-array of enabled services grouped by carrier key. 919 * 920 * @return Array 921 */ 922 public function get_enabled_services() { 923 924 $enabled = array(); 925 $saved_services = $this->get_option( 'services', array() ); 926 if( empty( $saved_services ) ) return $enabled; 927 928 foreach( $saved_services as $c => $sa ) { 929 foreach( $sa as $sk => $s ) { 930 if( ! isset( $s['enabled'] ) || ! $s['enabled'] ) continue; 931 $enabled[ $c ][ $sk ] = $s; 932 } 933 } 934 935 return $enabled; 936 937 } 938 939 940 /** 877 941 * Log error in WooCommerce 878 942 * Passthru method - log what's given and give it back. -
live-rates-for-shipstation/trunk/core/shipstation-api.php
r3361859 r3362619 247 247 // Sometimes rates can be cost $0, which isn't right - skip them. 248 248 if( $rate['shipping_amount']['amount'] <= 0 ) continue; 249 if( ! empty( $rate['package_type'] ) && 'package' != $rate['package_type'] ) continue; 249 250 250 251 $est = array( -
live-rates-for-shipstation/trunk/live-rates-for-shipstation.php
r3361859 r3362619 4 4 * Plugin URI: https://iqcomputing.com/contact/ 5 5 * Description: ShipStation shipping method with live rates. 6 * Version: 1.0. 46 * Version: 1.0.5 7 7 * Requries at least: 5.9 8 8 * Author: IQComputing … … 26 26 * @var String 27 27 */ 28 protected static $version = '1.0. 4';28 protected static $version = '1.0.5'; 29 29 30 30 -
live-rates-for-shipstation/trunk/readme.txt
r3361859 r3362619 4 4 Requires at least: 5.9 5 5 Tested up to: 6.8 6 Stable tag: 1.0. 46 Stable tag: 1.0.5 7 7 License: GPLv3 or later 8 8 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 49 49 == Changelog == 50 50 51 = 1.0.5 (2025-09-16) = 52 * Patches shipping rate price disrepencies due to rates with multiple package types. 53 * Patches disabled shipping services displaying. 54 * Patches nicknames not applying properly. 55 * Adds/Displays order item metadata to track ship rate, rate adjustment, carrier, service, and codes. 56 51 57 = 1.0.4 (2025-09-15) = 52 58 * Patches issues with shipping units not match store set units. … … 57 63 = 1.0.3 (2025-08-05) = 58 64 * Patches an issue with Shipping Method availability (Thanks to @sportswreathshop for reporting!) 59 60 = 1.0.2 (2025-08-04) =61 * Refines API caching that clears on settings save (thanks again to @dpkonofa for test/reporting!).
Note: See TracChangeset
for help on using the changeset viewer.