Rule for checking shopping cart (order) for duplicated items
I am trying to create a rule to check order for duplicated products. I am selling digital goods and it does not make sense for customer to buy two same digital products.
So I created a rule that loops through commerce order line items to find duplicates. When finds duplicates, it should remove the newly added product from order. However I am not able to distingiush between products that are in shopping cart already and newly added product.
My rule is reacting on event „After adding a product to the cart“ and is looping through „cart-order:commerce-line-items“.
The component that is looping through order line items has condition: „List contains item“ , where List is „cart-order:commerce-line-items“, and the item to check for is a variable passed to component „lineitem-added-to-cart“.
Currently when I add product to the cart, the condition is always evaluated as True and product is removed from the cart.
Screencast in this thread gave me the basic clue how to loop through line items in order, thank you Randy very much! http://www.drupalcommerce.org/discussions/2491/solved-removing-line-item....
However I still could not figure out solution for my specific purpose. Any help will be much appreciated!