Upon further testing, it seems that my programmatically populated cart must have some problem that causes it to be not accepted by Woocommerce on in the Checkout process.
When I tested the standard user method of Add to Cart, then Checkout, after filling in my details and clicking Place Order, I was indeed sent to the Thank You page. So clearly that process works.
Now the question is, why is my programmatically defined cart looking reasonable on the Checkout page, but obviously not good enough to pass the order creation phase?
This is how I setup the cart:
function foo_prepopulate_cart_action($post_object) {
if (is_null(WC()) || is_null(WC()->cart)) {
return;
}
$referrer = get_query_var('referrer', '');
WC()->cart->empty_cart();
$custom_data = array();
$custom_data['custom_data']['referrer'] = sanitize_text_field($referrer);
WC()->cart->add_to_cart(17, '1', '0', array(), $custom_data);
}