I tried to solve my challenge with a rule. Here is what i did so far:
{ "rules_textfeldl_nge_preiskalkulation" : {
"LABEL" : "Textfeldl\u00e4nge Preiskalkulation",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "rules", "php", "commerce_line_item", "commerce_cart" ],
"ON" : [ "commerce_cart_product_add" ],
"IF" : [
{ "entity_has_field" : { "entity" : [ "commerce-line-item" ], "field" : "field_usertexts" } }
],
"DO" : [
{ "commerce_line_item_unit_price_multiply" : {
"commerce_line_item" : [ "commerce_line_item" ],
"amount" : {
"select" : "commerce-product:commerce-price:amount",
"num_offset" : { "value" : "1" },
"php" : { "code" : "$field_usertexts_1 = $data-\u003Efield_field_usertexts[0][\u0027raw\u0027][\u0027value\u0027];\r\nif ($field_usertexts_1 !== \u0022Beispieltext\u0022) {\r\n$printtext = $field_usertexts_1;\r\n$value = strlen($printtext);\r\nreturn $value;\r\nprint $value;\r\necho $value;\r\n};" }
},
"component_name" : "base_price",
"round_mode" : "1"
}
}
]
}
}
I guess the challenge is to read the editable field called "usertexts" count the number of characters and then multiply the price with the value.
i used custom "PHP evaluation" under "Actions" to do that:
$field_usertexts_1 = $data->field_field_usertexts[0]['raw']['value'];
if ($field_usertexts_1 !== "Beispieltext") {
$printtext = $field_usertexts_1;
$value = strlen($printtext);
return $value;
print $value;
echo $value;
};