// Add Delivery Fee if cart total less than $100 AND Distance Rate shipping selected add_action( 'woocommerce_cart_calculate_fees', 'fivetwelve_conditional_delivery_fee', 20, 1 ); function fivetwelve_conditional_delivery_fee( $cart ) { if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return; global $woocommerce; // Get the current cart total $cart_total = $woocommerce->cart->cart_contents_total; // Move forward if cart total is less than $100 if ( $cart_total < 100 ) { // Get the currently selected shipping method $chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods' ); // If shipping method is local delivery, add $10 delivery fee if( in_array( 'szbd-shipping-method:10', $chosen_shipping_methods ) ) $cart->add_fee( 'Delivery Fee', 10, false ); } }