Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // WooCommerce - Hide 2nd class if free shipping is available
- add_filter( 'woocommerce_package_rates', 'custom_package_rates', 100 );
- function custom_package_rates( $rates ) {
- $has_free = false;
- foreach ( $rates as $rate_id => $rate ) {
- // free must be first
- if ( 'free_shipping' === $rate->method_id ) {
- $has_free = true;
- }
- if ( $has_free & '2nd Class' == $rate->label ) {
- unset( $rates[$rate_id] );
- }
- }
- return $rates;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement