Multiply by amount is not working
Hello I created this simple rule, just to test if this works, my actual rule is more complicated and that is why I need multiply by some amount.
{ "rules_test" : {
"LABEL" : "test",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "commerce_line_item", "commerce_cart" ],
"ON" : [ "commerce_cart_product_add" ],
"DO" : [
{ "commerce_line_item_unit_price_divide" : {
"commerce_line_item" : [ "commerce_line_item" ],
"amount" : "50",
"component_name" : "base_price",
"round_mode" : "1"
}
}
]
}
}
And this doesn't work :(
Any suggestions?
Comments
Missed the part about updating the order total, so here's a slightly modified rule to actually Save the updated line item price
{ "rules_test" : {
"LABEL" : "test",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "rules", "commerce_line_item", "commerce_product_reference" ],
"ON" : [ "commerce_product_calculate_sell_price" ],
"IF" : [
{ "entity_has_field" : { "entity" : [ "commerce-line-item" ], "field" : "commerce_product" } }
],
"DO" : [
{ "data_calc" : {
"USING" : {
"input_1" : [ "commerce-line-item:commerce-product:commerce-price:amount" ],
"op" : "*",
"input_2" : ".5"
},
"PROVIDE" : { "result" : { "super_result" : "Calculation result" } }
}
},
{ "commerce_line_item_unit_price_amount" : {
"commerce_line_item" : [ "commerce_line_item" ],
"amount" : [ "super-result" ],
"component_name" : "base_price",
"round_mode" : "0"
}
},
{ "entity_save" : { "data" : [ "commerce-line-item" ] } }
]
}
}
I think I missed the entity save thing, I tested a rule almost identically with this and it didn't work, on the event "calculation the sell price of a product", but on a clean install of Drupal with Commerce installed, it worked, I think I have some other problems.
The rule you provided is working, thanks so much favrik!