Here my query is that, I have created one field in product type "Time(Interval)" and another field created in Line item types "(Default Time)" field. My requirement is when user saves a new commerce order, Product type (Time(Interval) field) value auto saves in Line item field (Default Time) value. how we can do this, any idea.
You can implement hook_commerce_cart_product_add() The product which user is adding to cart and the line item is available with in this hook. you can fetch the Time(Interval) field value from product and save it to line item.
function my_module_commerce_cart_product_add($order, $product, $quantity, $line_item) { $commerce_line_item = commerce_line_item_load($line_item->line_item_id); $product_time = $product->time_interval['und'][0]['value']; $line_item->default_time = $product_time; commerce_line_item_save($line_item); }
-
-
it is possible it's work when new commerce order because it work with add to cart – Richa Feb 8 '17 at 5:58
-
The question is about using the Rules module to get this to work. How does this answer help to do so? – Pierre.Vriens Feb 8 '17 at 8:24
-
-
@Pierre.Vriens "Don't use rules, do it this way because it's better, simpler and more performant" is a perfectly acceptable answer to "how do I do x with rules" – Clive♦ Feb 8 '17 at 9:52