Skip to content

Instantly share code, notes, and snippets.

@mglaman
Created November 9, 2013 20:02
Show Gist options
  • Save mglaman/7389311 to your computer and use it in GitHub Desktop.
Save mglaman/7389311 to your computer and use it in GitHub Desktop.
Example rule for altering a line item's label when adding a product to the cart. When a product is added to the cart a line item is created for that order, with its title being the product's SKU. This allows altering of the SKU when added to the order.
{ "rules_alter_line_item_label" : {
"LABEL" : "Alter line item label",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "commerce_cart" ],
"ON" : { "commerce_cart_product_add" : [] },
"IF" : [
{ "entity_is_of_type" : { "entity" : [ "commerce-line-item" ], "type" : "commerce_line_item" } },
{ "data_is" : { "data" : [ "commerce-product:type" ], "value" : "product" } }
],
"DO" : [
{ "data_set" : {
"data" : [ "commerce-line-item:line-item-label" ],
"value" : "[commerce-product:type]-[commerce-order:uid]"
}
}
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment