title: Woocommerce: how do I add metadata to a cart item?
body: <p>I have a digital product which is described by a quantity and a price, but which also needs 3 more numbers to completely specify it (Unix dates, etc). Problem: how do I get these numbers into the cart?</p>
  
  <p>As far as I can see, there are 2 possible ways to handle this:</p>
  
  <ol>
  <li>A product variation</li>
  <li>A product custom field</li>
  </ol>
  
  <p>It looks like variations can only handle <em>discrete</em> values with a limited range (ie. red/yellow/green, S/M/L, etc), and can't handle general integers, like dates. That leaves custom fields. I think I'm right in saying that custom fields are ordinary meta data on the product post page, so I can handle them with <code>get_post_meta</code> and <code>update_post_meta</code>.</p>
  
  <p>So, if I go for custom fields, then I would update the product page field during ordering, and then I would read back the field during checkout, when the <code>WC_Order</code> is created, and add the field to the new order. However, this won't work. I can't change metadata on the product page, because the product is global to all customers, and this operation would interfere with other customers. <strong>In other words, you can't store order-specific information in a product, so neither of these options would work.</strong></p>
  
  <p>So, how do I store temporary product metadata and pass it between the ordering and checkout phases (ie. between <code>WC_Cart</code> and <code>WC_Order</code>)?</p>
  
  <p>One option would be to store it as <em>user</em> metadata (or as session data?), but there's got to be a better way - any ideas?</p>