Skip to content

Instantly share code, notes, and snippets.

@pramodjodhani
Created January 13, 2025 06:56
Show Gist options
  • Save pramodjodhani/af583d7a6f3928fac8afe38190496f35 to your computer and use it in GitHub Desktop.
Save pramodjodhani/af583d7a6f3928fac8afe38190496f35 to your computer and use it in GitHub Desktop.
Iconic WDS - Disable day fee for local pickup.
<?php
/**
* Iconic WDS - Disable day fee for local pickup.
*
* @return void
*/
function disable_day_fee_for_local_pickup() {
global $iconic_wds;
if ( ! isset( $iconic_wds ) ) {
return;
}
$chosen_delivery_method = $iconic_wds->get_chosen_shipping_method();
if ( empty( $_POST['post_data'] ) ) {
return;
}
$post_data = $_POST['post_data'];
$posted_data = array();
parse_str( $post_data, $posted_data );
$chosen_date_ymd = $posted_data['jckwds-delivery-date-ymd'];
$today_ymd = wp_date( 'Ymd' );
if ( str_contains( $chosen_delivery_method, 'local_pickup' ) && $chosen_date_ymd === $today_ymd ) {
WC()->session->set( 'jckwds_same_day_fee', 0 );
WC()->session->set( 'jckwds_day_fee', 0 );
}
}
add_action( 'woocommerce_cart_calculate_fees', 'disable_day_fee_for_local_pickup', 9 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment