Set order id for fees & shipping on legacy api
If order ID is not set, the item will be created, but will not be associated with the order being updated.
This commit is contained in:
parent
62240c6bbd
commit
8e81a7e4e0
|
@ -1019,6 +1019,7 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
|
||||
$rate = new WC_Shipping_Rate( $shipping['method_id'], isset( $shipping['method_title'] ) ? $shipping['method_title'] : '', isset( $shipping['total'] ) ? floatval( $shipping['total'] ) : 0, array(), $shipping['method_id'] );
|
||||
$item = new WC_Order_Item_Shipping();
|
||||
$item->set_order_id( $order->get_id() );
|
||||
$item->set_shipping_rate( $rate );
|
||||
$shipping_id = $item->save();
|
||||
|
||||
|
@ -1068,6 +1069,7 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
}
|
||||
|
||||
$item = new WC_Order_Item_Fee();
|
||||
$item->set_order_id( $order->get_id() );
|
||||
$item->set_name( sanitize_title( $fee['title'] ) );
|
||||
$item->set_total( isset( $fee['total'] ) ? floatval( $fee['total'] ) : 0 );
|
||||
|
||||
|
|
|
@ -1069,6 +1069,7 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
|
||||
$rate = new WC_Shipping_Rate( $shipping['method_id'], isset( $shipping['method_title'] ) ? $shipping['method_title'] : '', isset( $shipping['total'] ) ? floatval( $shipping['total'] ) : 0, array(), $shipping['method_id'] );
|
||||
$item = new WC_Order_Item_Shipping();
|
||||
$item->set_order_id( $order->get_id() );
|
||||
$item->set_shipping_rate( $rate );
|
||||
$shipping_id = $item->save();
|
||||
|
||||
|
@ -1118,6 +1119,7 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
}
|
||||
|
||||
$item = new WC_Order_Item_Fee();
|
||||
$item->set_order_id( $order->get_id() );
|
||||
$item->set_name( sanitize_title( $fee['title'] ) );
|
||||
$item->set_total( isset( $fee['total'] ) ? floatval( $fee['total'] ) : 0 );
|
||||
|
||||
|
|
Loading…
Reference in New Issue