I am creating products on the fly with Rules, using Drupal Commerce. After user clicks on checkbox near product (additional service to product), I need to "add the service" to cart. Service is always 15% of price of Base product.
I created a rule which creates new products, and add them to cart. This works nicely but I am unable to set up the price field. In Data Selector mode I can not see my calculation field anywhere, not even when calculated value is Integer and price is also integer.
Any help with this? I am posting a Rule here:
{ "rules_grafeon_doplnkov_slu_by_pri_pridan_do_kosika" : {
"LABEL" : "Grafeon - Doplnkov\u00e9 slu\u017eby pri pridan\u00ed do ko\u0161\u00edka",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "commerce_discount_extra", "commerce_cart" ],
"ON" : { "commerce_cart_product_add" : [] },
"IF" : [
{ "entity_has_field" : {
"entity" : [ "commerce-line-item" ],
"field" : "field_doplnkove_sluzby_item"
}
},
{ "data_is" : {
"data" : [ "commerce-line-item:field-doplnkove-sluzby-item:0" ],
"value" : "Service SLA"
}
},
{ "commerce_discount_extra_line_item_has_product_type" : {
"commerce_line_item" : [ "commerce_line_item" ],
"product_types" : { "value" : { "product" : "product" } }
}
}
],
"DO" : [
{ "variable_add" : {
"USING" : { "type" : "date", "value" : "now" },
"PROVIDE" : { "variable_added" : { "variable_added" : "Added variable" } }
}
},
{ "data_convert" : {
"USING" : { "type" : "text", "value" : [ "variable-added" ] },
"PROVIDE" : { "conversion_result" : { "conversion_result" : "Conversion result" } }
}
},
{ "entity_query" : {
"USING" : {
"type" : "commerce_order",
"property" : "order_id",
"value" : [ "commerce-line-item:order-id" ]
},
"PROVIDE" : { "entity_fetched" : { "entity_fetched" : "Fetched entity" } }
}
},
{ "entity_create" : {
"USING" : {
"type" : "commerce_product",
"param_sku" : "DS-[commerce-line-item:order-id]-[conversion-result:value]",
"param_type" : "doplnkov_slu_by",
"param_title" : "Service SLA",
"param_creator" : [ "site:current-user" ],
"param_commerce_price" : { "value" : { "amount" : 1000, "currency_code" : "EUR" } },
"param_commerce_stock" : "1000"
},
"PROVIDE" : { "entity_created" : { "entity_created" : "Created entity" } }
}
},
{ "entity_save" : { "data" : [ "entity-created" ], "immediate" : "1" } },
{ "commerce_cart_product_add_by_sku" : {
"USING" : {
"user" : [ "site:current-user" ],
"sku" : "DS-[commerce-line-item:order-id]-[conversion-result:value]",
"quantity" : "1",
"combine" : "0"
},
"PROVIDE" : { "product_add_line_item" : { "product_add_line_item" : "Added product line item" } }
}
}
]
} }
Any advice how to get the value to Price value? Thanks a lot.