Add product to cart with Rules?
I've not had any success adding products to the cart via reaction rules.
Basically when the user creates a conference registration entity, I want to add the corresponding product to the cart. Everything runs successfully, but I still get "cart is empty" when done.
{ "rules_add_registration_to_cart" : {
"LABEL" : "Add Registration to Cart",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "rules" ],
"ON" : [ "node_insert" ],
"IF" : [
{ "node_is_of_type" : {
"node" : [ "node" ],
"type" : { "value" : { "conference_registration" : "conference_registration" } }
}
}
],
"DO" : [
{ "entity_fetch" : {
"USING" : {
"type" : "commerce_product",
"id" : [ "node:field-product-reference:product-id" ]
},
"PROVIDE" : { "entity_fetched" : { "product_fetched" : "Fetched Product" } }
}
},
{ "entity_create" : {
"USING" : {
"type" : "commerce_line_item",
"param_order" : [ "site:current-cart-order" ],
"param_type" : "product",
"param_line_item_label" : "Conference Registration for [product_fetched:title]",
"param_quantity" : "1"
},
"PROVIDE" : { "entity_created" : { "lineitem_created" : "Created LiteItem" } }
}
},
{ "data_set" : {
"data" : [ "lineitem-created:commerce-product" ],
"value" : [ "product-fetched" ]
}
},
{ "data_set" : {
"data" : [ "lineitem-created:commerce-unit-price:amount" ],
"value" : [ "product-fetched:commerce-price:amount" ]
}
},
{ "entity_save" : { "data" : [ "lineitem-created" ] } },
{ "list_add" : {
"list" : [ "site:current-cart-order:commerce-line-items" ],
"item" : [ "lineitem-created" ]
}
}
]
}
}
Comments
Same here
I'm striving to get the same result. I fear this is not possible, but it sounds too strange to me... I mean, it should be simple to achieve :(
Odds are good that it's just under my nose.
i need the same thing
i need the same thing
Good solution in the works
Good solution in the works here: http://drupal.org/node/823466#comment-5016890
Any progress?
Any progress on this front?