Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Drupal Commerce Rules Component to send an email to the customer
{ "rules_send_message_to_customer" : {
"LABEL" : "Send message to customer",
"PLUGIN" : "rule set",
"REQUIRES" : [ "rules" ],
"USES VARIABLES" : {
"order" : { "label" : "Order", "type" : "commerce_order" },
"subject" : { "label" : "Subject", "type" : "text" },
"body" : { "label" : "Body", "type" : "text" }
},
"RULES" : [
{ "RULE" : {
"PROVIDE" : { "entity_fetched" : { "customer_billing_profile" : "Customer billing profile" } },
"IF" : [
{ "entity_has_field" : { "entity" : [ "order" ], "field" : "commerce_customer_billing" } }
],
"DO" : [
{ "entity_fetch" : {
"USING" : {
"type" : "commerce_customer_profile",
"id" : [ "order:commerce-customer-billing:profile-id" ]
},
"PROVIDE" : { "entity_fetched" : { "customer_billing_profile" : "Customer billing profile" } }
}
}
],
"LABEL" : "Fetch the billing profile"
}
},
{ "RULE" : {
"IF" : [
{ "entity_has_field" : {
"entity" : [ "customer-billing-profile" ],
"field" : "commerce_customer_address"
}
}
],
"DO" : [
{ "mail" : {
"to" : [ "order:mail" ],
"subject" : "[STORE NAME] Order update: [order:order-number] - [subject:value]",
"message" : "Hello [customer-billing-profile:commerce-customer-address:name-line],\u000D\u000A\u000D\u000AOur team has new information about your order #[order:order-number].\u000D\u000A\u000D\u000A[body:value]\u000D\u000A\u000D\u000AThanks again for shopping with STORE NAME, and remember if you need additional information or assistance with your order, you can \u003Ca href=\u0022[site:url]contact\u002Fcontact-us\u0022\u003Econtact us online\u003C\u002Fa\u003E or phone us at (###) ###-####\u000D\u000A\u000D\u000AThanks!\u000D\u000A\u000D\u000A--The STORE NAME Team",
"language" : [ "" ]
}
}
],
"LABEL" : "Send the email"
}
}
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.