Advertisement
Guest User

Untitled

a guest
Dec 25th, 2014
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. // Load whatever product represents the item the customer will be
  2. // paying for and create a line item for it.
  3. $line_item = commerce_product_line_item_new($product, $quantity, $order->order_id);
  4.  
  5. // Save the line item to get its ID.
  6. commerce_line_item_save($line_item);
  7.  
  8.  
  9. //***this is the part that's not working. trying to set the field_notes field***
  10. $line_item_wrapper = entity_metadata_wrapper('commerce_line_item', $line_item);
  11. $line_item_wrapper->field_notes->set("Does this work??");
  12.  
  13.  
  14. // Save the line item to get its ID.
  15. commerce_line_item_save($line_item);
  16.  
  17. // Add the line item to the order using fago's rockin' wrapper.
  18. $order_wrapper = entity_metadata_wrapper('commerce_order', $order);
  19. $order_wrapper->commerce_line_items[] = $line_item;
  20.  
  21. // Save the order again to update its line item reference field.
  22. commerce_order_save($order);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement