Created
November 22, 2022 06:32
-
-
Save pramodjodhani/d32005327b4ebf9c975e90ef4757be08 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Iconic WDS - disable Fee for local pickup. | |
| * | |
| * @return void | |
| */ | |
| function iconic_wds_disable_fees_for_flatrate() { | |
| $shipping_methods = WC()->session->get( 'chosen_shipping_methods' ); | |
| $post_data = filter_input( INPUT_POST, 'post_data' ); | |
| $data = array(); | |
| parse_str( $post_data, $data ); | |
| if ( empty( $data['shipping_method'] ) ) { | |
| return; | |
| } | |
| $shipping_methods = $data['shipping_method']; | |
| if ( empty( $shipping_methods ) || ! is_array( $shipping_methods ) ) { | |
| return; | |
| } | |
| // Disable fees for other shipping methods except flat_rate. | |
| if ( false === strpos( $shipping_methods[0], 'flat_rate' ) ) { | |
| WC()->session->__unset( 'jckwds_same_day_fee' ); | |
| } | |
| } | |
| add_action( 'woocommerce_cart_calculate_fees', 'iconic_wds_disable_fees_for_flatrate', 9 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment