Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save shameemreza/ae0e13dd0de4a8f16a4173a2a52fa775 to your computer and use it in GitHub Desktop.
Save shameemreza/ae0e13dd0de4a8f16a4173a2a52fa775 to your computer and use it in GitHub Desktop.
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