Forzar calculo de gasto de envío al añadir producto al carrito de compras WC

Forzar calculo de gasto de envío al añadir producto al carrito de compras WC.

function woocommerce_custom_price_to_cart_item( $cart_object ) {  
//if( !WC()->session->__isset( "reload_checkout" )) {

// Mandatory to make it work with shipping methods
foreach ( WC()->cart->get_shipping_packages() as $package_key => $package ){
WC()->session->set( "shipping_for_package_" . $package_key, true );
}
WC()->cart->calculate_shipping();
//}
}
add_action( "woocommerce_before_calculate_totals", "woocommerce_custom_price_to_cart_item", 99 );