Envío escalonado con múltiples opciones de tarifas de envío y precios

Recientemente configuré mi envío escalonado y leí este tutorial sobre esto, modifiqué su código al mío de esta manera:

add_filter( 'woocommerce_package_rates', 'bbloomer_woocommerce_tiered_shipping', 10, 2 ); function bbloomer_woocommerce_tiered_shipping( $rates, $package ) { $thresholdsmall = 200; $thresholdbig = 899.99; if ( WC()->cart->subtotal cart->subtotal > $thresholdbig ) { ( isset( $rates['free_shipping:19'] ) ) ; ( isset( $rates['free_shipping:21'] ) ) ; unset( $rates['free_shipping:18'] ); unset( $rates['free_shipping:14'] ); unset( $rates['free_shipping:4'] ); ( isset( $rates['flat_rate:25'] ) ) ; ( isset( $rates['flat_rate:26'] ) ) ; unset( $rates['flat_rate:22'] ); unset( $rates['flat_rate:23'] ); unset( $rates['flat_rate:24'] ); unset( $rates['flat_rate:9'] ); unset( $rates['flat_rate:15'] ); unset( $rates['flat_rate:16'] ); } else { ( isset( $rates['free_shipping:4'] ) ) ; ( isset( $rates['free_shipping:18'] ) ) ; unset( $rates['free_shipping:19'] ); unset( $rates['free_shipping:21'] ); unset( $rates['free_shipping:14'] ); ( isset( $rates['flat_rate:9'] ) ) ; ( isset( $rates['flat_rate:24'] ) ) ; ( isset( $rates['flat_rate:23'] ) ) ; ( isset( $rates['flat_rate:22'] ) ) ; unset( $rates['flat_rate:15'] ); unset( $rates['flat_rate:16'] ); unset( $rates['flat_rate:25'] ); unset( $rates['flat_rate:26'] ); } return $rates; } 

En este momento, cuando mi carro está por debajo de 200, solo se muestran free_shipping: 4 y flat_rate: 9.

¿Qué debo modificar para incluir free_shipping: 14, flat_rate: 15, flat_rate: 16?

Editar: Para aclarar esto intenté hacer un envío de 3 niveles. El total del carrito es menos de 200, el total del carrito es más de 200 pero menos de 900, y el total del carrito es más de 900. Las diferentes tarifas corresponden a las diferentes opciones / compañías de envío. enter image description here

Aquí están las diferentes referencias de tarifas de envío

• CARRITO BAJO 200

 - Fedex Ground (Free) => free_shipping:14 - Fedex 2 days ($20) => flat_rate:15 - Fedex Stand Overnight ($45) => flat_rate:16 

• CARRO BAJO 900

 - USPS Priority (free) => free_shipping:4 - USPS Express ($45) => flat_rate:9 - Fedex 2 days AM ($20) => flat_rate:22 - Fedex Stand Overnight ($40) => flat_rate:23 - Fedex Pty. Overnight ($50) => flat_rate:24 

• CARRITO ENTRE 200 y (debajo) 900

 - Fedex Stand 2 days (Free) => free_shipping:18 

• CARRO HASTA 900

 - USPS Express (free) => free_shipping:19 - Fedex Stand. Overnight (Free) => free_shipping:21 - Fedex Pty. Overnight ($20) => flat_rate:25 - Fedex Pty. Saturday Deliv. ($40) => flat_rate:26 

Aquí he tratado de configurar todo este complicado sistema de tarifas de envío en este código, ya que hay muchos errores y errores en su código. He comentado el código lo mejor que puedo.

Aquí está ese código:

 add_filter( 'woocommerce_package_rates', 'shipping_rates_based_on_cart_amount', 10, 2 ); function shipping_rates_based_on_cart_amount( $rates, $package ) { if ( WC()->cart->subtotal < 900 ) { ## Under 900 unset( $rates['free_shipping:19'] ); // remove: USPS Express (free) unset( $rates['free_shipping:21'] ); // remove: Fedex Stand. Overnight (Free) unset( $rates['flat_rate:25'] ); // remove: Fedex Pty. Overnight ($20) unset( $rates['flat_rate:26'] ); // remove: Fedex Pty. Saturday Deliv. ($40) if ( WC()->cart->subtotal < 200 ) { ## Under 200 // For => "Fedex Stand Overnight ($45)" if ( isset( $rates['flat_rate:16'] ) ) { unset( $rates['flat_rate:23'] ); // remove: Fedex Stand Overnight ($40) unset( $rates['flat_rate:24'] ); // remove: Fedex Pty. Overnight ($50) } // For => "Fedex 2 days ($20) " if ( isset( $rates['flat_rate:15'] ) ) unset( $rates['flat_rate:22'] ); // remove: Fedex 2 days AM ($20) } else { ## Between 200 and under 900 // For => "Fedex Stand 2 days (free)" if ( isset( $rates['free_shipping:18'] ) ) { unset( $rates['free_shipping:14'] ); // Fedex Ground (Free) unset( $rates['flat_rate:15'] ); // remove: Fedex 2 days ($20) } // For => "Fedex Stand Overnight ($40)" if ( isset( $rates['flat_rate:23'] ) ) unset( $rates['flat_rate:16'] ); // remove: Fedex Stand Overnight ($45) } } else { ## From 900 (up to 900) ## 1) FEDEX // For => "Fedex Stand. Overnight (Free)" if ( isset( $rates['free_shipping:21'] ) ) { unset( $rates['free_shipping:18'] ); // remove: Fedex Stand 2 days (Free) unset( $rates['free_shipping:14'] ); // remove: Fedex Ground (Free) } // For => "Fedex Pty. Overnight ($20)" // Or for => "Fedex Pty. Saturday Deliv. ($40)" if ( isset( $rates['flat_rate:25'] ) || isset( $rates['flat_rate:26'] ) ) { unset( $rates['flat_rate:15'] ); // remove: Fedex 2 days ($20) unset( $rates['flat_rate:22'] ); // remove: Fedex 2 days AM ($20 unset( $rates['flat_rate:16'] ); // remove: Fedex Stand Overnight ($45) unset( $rates['flat_rate:23'] ); // remove: Fedex Stand Overnight ($40) unset( $rates['flat_rate:24'] ); // remove: Fedex Pty. Overnight ($50) unset( $rates['flat_rate:9'] ); // remove: USPS Express ($45) } ## 2) USPS if ( isset( $rates['free_shipping:19'] ) ) // For => "USPS Express (free)" unset( $rates['free_shipping:4'] ); // remove: USPS Priority (free) } return $rates; } 

Este código debería funcionar …

Tendrá que actualizar los datos de envío en caché: deshabilitar, guardar y habilitar, guardar los métodos de envío relacionados para la zona de envío actual, en la configuración de envío woocommerce.