I'm using the Commerce framework. I use the commerce_license and commerce_recurring modules to sell subscription memberships to users.

I'm trying to implement gift memberships, so that User A (the "purchaser") can pay for a subscription for User B (the "recipient").

So, when the purchaser checks out, I need to prompt them for the recipient's email address. How can I do this?

(I can imagine other scenarios where you might want to prompt the customer for a "gift message", or a line of custom text to print on a personalized mug, or something like that.)

I know that the Commerce framework has product attributes, which allow customers to specify things such as color, size, etc. However, as far as I can tell, this doesn't support free-text fields – only radio buttons, select boxes, and the like.

Any ideas?

Bonus question: I'll need to validate the recipient's email address before allowing the purchase, so I can make sure they don't already have a subscription. Any thoughts on how to approach that?


  • I'll need to validate the recipient's email address before allowing the purchase use hook_form_FORM_ID_alter() where the email address appears and add a custom validation function to the #validation array so that it performs this check.
    – No Sssweat
    Dec 22, 2020 at 15:03

1 Answer 1


Add a "Recipient email" field to your order item type and expose it to the Add to Cart form. It's up to you then to override the normal fulfillment process that creates entities for the current user, directing them to another user account instead. You'll also need to accommodate the edge case of a customer buying on behalf of a person who doesn't have a user account yet.

cf. https://docs.drupalcommerce.org/commerce2/developer-guide/orders/order-items

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.