WC_Abstract_Legacy_Order::update_shipping() public WC 1.0
Update shipping method for order.
Note this does not update the order total.
{} Это метод класса: WC_Abstract_Legacy_Order{}
Хуки из метода
Возвращает
Число. updated order item ID
Использование
$WC_Abstract_Legacy_Order = new WC_Abstract_Legacy_Order(); $WC_Abstract_Legacy_Order->update_shipping( $item, $args );
- $item(объект/число) (обязательный)
- -
- $args(массив) (обязательный)
- -
Код WC_Abstract_Legacy_Order::update_shipping() WC Abstract Legacy Order::update shipping WC 5.0.0
public function update_shipping( $item, $args ) {
wc_deprecated_function( 'WC_Order::update_shipping', '3.0', 'an interaction with the WC_Order_Item_Shipping class' );
if ( is_numeric( $item ) ) {
$item = $this->get_item( $item );
}
if ( ! is_object( $item ) || ! $item->is_type( 'shipping' ) ) {
return false;
}
if ( ! $this->get_id() ) {
$this->save(); // Order must exist
}
// BW compatibility for old args
if ( isset( $args['cost'] ) ) {
$args['total'] = $args['cost'];
}
$item->set_order_id( $this->get_id() );
$item->set_props( $args );
$item->save();
$this->calculate_shipping();
do_action( 'woocommerce_order_update_shipping', $this->get_id(), $item->get_id(), $args );
return $item->get_id();
}