add_action( 'woocommerce_before_calculate_totals', 'change_subscription_signup_fee', 1000, 1 );
function change_subscription_signup_fee( $cart ) {
if (is_admin() && !defined('DOING_AJAX'))
return;
if ( did_action( 'woocommerce_before_calculate_totals' ) >= 2 )
return;
// Loop through cart items
foreach ( $cart->get_cart() as $cart_item ) {
// Check that product custom cart item data "alredy_have_number" exist and is true
if( isset($cart_item['alredy_have_number']) && $cart_item['alredy_have_number'] ) {
// Check if subscription products
if ( in_array( $cart_item['data']->get_type(), ['subscription', 'subscription_variation']) ) {
// Change subscription Sign up fee
$cart_item['data']->update_meta_data('_subscription_sign_up_fee', 0.90);
}
}
}
}