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?
Thanks!
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 '20 at 15:03