Delivery Slots
Disable Day Fee When Free Shipping Method is Selected
Coming soon: Iconic Delivery Slots is becoming part of Kadence Shop Kit. You may see both names used while we update the product, documentation, and customer experience.
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’.
Filed under
Uncategorized
Was this page helpful?
Thanks for the feedback!