I've been trying numerous solutions to programmatically set the price of shipping (per order) via Woocommerce. I'm having no luck
I have tried overwriting the meta value for the item:
update_post_meta( $woo_order_id, '_order_shipping', $new_ship_price );
Also tried something along the lines of this [Question/Answer][1]
$item_ship = new WC_Order_Item_Shipping();
$item_ship->set_name( "flat_rate" );
$item_ship->set_amount( $new_ship_price );
$item_ship->set_tax_class( '' );
$item_ship->set_tax_status( 'none' );
// Add Shipping item to the order
$order->add_item( $item_ship );
But neither seem to work.
Any pointers most welcome.
Similar thread: Add a fee to an order programmatically in Woocommerce 3
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…