A great addition would be a condition to check if an order contains a product of a particular type. There is some stubb code for this in the comments over here http://www.commerceguys.com/resources/articles/250. It's probably possible to do this using Rules Components, but having a simple rule condition to do it would make life simple.

Comments

mrfelton’s picture

Status: Active » Needs review
StatusFileSize
new3.29 KB

Here is a patch. Though after implementing it I realized that actually what I was looking for was more like 'order contains a product with a particular taxonomy term'! doh!

graker’s picture

I patched the module and tried to create a rule with this condition.

I put "commerce-line-item:order" as data selector and choose one of product types.

The event was "Calculating the sell price of a product" because I'd like to create a discount if certain product is in the cart.

But when I put this condition in the rule, lots of errors appear when displaying the cart:

Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! в функции DrupalDefaultEntityController->load() (row 178 in /includes/entity.inc).
Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! в функции DrupalDefaultEntityController->load() (row 178 in /includes/entity.inc).

Although, I'm not sure, maybe it's not an issue of the patch, maybe it's just that the order is not created until checkout?

upd: it seems like an issue of the patch - I replaced "commerce-line-item:order" with "site:current-cart-order" and errors remain.

upd2: anyways, it seems that you can replace this condition with the other one in the module: "Total product of type quantity comparision". It is just a little less comfortable, but it works.

torgospizza’s picture

idflood’s picture

Status: Needs review » Closed (duplicate)

I think too that it's a duplicate and the other version is even more flexible. I've used the other condition to do exactly what is described in this issue summary.

Feel free to change the status of this issue if this is not the case.