public function update_product($item, $product, $args)
{
wc_deprecated_function('WC_Order::update_product', '2.7', 'Interact with WC_Order_Item_Product class');
if (is_numeric($item)) {
$item = $this->get_item($item);
}
if (!is_object($item) || !$item->is_type('line_item')) {
return false;
}
if (!$this->get_id()) {
$this->save();
// Order must exist
}
// BW compatibility with old args
if (isset($args['totals'])) {
foreach ($args['totals'] as $key => $value) {
if ('tax' === $key) {
$args['total_tax'] = $value;
} elseif ('tax_data' === $key) {
$args['taxes'] = $value;
} else {
$args[$key] = $value;
}
}
}
// Handly qty if set
if (isset($args['qty'])) {
if ($product->backorders_require_notification() && $product->is_on_backorder($args['qty'])) {
$item->add_meta_data(apply_filters('woocommerce_backordered_item_meta_name', __('Backordered', 'woocommerce')), $args['qty'] - max(0, $product->get_stock_quantity()), true);
}
$args['subtotal'] = $args['subtotal'] ? $args['subtotal'] : wc_get_price_excluding_tax($product, array('qty' => $args['qty']));
$args['total'] = $args['total'] ? $args['total'] : wc_get_price_excluding_tax($product, array('qty' => $args['qty']));
}
$item->set_order_id($this->get_id());
$item->set_props($args);
$item->save();
do_action('woocommerce_order_edit_product', $this->get_id(), $item->get_id(), $args, $product);
return $item->get_id();
}