Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- { "rules_create_user_when_adding_order" : {
- "LABEL" : "Create user when adding order",
- "PLUGIN" : "reaction rule",
- "REQUIRES" : [ "rules", "commerce", "commerce_checkout", "entity" ],
- "ON" : [ "commerce_order_insert" ],
- "IF" : [
- { "data_is" : { "data" : [ "commerce-order:uid" ], "value" : "0" } },
- { "NOT entity_exists" : {
- "type" : "user",
- "property" : "mail",
- "value" : [ "commerce-order:mail" ]
- }
- },
- { "NOT data_is" : {
- "data" : [ "commerce-order:mail" ],
- "value" : [ "site:current-user:mail" ]
- }
- },
- { "NOT data_is_empty" : { "data" : [ "commerce-order:mail" ] } },
- { "data_is" : { "data" : [ "commerce-order:type" ], "value" : "commerce_order" } }
- ],
- "DO" : [
- { "entity_create" : {
- "USING" : {
- "type" : "user",
- "param_name" : [ "commerce-order:mail" ],
- "param_mail" : [ "commerce-order:mail" ]
- },
- "PROVIDE" : { "entity_created" : { "new_user" : "New User" } }
- }
- },
- { "data_set" : { "data" : [ "new-user:status" ], "value" : "1" } },
- { "entity_save" : { "data" : [ "new-user" ], "immediate" : 1 } },
- { "entity_query" : {
- "USING" : {
- "type" : "user",
- "property" : "mail",
- "value" : [ "commerce-order:mail" ],
- "limit" : "1"
- },
- "PROVIDE" : { "entity_fetched" : { "account_fetched" : "account_fetched" } }
- }
- },
- { "LOOP" : {
- "USING" : { "list" : [ "account-fetched" ] },
- "ITEM" : { "list_item" : "Current list item" },
- "DO" : [
- { "send_account_email" : { "account" : [ "list-item" ], "email_type" : "register_admin_created" } },
- { "data_set" : { "data" : [ "commerce-order:uid" ], "value" : [ "list-item:uid" ] } },
- { "data_set" : {
- "data" : [ "commerce-order:commerce-customer-billing:uid" ],
- "value" : [ "list-item:uid" ]
- }
- },
- { "data_set" : {
- "data" : [ "commerce-order:commerce-customer-shipping:uid" ],
- "value" : [ "list-item:uid" ]
- }
- }
- ]
- }
- }
- ]
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement