I have a drupal commerce form and I'd like it to send me an email with all the data from the form the user filled out every time they submit the form.

Is this possible?


Not sure what a "drupal commerce" form is. There are two major kinds of forms in Drupal Commerce, including the add-to-cart form and the checkout form. Both forms include actions in the Rules module that would let you send an email should one of them get submitted.

Here's a rule that proves the point for add-to-cart (though I would not recommend spamming yourself this way):

{ "rules_spam_yourself" : {
"LABEL" : "Spam Yourself",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "commerce_cart" ],
"ON" : { "commerce_cart_product_add" : [] },
"DO" : [
  { "mail" : {
      "to" : [ "site:mail" ],
      "subject" : "Product added!",
      "message" : "\/\/ Product\r\nProduct Added: [commerce-product:title] ([commerce-product:sku])\r\nQuantity: [quantity:value]\r\n\r\n\/\/ Order\r\nOrder ID: [commerce-order:order-id]\r\nOrder Number: [commerce-order:order-number]\r\n\r\nOrder Status: [commerce-order:status-title]\t\r\nOrder State: [commerce-order:state-title]\r\n\r\nCreated: [commerce-order:created]\r\nUpdated: [commerce-order:changed]\r\n\r\n\/\/ Customer\r\nCustomer Email Address: [commerce-order:mail]\r\n\r\n\/\/ Actions\r\nCustomer View: [commerce-order:customer-url]\r\nAdministrative View: [commerce-order:admin-url]\r\n",
      "language" : [ "" ]
  • 1
    Slightly more useful comment: If you want custom field data from the add-to-cart or checkout, those can be found in the [order] or [line-item] tokens most often. – joshmiller Jan 8 '16 at 21:06
  • I see. And would the best way to discover this then be to just test it manually or can I use devel module to find the proper syntax to use for referencing those fields in your opinion? – Sage Jan 9 '16 at 21:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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