Working with WooCommerce, I have some custom code that moves custom data from cart items to line items. This is what I'm doing:
add_action('woocommerce_checkout_create_order_line_item', 'tls_checkout_create_order_line_item', 10, 4 );
function tls_checkout_create_order_line_item( $item, $cart_item_key, $values, $order ) {
if (isset($values['custom_data']['tls_associated_line_item'])) {
$item->update_meta_data('_tls_associated_order_item', $values['custom_data']['tls_associated_line_item']);
}
else{
$item->update_meta_data('_tls_item_id', $cart_item_key);
}
}
The order items are updated appropriately, but this code prevents the cart from clearing when the order is completed (maybe because the hash is changing?). Is there any way to update order item meta without causing this interruption?