Advertisement
MrJoshMiller

Drupal Commerce: Price based on Product Display Node Field

Apr 23rd, 2013
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.29 KB | None | 0 0
  1. { "rules_price_based_on_product_display_node" : {
  2.     "LABEL" : "Price based on Product Display Node Field",
  3.     "PLUGIN" : "reaction rule",
  4.     "REQUIRES" : [ "php", "rules", "commerce_line_item", "commerce_product_reference" ],
  5.     "ON" : [ "commerce_product_calculate_sell_price" ],
  6.     "DO" : [
  7.       { "variable_add" : {
  8.           "USING" : {
  9.             "type" : "integer",
  10.             "value" : {
  11.               "select" : "commerce-line-item:line-item-id",
  12.               "php" : { "code" : "$line_item_wrapper = entity_metadata_wrapper(\u0027commerce_line_item\u0027, $value);\r\n$url = $line_item_wrapper-\u003Ecommerce_display_path-\u003Evalue();\r\n$url_parts = explode(\u0027\/\u0027, $url);\r\nreturn $url_parts[1];" }
  13.             }
  14.           },
  15.           "PROVIDE" : { "variable_added" : { "nid" : "nid" } }
  16.         }
  17.       },
  18.       { "entity_fetch" : {
  19.           "USING" : { "type" : "node", "id" : [ "nid" ] },
  20.           "PROVIDE" : { "entity_fetched" : { "product_display" : "Product Display" } }
  21.         }
  22.       },
  23.       { "commerce_line_item_unit_price_multiply" : {
  24.           "commerce_line_item" : [ "commerce_line_item" ],
  25.           "amount" : [ "product-display:status" ],
  26.           "component_name" : "discount",
  27.           "round_mode" : "1"
  28.         }
  29.       }
  30.     ]
  31.   }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement