I'm developing my own module for a customizable bundle of commerce products.
I'm saving the subproducts in a field collection in a line item field.
For some reasons I'm doing this with my module, not using "Include this field on Add to Cart forms for line items of this type" in the line item field settings.
Well, when I use my module I use
$form['#submit'][] = 'commerce_custom_bundle_add_to_cart_form_submit';
inside a
commerce_custom_bundle_form_commerce_cart_add_to_cart_form_alter
(is hook_form_BASE_FORM_ID_alter)
Then my function is executed after the product is added to the cart.
The problem is if I choose to add to cart the same product no new line item is created and the existing quantity is increased in 1, obviously.
But I need a new line item, because my custom field changes and I need to not merge the values chosen in the existing line item. I don't know How to force the creation of a new line item.
I tested, if I not use my code and I expose this field in the add to cart form enabling the "Include this field on Add to Cart forms for line items of this type" in the line item field settings. If the same product is added to the cart with a different value in my custom field, is created a new line item.
How do I force the creation of a new line item?