Merging two 'tables' (function outputs) 1 to 1
Just assign a unique index in both tables, then use that for the join:

SELECT order_details, product_id, quantity, order_item_id
FROM (SELECT order_item_id, product_id, quantity,
             row_number() OVER (PARTITION BY product_id, quantity) AS indx
      FROM order_items) AS items
JOIN (SELECT order_details, product_id, quantity,
             row_number() OVER (PARTITION BY product_id, quantity) AS indx
      FROM order_details) AS details
USING (product_id, quantity, indx);