1
Answers
Using Rules to Add Product to Cart doesn't populate Line Item Data object
I am using Commerce Registration as well. I have a Rule setup to split the quantity that someone adds to their cart into separate line items by looping through the quantity and using the Add Product to Cart action to add a new product..
This works great but the $line_item->data array is empty, unlike normal products that are manually added to the cart.
Item added to cart looks like this.
object(stdClass)#138 (14) {
["line_item_id"]=>
string(3) "367"
["order_id"]=>
string(3) "106"
["type"]=>
string(7) "product"
["line_item_label"]=>
string(6) "001007"
["quantity"]=>
string(4) "2.00"
["created"]=>
string(10) "1439915310"
["changed"]=>
string(10) "1439915310"
["data"]=>
array(1) {
["context"]=>
array(5) {
["product_ids"]=>
array(1) {
[0]=>
int(4)
}
["add_to_cart_combine"]=>
bool(false)
["show_single_product_attributes"]=>
bool(false)
["display_path"]=>
string(6) "node/8"
["entity"]=>
array(3) {
["entity_type"]=>
string(4) "node"
["entity_id"]=>
string(1) "8"
["product_reference_field_name"]=>
string(26) "field_registration_product"
}
}
}
and additional items added to the cart via Rules look like this
object(stdClass)#175 (14) {
["line_item_id"]=>
string(3) "368"
["order_id"]=>
string(3) "106"
["type"]=>
string(7) "product"
["line_item_label"]=>
string(6) "001007"
["quantity"]=>
string(4) "1.00"
["created"]=>
string(10) "1439915310"
["changed"]=>
string(10) "1439915310"
["data"]=>
array(0) {
}
Thoughts?