Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter( 'woocommerce_package_rates', 'add_shipping_option_base_fee', 10, 2 );
- function add_shipping_option_base_fee( $rates, $package ) {
- foreach( $rates as $key => $rate ) {
- // reset defaults
- $highest_length = 0;
- // Do not apply base fee if not the right option
- if( $rate->id !== 'betrs_shipping:1-1' ) continue;
- // find highest priority class (BE Table Rate Shipping Only)
- foreach( $package['contents'] as $key => $values ) {
- $item_length = $values[ 'data' ]->get_length();
- if( $item_length > $highest_length ) {
- $highest_length = $item_length;
- }
- }
- // Add $5 surcharge on orders with items larger than 21cm
- if( $highest_length > 21 ) {
- $rates[ $key ]->cost += 5.00;
- }
- }
- return $rates;
- }
Add Comment
Please, Sign In to add comment