I am trying to add product in cart with cart item meta data. Here is the code :
$cart_item_data = array();
$cart_item_data[\'add_size\'] = array(\'PR CODE\'=>
After I spent the last hours figuring things out I found out that the method has actually changed a bit over the time.
Method:
$woocommerce->cart->add_to_cart( $product_id, $quantity, $variation_id, $variation, $cart_item_data );
In my case I needed to do this and the custom meta data got automatically displayed in the cart and order:
$woocommerce->cart->add_to_cart($product_id, $quantity, NULL, NULL, array('your_key' => 'your_value'));
You can find out more here: https://woocommerce.wp-a2z.org/oik_api/wc_cartadd_to_cart/