Created
May 4, 2025 01:59
-
-
Save shameemreza/ae0e13dd0de4a8f16a4173a2a52fa775 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
add_action( 'woocommerce_cart_calculate_fees', function() { | |
if ( wcs_cart_contains_renewal() ) { | |
return; | |
} | |
$subscription_box_id = 54; | |
$cart_contents = WC()->cart->get_cart_contents(); | |
foreach ( WC()->cart->get_cart() as $cart_item ) { | |
if ( empty( $cart_item[ 'wcsatt_data'][ 'active_subscription_scheme' ] ) ) { | |
continue; | |
} | |
$product = $cart_item[ 'data' ]; | |
if ( $subscription_box_id == $product->get_id() ) { | |
WC()->cart->add_fee( sprintf( __( 'Sign Up fee for "%1$s"', 'woocommerce_all_products_for_subscriptions' ), $product->get_title() ),50 ); | |
} | |
} | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment