WC_REST_Paypal_Standard_Controller::update_shipping_method_and_totals_for_order
Update the shipping method for the order, and then recompute the order totals.
Method of the class: WC_REST_Paypal_Standard_Controller{}
No Hooks.
Returns
void. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->update_shipping_method_and_totals_for_order( $order, $shipping_option_id ): void;
- $order(WC_Order) (required)
- The order object.
- $shipping_option_id(string) (required)
- The shipping option id.
WC_REST_Paypal_Standard_Controller::update_shipping_method_and_totals_for_order() WC REST Paypal Standard Controller::update shipping method and totals for order code WC 11.2.2
private function update_shipping_method_and_totals_for_order( $order, $shipping_option_id ): void {
// Remove and recreate the shipping lines for the order.
$order->remove_order_items( 'shipping' );
$packages = WC()->shipping()->get_packages();
WC()->checkout()->create_order_shipping_lines( $order, array( $shipping_option_id ), $packages );
// Update the order totals based on the updated shipping method and any relevant taxes.
$order->calculate_totals( true );
}