Disable Day Fee When Free Shipping Method is Selected
Add this code snippet to your site and it will disable the day fees when the user selects the Free Shipping method.
You can add this code to the functions.php of your active child theme or you can use the Code Snippet plugin.
<?php
/**
* Iconic WDS - remove day fees if free shipping is selected.
*
* @return void
*/
function iconic_wds_remove_day_fees() {
global $iconic_wds;
if ( empty( $iconic_wds ) ) {
return;
}
$post_data = filter_input( INPUT_POST, 'post_data' );
$data = array();
parse_str( $post_data, $data );
if ( ! empty( $data ) && ! empty( $data['shipping_method'] ) && is_array( $data['shipping_method'] ) ) {
$chosen_shipping_methods = $data['shipping_method'];
} else {
$chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods' );
}
if ( ! isset( $chosen_shipping_methods[0] ) ) {
return;
}
$chosen_shipping_method = $chosen_shipping_methods[0];
if ( false !== strpos( $chosen_shipping_method, 'free_shipping' ) ) {
WC()->session->__unset( 'jckwds_day_fee' );
}
}
add_action( 'woocommerce_checkout_update_order_review', 'iconic_wds_remove_day_fees', 11 );
Similarly, if you want to disable the fees for Local Pickup, you can do it by replacing ‘free_shipping’ in the above code snippet with ‘local_pickup’.
WooCommerce Delivery Slots
Let customers choose their preferred WooCommerce delivery date and time right from your WooCommerce checkout page. With WooCommerce Delivery Slots, you can set a flexible delivery schedule to suit you and your customers.
Was this helpful?
Please let us know if this article was useful. It is the best way to ensure our documentation is as helpful as possible.