Advertisement
MrJoshMiller

Create a node on checkout for each line item part 2 of 2

Jun 20th, 2013
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.38 KB | None | 0 0
  1. { "rules_create_a_node_for_each_line_item_component" : {
  2.     "LABEL" : "Create a node for each line item component",
  3.     "PLUGIN" : "rule",
  4.     "REQUIRES" : [ "rules" ],
  5.     "USES VARIABLES" : { "line_item" : { "label" : "line_item", "type" : "commerce_line_item" } },
  6.     "IF" : [
  7.       { "entity_is_of_bundle" : {
  8.           "entity" : [ "line-item" ],
  9.           "type" : "commerce_line_item",
  10.           "bundle" : { "value" : { "product" : "product" } }
  11.         }
  12.       },
  13.       { "entity_has_field" : { "entity" : [ "line-item" ], "field" : "field_product" } }
  14.     ],
  15.     "DO" : [
  16.       { "entity_query" : {
  17.           "USING" : {
  18.             "type" : "node",
  19.             "property" : "field_product",
  20.             "value" : [ "line-item:commerce-product:product-id" ],
  21.             "limit" : "1"
  22.           },
  23.           "PROVIDE" : { "entity_fetched" : { "product_display" : "product_display" } }
  24.         }
  25.       },
  26.       { "entity_create" : {
  27.           "USING" : {
  28.             "type" : "node",
  29.             "param_type" : "page",
  30.             "param_title" : [ "product-display:1:title" ],
  31.             "param_author" : [ "line-item:order:owner" ]
  32.           },
  33.           "PROVIDE" : { "entity_created" : { "node_created" : "Created node" } }
  34.         }
  35.       },
  36.       { "entity_save" : { "data" : [ "node-created" ] } }
  37.     ],
  38.     "PROVIDES VARIABLES" : [ "line_item" ]
  39.   }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement