Advertisement
MrJoshMiller

Anonymous Checkout Create New User Name as Billing Name

Dec 17th, 2012
703
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. { "rules_create_a_new_account_for_an_anonymous_order_jm" : {
  2.     "LABEL" : "Create a new account for an anonymous order (jm)",
  3.     "PLUGIN" : "reaction rule",
  4.     "WEIGHT" : "2",
  5.     "REQUIRES" : [ "rules", "commerce", "commerce_checkout" ],
  6.     "ON" : [ "commerce_checkout_complete" ],
  7.     "IF" : [
  8.       { "data_is" : { "data" : [ "commerce-order:uid" ], "value" : "0" } },
  9.       { "NOT entity_exists" : {
  10.           "type" : "user",
  11.           "property" : "mail",
  12.           "value" : [ "commerce-order:mail" ]
  13.         }
  14.       },
  15.       { "data_is" : { "data" : [ "commerce-order:type" ], "value" : "commerce_order" } }
  16.     ],
  17.     "DO" : [
  18.       { "entity_create" : {
  19.           "USING" : {
  20.             "type" : "user",
  21.             "param_name" : "[commerce-order:commerce-customer-billing]",
  22.             "param_mail" : [ "commerce-order:mail" ]
  23.           },
  24.           "PROVIDE" : { "entity_created" : { "account_created" : "Created account" } }
  25.         }
  26.       },
  27.       { "data_set" : { "data" : [ "account-created:status" ], "value" : 1 } },
  28.       { "entity_save" : { "data" : [ "account-created" ], "immediate" : 1 } },
  29.       { "entity_query" : {
  30.           "USING" : {
  31.             "type" : "user",
  32.             "property" : "mail",
  33.             "value" : [ "commerce-order:mail" ],
  34.             "limit" : 1
  35.           },
  36.           "PROVIDE" : { "entity_fetched" : { "account_fetched" : "Fetched account" } }
  37.         }
  38.       },
  39.       { "LOOP" : {
  40.           "USING" : { "list" : [ "account-fetched" ] },
  41.           "ITEM" : { "list_item" : "Current list item" },
  42.           "DO" : [
  43.             { "send_account_email" : { "account" : [ "list-item" ], "email_type" : "register_admin_created" } },
  44.             { "data_set" : { "data" : [ "commerce-order:uid" ], "value" : [ "list-item:uid" ] } },
  45.             { "data_set" : {
  46.                 "data" : [ "commerce-order:commerce-customer-billing:uid" ],
  47.                 "value" : [ "list-item:uid" ]
  48.               }
  49.             },
  50.             { "data_set" : {
  51.                 "data" : [ "commerce-order:commerce-customer-shipping:uid" ],
  52.                 "value" : [ "list-item:uid" ]
  53.               }
  54.             }
  55.           ]
  56.         }
  57.       }
  58.     ]
  59.   }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement