Changeset 2800481
- Timestamp:
- 10/18/2022 09:28:54 AM (3 years ago)
- Location:
- shiptimize-for-woocommerce/trunk
- Files:
-
- 4 edited
-
constants.php (modified) (1 diff)
-
includes/class-woo-shiptimize.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
-
shiptimize.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
shiptimize-for-woocommerce/trunk/constants.php
r2800002 r2800481 4 4 define( 'SHIPTIMIZE_API_URL', 'https://api.pakketmail.nl/v3' ); 5 5 define( 'SHIPTIMIZE_BRAND', 'Shiptimize' ); 6 define( 'SHIPTIMIZE_VERSION', '3.1.5 4' );6 define( 'SHIPTIMIZE_VERSION', '3.1.56' ); 7 7 define( 'SHIPTIMIZE_CREATE_ACCOUNT', 'https://www.shiptimize.me/quote/' ); 8 8 define( 'SHIPTIMIZE_CHECKOUT', 0); -
shiptimize-for-woocommerce/trunk/includes/class-woo-shiptimize.php
r2800116 r2800481 303 303 304 304 /** 305 * Checks exclude classes if defined to determine if the rate is valid 306 **/ 307 public function is_rate_valid( $r , $package ) { 308 $options = get_option( 'woocommerce_' . $r->method_id . '_' . $r->instance_id . '_settings' ); 309 310 if( isset( $options['excludeclasses'] ) && $options['excludeclasses'] ) { 311 WooShiptimize::log( $r->label ); 312 $opt_exclude_classes = explode( ',', $options['excludeclasses'] ); 313 $contains_classes_to_exclude = false; 314 315 // Check if the package contains products that have at least one of the selected classes 316 foreach ( $package['contents'] as $key => $item ) { 317 foreach ( $opt_exclude_classes as $c2exclude ) { 318 $terms = get_the_terms( $item['product_id'], 'product_shipping_class' ); 319 if ( $terms ) { 320 foreach( $terms as $term ) { 321 $contains_classes_to_exclude |= $term->term_id == $c2exclude ; 322 } 323 } 324 } 325 } 326 327 WooShiptimize::log("contains class " . ( $contains_classes_to_exclude ? 1 : 0 )); 328 return !$contains_classes_to_exclude; 329 } 330 331 return true; 332 } 333 334 /** 305 335 * Allow users to choose, if free shipping, then hide anything not free 306 336 * Also check if exclude classes is set inside the shipping method 307 337 **/ 308 338 public function rates_filter ( $rates, $package ) { 339 309 340 // Check if hide not free enabled 310 341 if ( get_option('shiptimize_hide_not_free') ) { 311 342 $free = array(); 312 foreach ( $rates as $id => $r) { 313 314 if ($r->cost == 0) { 343 foreach ( $rates as $id => $r) { 344 if ( $r->cost == 0 && $this->is_rate_valid( $r, $package ) ) { 315 345 array_push($free, $r); 316 346 } 317 347 } 318 348 319 if ( !empty( $free) ) {349 if ( !empty( $free ) ) { 320 350 $rates = $free; 321 351 } 322 352 } 323 353 324 // /Check for exclude classes354 // Check for exclude classes 325 355 $newrates = array(); 326 356 foreach ( $rates as $id => $r) { 327 $options = get_option('woocommerce_' . $r->method_id . '_' . $r->instance_id . '_settings'); 328 329 if(isset($options['excludeclasses']) && $options['excludeclasses']) { 330 WooShiptimize::log($r->label); 331 332 $opt_exclude_classes = explode( ',', $options['excludeclasses']); 333 $contains_classes_to_exclude = false; 334 335 // Check if the package contains products that have at least one of the selected classes 336 foreach ( $package['contents'] as $key => $item ) { 337 foreach ( $opt_exclude_classes as $c2exclude ) { 338 $terms = get_the_terms( $item['product_id'], 'product_shipping_class' ); 339 if ( $terms ) { 340 foreach($terms as $term) { 341 $contains_classes_to_exclude |= $term->term_id == $c2exclude ; 342 } 343 } 344 } 345 } 346 347 WooShiptimize::log("contains class " . ( $contains_classes_to_exclude ? 1 : 0 )); 348 if ( !$contains_classes_to_exclude ) { 349 array_push($newrates,$r); 350 } 351 } 352 else { 353 array_push($newrates, $r); 354 } 355 356 $rates = $newrates; 357 } 358 359 return $rates; 357 if( $this->is_rate_valid($r, $package) ) { 358 array_push( $newrates,$r ); 359 } 360 } 361 362 return $newrates; 360 363 } 361 364 -
shiptimize-for-woocommerce/trunk/readme.txt
r2800067 r2800481 59 59 == Changelog == 60 60 61 = 3.1.56 - 2022-10-18 = 62 * fix - If hide shipping methods was enabled and only rates that can't display because of class constraints match, then no rates would not display. 63 61 64 = 3.1.55 - 2022-10-17 = 62 65 * enhancement - If plugin Advanced Shipping is installed and active allow sellers to specify certain classes where our shipping methods will not display at checkout. -
shiptimize-for-woocommerce/trunk/shiptimize.php
r2800059 r2800481 3 3 * Plugin Name: Shiptimize for WooCommerce 4 4 * Description: Shiptimize for WooCommerce 5 * Version: 3.1.5 55 * Version: 3.1.56 6 6 * Author: Shiptimize 7 7 * Author URI: https://shiptimize.me
Note: See TracChangeset
for help on using the changeset viewer.