Created
March 23, 2026 12:00
-
-
Save xlplugins/a21614c1f6b9c2488478c43a4ee328fb to your computer and use it in GitHub Desktop.
free shipping for specific checkout
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
| add_filter( 'woocommerce_package_rates', 'wfacp_force_free_shipping_on_funnel_pages', 100, 2 ); | |
| /** | |
| * Filter shipping rates to force free shipping on target FunnelKit checkout pages. | |
| * | |
| * @param array $rates Available shipping rates. | |
| * @param array $package Shipping package data. | |
| * | |
| * @return array Filtered shipping rates. | |
| */ | |
| function wfacp_force_free_shipping_on_funnel_pages( $rates, $package ) { | |
| //checkout page IDs — add your page IDs here. | |
| $free_shipping_pages = array(2567 , 2916 ); | |
| if ( empty( $free_shipping_pages ) ) { | |
| return $rates; | |
| } | |
| if ( ! class_exists( 'WFACP_Common' ) ) { | |
| return $rates; | |
| } | |
| $current_page_id = WFACP_Common::get_id(); | |
| if ( empty( $current_page_id ) || ! in_array( (int) $current_page_id, $free_shipping_pages, true ) ) { | |
| return $rates; | |
| } | |
| $free_rates = array(); | |
| foreach ( $rates as $rate_id => $rate ) { | |
| if ( 'free_shipping' === $rate->get_method_id() ) { | |
| $free_rates[ $rate_id ] = $rate; | |
| } | |
| } | |
| if ( ! empty( $free_rates ) ) { | |
| return $free_rates; | |
| } | |
| $free_rate = new WC_Shipping_Rate( | |
| 'free_shipping:funnelkit_override', | |
| __( 'Free Shipping', 'woocommerce' ), | |
| 0, | |
| array(), | |
| 'free_shipping' | |
| ); | |
| return array( 'free_shipping:funnelkit_override' => $free_rate ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment