/**
* Add line items to the order.
*
* @param WC_Order $order
*/
protected function create_order_line_items(&$order)
{
foreach (WC()->cart->get_cart() as $cart_item_key => $values) {
$product = $values['data'];
$item = new WC_Order_Item_Product();
$item->set_props(array('quantity' => $values['quantity'], 'name' => $product ? $product->get_name() : '', 'tax_class' => $product ? $product->get_tax_class() : '', 'product_id' => $product ? $product->is_type('variation') ? $product->get_parent_id() : $product->get_id() : 0, 'variation_id' => $product && $product->is_type('variation') ? $product->get_id() : 0, 'variation' => $values['variation'], 'subtotal' => $values['line_subtotal'], 'total' => $values['line_total'], 'subtotal_tax' => $values['line_subtotal_tax'], 'total_tax' => $values['line_tax'], 'taxes' => $values['line_tax_data']));
$item->set_backorder_meta();
// Set this to pass to legacy actions.
$item->legacy_values = $values;
$item->legacy_cart_item_key = $cart_item_key;
$order->add_item($item);
}
}