Changeset 3339099
- Timestamp:
- 08/04/2025 03:08:27 PM (8 months ago)
- Location:
- live-rates-for-shipstation
- Files:
-
- 10 edited
- 1 copied
-
tags/1.0.2 (copied) (copied from live-rates-for-shipstation/trunk)
-
tags/1.0.2/changelog.txt (modified) (1 diff)
-
tags/1.0.2/core/settings-shipstation.php (modified) (6 diffs)
-
tags/1.0.2/core/shipping-method-shipstation.php (modified) (6 diffs)
-
tags/1.0.2/live-rates-for-shipstation.php (modified) (2 diffs)
-
tags/1.0.2/readme.txt (modified) (2 diffs)
-
trunk/changelog.txt (modified) (1 diff)
-
trunk/core/settings-shipstation.php (modified) (6 diffs)
-
trunk/core/shipping-method-shipstation.php (modified) (6 diffs)
-
trunk/live-rates-for-shipstation.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
live-rates-for-shipstation/tags/1.0.2/changelog.txt
r3337929 r3339099 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.2 = 6 7 Relase Date: August 04, 2025 8 9 * Overview 10 * Automatically clears the API caching whenever Integration settings or Shipping Zone settings are saved. 11 * Shoutout to .org user @dpkonofa for their assistance in debugging this issue! 12 13 * Code Updates 14 * Moves the \IQLRSS\Core\Settings_Shipstation::api_actions_endpoint() clearcache action into it's own method. 15 * In a future release, the caching will be in it's own class definition. 4 16 5 17 = 1.0.1 = -
live-rates-for-shipstation/tags/1.0.2/core/settings-shipstation.php
r3337929 r3339099 42 42 add_action( 'woocommerce_cart_totals_after_order_total',array( $this, 'display_cart_weight' ) ) ; 43 43 add_action( 'rest_api_init', array( $this, 'api_actions_endpoint' ) ); 44 add_action( 'woocommerce_update_option', array( $this, 'clear_cache_on_update' ) ); 44 45 45 46 } … … 180 181 'callback' => function( $request ) { 181 182 182 global $wpdb;183 184 183 $params = $request->get_params(); 185 184 if( ! isset( $params['action'] ) || empty( $params['action'] ) ) { … … 192 191 case 'clearcache': 193 192 194 /**195 * The API Class creates various transients to cache carrier services.196 * These transients are not tracked but generated based on the responses carrier codes.197 * All these transients are prefixed with our plugins unique string slug.198 * The first WHERE ensures only `_transient_` and the 2nd ensures only our plugins transients.199 */200 $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s AND option_name LIKE %s",201 $wpdb->esc_like( '_transient_' ) . '%',202 '%' . $wpdb->esc_like( '_' . \IQLRSS\Driver::get( 'slug' ) . '_' ) . '%'203 ) );204 205 // Set transient to clear any WC_Session caches if they are found.206 $time = absint( apply_filters( 'wc_session_expiration', DAY_IN_SECONDS * 2 ) );207 set_transient( \IQLRSS\Driver::plugin_prefix( 'wcs_timeout' ), time(), $time );208 209 193 // Success! 194 $this->clear_cache(); 210 195 wp_send_json_success(); 211 196 … … 283 268 284 269 270 /** 271 * Clear the API cache. 272 * 273 * @return void 274 */ 275 public function clear_cache() { 276 277 global $wpdb; 278 279 /** 280 * The API Class creates various transients to cache carrier services. 281 * These transients are not tracked but generated based on the responses carrier codes. 282 * All these transients are prefixed with our plugins unique string slug. 283 * The first WHERE ensures only `_transient_` and the 2nd ensures only our plugins transients. 284 */ 285 $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s AND option_name LIKE %s", 286 $wpdb->esc_like( '_transient_' ) . '%', 287 '%' . $wpdb->esc_like( '_' . \IQLRSS\Driver::get( 'slug' ) . '_' ) . '%' 288 ) ); 289 290 // Set transient to clear any WC_Session caches if they are found. 291 $time = absint( apply_filters( 'wc_session_expiration', DAY_IN_SECONDS * 2 ) ); 292 set_transient( \IQLRSS\Driver::plugin_prefix( 'wcs_timeout' ), time(), $time ); 293 294 } 295 296 297 /** 298 * Clear the cache whenever the Integration settings have been updated. 299 * 300 * @param Array $args 301 * 302 * @return void 303 */ 304 public function clear_cache_on_update( $args ) { 305 306 if( ! isset( $args['id'] ) || false === strpos( $args['id'], 'shipstation' ) ) { 307 return; 308 } 309 310 $this->clear_cache(); 311 312 } 313 314 285 315 286 316 /**------------------------------------------------------------------------------------------------ **/ … … 326 356 $appended_fields = array(); 327 357 $carrier_desc = esc_html__( 'Select which ShipStation carriers you would like to see live shipping rates from.', 'live-rates-for-shipstation' ); 358 359 $carriers = array(); 360 $shipStationAPI = new Shipstation_Api(); 361 $response = $shipStationAPI->get_carriers(); 362 363 if( ! is_a( $response, 'WP_Error' ) ) { 364 foreach( $response as $carrier ) { 365 $carriers[ $carrier['carrier_id'] ] = $carrier['name']; 366 } 367 } 328 368 329 369 foreach( $fields as $key => $field ) { … … 345 385 'type' => 'multiselect', 346 386 'class' => 'chosen_select', 347 'options' => ( function() { // Closure since it's only used once. 348 349 $carriers = array(); 350 $shipStationAPI = new Shipstation_Api(); 351 $response = $shipStationAPI->get_carriers(); 352 353 if( ! is_a( $response, 'WP_Error' ) ) { 354 foreach( $response as $carrier ) { 355 $carriers[ $carrier['carrier_id'] ] = $carrier['name']; 356 } 357 } 358 359 return $carriers; 360 361 } )(), 387 'options' => $carriers, 362 388 'description' => $carrier_desc, 363 389 'desc_tip' => esc_html__( 'Services from selected carriers will be available when setting up Shipping Zones.', 'live-rates-for-shipstation' ), -
live-rates-for-shipstation/tags/1.0.2/core/shipping-method-shipstation.php
r3337929 r3339099 38 38 39 39 /** 40 * Array of global carriers 41 * There are the carriers saved in Integration settings. 42 * 43 * @var Array 44 */ 45 protected $carriers = array(); 46 47 48 /** 40 49 * ShipStation API Helper Class 41 50 * 42 51 * @var Object 43 52 */ 44 protected $shipStationApi ;53 protected $shipStationApi = null; 45 54 46 55 … … 70 79 $this->supports = array( 'instance-settings' ); 71 80 81 $this->carriers = \IQLRSS\Driver::get_ss_opt( 'carriers', array(), true ); 72 82 $saved_key = \IQLRSS\Driver::get_ss_opt( 'api_key_valid', false, true ); 73 $saved_carriers = \IQLRSS\Driver::get_ss_opt( 'carriers', array(), true );74 83 75 84 // Only show in Shipping Zones if API Key is invalid. … … 88 97 89 98 /** 99 * Clear cache whenever settings are updated. 100 * 101 * @return Boolean 102 */ 103 public function process_admin_options() { 104 105 ( new \IQLRSS\Core\Settings_Shipstation() )->clear_cache(); 106 return parent::process_admin_options(); 107 108 } 109 110 111 /** 90 112 * Increase the HTTP Request Timeout 91 113 * Sometimes ShipStation takes awhile to responde with rates. … … 117 139 */ 118 140 protected function init_instance_form_fields() { 119 120 $global_adjustment = \IQLRSS\Driver::get_ss_opt( 'global_adjustment', '0', true );121 141 122 142 $this->instance_form_fields = array( … … 345 365 } 346 366 367 $saved_carriers = array_keys( $saved_services ); 368 if( ! empty( $saved_carriers ) && ! empty( $this->carriers ) ) { 369 $saved_carriers = array_values( array_intersect( $saved_carriers, $this->carriers ) ); 370 } 371 347 372 $global_upcharge = floatval( \IQLRSS\Driver::get_ss_opt( 'global_adjustment', 0, true ) ); 348 $saved_carriers = array_keys( $saved_services );349 373 $packing_type = $this->get_option( 'packing', 'individual' ); 350 374 $request = array( … … 435 459 $rate = array( 436 460 'id' => $shiprate['code'], 437 'label' => $shiprate['carrier_name'] . ' - ' . $shiprate['name'],461 'label' => sprintf( '%s (%s)', $shiprate['name'], $shiprate['carrier_name'] ), 438 462 'package' => $packages, 439 463 'meta_data' => array( -
live-rates-for-shipstation/tags/1.0.2/live-rates-for-shipstation.php
r3337929 r3339099 4 4 * Plugin URI: https://iqcomputing.com/contact/ 5 5 * Description: ShipStation shipping method with live rates. 6 * Version: 1.0. 16 * Version: 1.0.2 7 7 * Requries at least: 5.9 8 8 * Author: IQComputing … … 26 26 * @var String 27 27 */ 28 protected static $version = '1.0. 1';28 protected static $version = '1.0.2'; 29 29 30 30 -
live-rates-for-shipstation/tags/1.0.2/readme.txt
r3337929 r3339099 4 4 Requires at least: 5.9 5 5 Tested up to: 6.8 6 Stable tag: 1.0. 16 Stable tag: 1.0.2 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.2 (2025-08-04) = 52 * Refines API caching that clears on settings save (thanks again to @dpkonofa for test/reporting!). 53 51 54 = 1.0.1 (2025-08-01) = 52 55 * Patches an issue with Individual Shipping Requests (thanks @dpkonofa !). -
live-rates-for-shipstation/trunk/changelog.txt
r3337929 r3339099 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.2 = 6 7 Relase Date: August 04, 2025 8 9 * Overview 10 * Automatically clears the API caching whenever Integration settings or Shipping Zone settings are saved. 11 * Shoutout to .org user @dpkonofa for their assistance in debugging this issue! 12 13 * Code Updates 14 * Moves the \IQLRSS\Core\Settings_Shipstation::api_actions_endpoint() clearcache action into it's own method. 15 * In a future release, the caching will be in it's own class definition. 4 16 5 17 = 1.0.1 = -
live-rates-for-shipstation/trunk/core/settings-shipstation.php
r3337929 r3339099 42 42 add_action( 'woocommerce_cart_totals_after_order_total',array( $this, 'display_cart_weight' ) ) ; 43 43 add_action( 'rest_api_init', array( $this, 'api_actions_endpoint' ) ); 44 add_action( 'woocommerce_update_option', array( $this, 'clear_cache_on_update' ) ); 44 45 45 46 } … … 180 181 'callback' => function( $request ) { 181 182 182 global $wpdb;183 184 183 $params = $request->get_params(); 185 184 if( ! isset( $params['action'] ) || empty( $params['action'] ) ) { … … 192 191 case 'clearcache': 193 192 194 /**195 * The API Class creates various transients to cache carrier services.196 * These transients are not tracked but generated based on the responses carrier codes.197 * All these transients are prefixed with our plugins unique string slug.198 * The first WHERE ensures only `_transient_` and the 2nd ensures only our plugins transients.199 */200 $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s AND option_name LIKE %s",201 $wpdb->esc_like( '_transient_' ) . '%',202 '%' . $wpdb->esc_like( '_' . \IQLRSS\Driver::get( 'slug' ) . '_' ) . '%'203 ) );204 205 // Set transient to clear any WC_Session caches if they are found.206 $time = absint( apply_filters( 'wc_session_expiration', DAY_IN_SECONDS * 2 ) );207 set_transient( \IQLRSS\Driver::plugin_prefix( 'wcs_timeout' ), time(), $time );208 209 193 // Success! 194 $this->clear_cache(); 210 195 wp_send_json_success(); 211 196 … … 283 268 284 269 270 /** 271 * Clear the API cache. 272 * 273 * @return void 274 */ 275 public function clear_cache() { 276 277 global $wpdb; 278 279 /** 280 * The API Class creates various transients to cache carrier services. 281 * These transients are not tracked but generated based on the responses carrier codes. 282 * All these transients are prefixed with our plugins unique string slug. 283 * The first WHERE ensures only `_transient_` and the 2nd ensures only our plugins transients. 284 */ 285 $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s AND option_name LIKE %s", 286 $wpdb->esc_like( '_transient_' ) . '%', 287 '%' . $wpdb->esc_like( '_' . \IQLRSS\Driver::get( 'slug' ) . '_' ) . '%' 288 ) ); 289 290 // Set transient to clear any WC_Session caches if they are found. 291 $time = absint( apply_filters( 'wc_session_expiration', DAY_IN_SECONDS * 2 ) ); 292 set_transient( \IQLRSS\Driver::plugin_prefix( 'wcs_timeout' ), time(), $time ); 293 294 } 295 296 297 /** 298 * Clear the cache whenever the Integration settings have been updated. 299 * 300 * @param Array $args 301 * 302 * @return void 303 */ 304 public function clear_cache_on_update( $args ) { 305 306 if( ! isset( $args['id'] ) || false === strpos( $args['id'], 'shipstation' ) ) { 307 return; 308 } 309 310 $this->clear_cache(); 311 312 } 313 314 285 315 286 316 /**------------------------------------------------------------------------------------------------ **/ … … 326 356 $appended_fields = array(); 327 357 $carrier_desc = esc_html__( 'Select which ShipStation carriers you would like to see live shipping rates from.', 'live-rates-for-shipstation' ); 358 359 $carriers = array(); 360 $shipStationAPI = new Shipstation_Api(); 361 $response = $shipStationAPI->get_carriers(); 362 363 if( ! is_a( $response, 'WP_Error' ) ) { 364 foreach( $response as $carrier ) { 365 $carriers[ $carrier['carrier_id'] ] = $carrier['name']; 366 } 367 } 328 368 329 369 foreach( $fields as $key => $field ) { … … 345 385 'type' => 'multiselect', 346 386 'class' => 'chosen_select', 347 'options' => ( function() { // Closure since it's only used once. 348 349 $carriers = array(); 350 $shipStationAPI = new Shipstation_Api(); 351 $response = $shipStationAPI->get_carriers(); 352 353 if( ! is_a( $response, 'WP_Error' ) ) { 354 foreach( $response as $carrier ) { 355 $carriers[ $carrier['carrier_id'] ] = $carrier['name']; 356 } 357 } 358 359 return $carriers; 360 361 } )(), 387 'options' => $carriers, 362 388 'description' => $carrier_desc, 363 389 'desc_tip' => esc_html__( 'Services from selected carriers will be available when setting up Shipping Zones.', 'live-rates-for-shipstation' ), -
live-rates-for-shipstation/trunk/core/shipping-method-shipstation.php
r3337929 r3339099 38 38 39 39 /** 40 * Array of global carriers 41 * There are the carriers saved in Integration settings. 42 * 43 * @var Array 44 */ 45 protected $carriers = array(); 46 47 48 /** 40 49 * ShipStation API Helper Class 41 50 * 42 51 * @var Object 43 52 */ 44 protected $shipStationApi ;53 protected $shipStationApi = null; 45 54 46 55 … … 70 79 $this->supports = array( 'instance-settings' ); 71 80 81 $this->carriers = \IQLRSS\Driver::get_ss_opt( 'carriers', array(), true ); 72 82 $saved_key = \IQLRSS\Driver::get_ss_opt( 'api_key_valid', false, true ); 73 $saved_carriers = \IQLRSS\Driver::get_ss_opt( 'carriers', array(), true );74 83 75 84 // Only show in Shipping Zones if API Key is invalid. … … 88 97 89 98 /** 99 * Clear cache whenever settings are updated. 100 * 101 * @return Boolean 102 */ 103 public function process_admin_options() { 104 105 ( new \IQLRSS\Core\Settings_Shipstation() )->clear_cache(); 106 return parent::process_admin_options(); 107 108 } 109 110 111 /** 90 112 * Increase the HTTP Request Timeout 91 113 * Sometimes ShipStation takes awhile to responde with rates. … … 117 139 */ 118 140 protected function init_instance_form_fields() { 119 120 $global_adjustment = \IQLRSS\Driver::get_ss_opt( 'global_adjustment', '0', true );121 141 122 142 $this->instance_form_fields = array( … … 345 365 } 346 366 367 $saved_carriers = array_keys( $saved_services ); 368 if( ! empty( $saved_carriers ) && ! empty( $this->carriers ) ) { 369 $saved_carriers = array_values( array_intersect( $saved_carriers, $this->carriers ) ); 370 } 371 347 372 $global_upcharge = floatval( \IQLRSS\Driver::get_ss_opt( 'global_adjustment', 0, true ) ); 348 $saved_carriers = array_keys( $saved_services );349 373 $packing_type = $this->get_option( 'packing', 'individual' ); 350 374 $request = array( … … 435 459 $rate = array( 436 460 'id' => $shiprate['code'], 437 'label' => $shiprate['carrier_name'] . ' - ' . $shiprate['name'],461 'label' => sprintf( '%s (%s)', $shiprate['name'], $shiprate['carrier_name'] ), 438 462 'package' => $packages, 439 463 'meta_data' => array( -
live-rates-for-shipstation/trunk/live-rates-for-shipstation.php
r3337929 r3339099 4 4 * Plugin URI: https://iqcomputing.com/contact/ 5 5 * Description: ShipStation shipping method with live rates. 6 * Version: 1.0. 16 * Version: 1.0.2 7 7 * Requries at least: 5.9 8 8 * Author: IQComputing … … 26 26 * @var String 27 27 */ 28 protected static $version = '1.0. 1';28 protected static $version = '1.0.2'; 29 29 30 30 -
live-rates-for-shipstation/trunk/readme.txt
r3337929 r3339099 4 4 Requires at least: 5.9 5 5 Tested up to: 6.8 6 Stable tag: 1.0. 16 Stable tag: 1.0.2 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.2 (2025-08-04) = 52 * Refines API caching that clears on settings save (thanks again to @dpkonofa for test/reporting!). 53 51 54 = 1.0.1 (2025-08-01) = 52 55 * Patches an issue with Individual Shipping Requests (thanks @dpkonofa !).
Note: See TracChangeset
for help on using the changeset viewer.