I ended up setting it directly on the order instead of on the cart;
Here is the method I created and used in my "complete purchase" processing :
function addShippingToOrder( $order, $shipping_amount, $shipping_name ) {
$shipping_tax = array();
$shipping_rate = new WC_Shipping_Rate( '', $shipping_name,
$shipping_amount, $shipping_tax,
'custom_shipping_method' );
$order->add_shipping($shipping_rate);
}
I also needed to save the shipping amount when I was in the cart logic, and then retrieve it when I was in the order logic, and I did that with a custom cart "session" variable :
WC()->session->set( 'my_custom_shipping_amount', $amt );
and
WC()->session->get( 'my_custom_shipping_amount' )
This is a very simple answer, but it took me the longest time to figure out - I even ended up creating a plugin especially for debugging changes to WC_Orders : WooCommerce Order Debugger Plugin
WC()->cart->shipping_amount
but onlyWC()->cart->shipping_total
– Reigel