I am creating a gift shop website where users can buy gifts for other users. So on every user profile i want to add a link "buy gift for this user" which takes you to the product page. After adding items to cart and checkout, a "gift recipient" (user-reference) field is already pre-filled with the name of the user from whose profile the shopping was initiated (not the name of the logged in user). Is this sort of thing possible in drupal 7? How can i achieve such? Thanks.
1 Answer
I don't know ready solution from the box for your use case but it's possible to implement it with Drupal Commerce and Line items functionality.
You can extend Line Item with the user reference field "gift recipient". User value will be saved on line item but not a product. Than everything is in your hands. E.g. you can click on option "Include this field on "Add to Cart" form. Or you can prepopulate this field using special get parameter in the "buy gift for this user" link.
For more information about extending Line Items see the video: http://vimeo.com/31459435