I have a site with product types A, B, C

If 10 or more of type A are in the cart, then all line items of type A should have their unit price reduced. However products of type B / C in the cart should not influence this.

Currently it is only possible to check the order quantity as a whole, or the line item quantity.

Perhaps a more flexible "Sum of field with condition" from a Rules perspective would be better, but I thought I'd get an opinion of this issue from a Commerce perspective first to see what the reaction is like :)


#11 commerce-order_product_type_rule-1249442-10.patch4.11 KBacrazyanimal
PASSED: [[SimpleTest]]: [MySQL] 3,567 pass(es).
[ View ]
#3 commerce-order_product_type_rule-1249442-1.patch3.73 KBmossy2100
FAILED: [[SimpleTest]]: [MySQL] 3,471 pass(es), 46 fail(s), and 42 exception(s).
[ View ]


I am close to having a rule condition "Total product of type quantity comparison" which would at least allow one to determine how many of a certain product type were in the cart.

I have the rule admin side of things working, but can't work out how to determine the product type of a line item as it is not contained within the line_item array.

Any input here greatly appreciated.

I have managed to create a new Rule condition called "Total product of type quantity comparison"

This condition is the same as the "Total product quantity comparison" but also takes a product type, and only counts items of that type.

I have posted it to Commerce Extra Rule Conditions as that seemed the best place for it. Hopefully they integrate it into the project.


new3.73 KB
FAILED: [[SimpleTest]]: [MySQL] 3,471 pass(es), 46 fail(s), and 42 exception(s).
[ View ]

I have only just seen this issue :) I did check the issue queue before implementing the feature, but I must not have seen this item or realised that it's the same as the one I was working on. Anyway, the attached patch adds a condition "Order contains a particular product type" to commerce_order.rules.inc. If you think it's useful, please use!

Did anyone from commerce look at my patch?

Status:Active» Needs review

I second the request for this to be added to the commerce module itself. Thanks.

Status:Needs review» Needs work

The last submitted patch, commerce-order_product_type_rule-1249442-1.patch, failed testing.

Status:Needs work» Needs review

I've tested the patch on my end and it seems to work fine. Looking at the failed test results I can't determine that this patch is causing a problem. From the log messages it looks to have been applied okay. What should the next step be to resolve this???

Thanks for testing the patch. I'm not sure how to proceed. Do I have the tests that I can run myself?

Sorry for not responding sooner - for some reason I'm not receiving any notifications from d.o.

Status:Needs review» Needs work

The last submitted patch, commerce-order_product_type_rule-1249442-1.patch, failed testing.

Version:7.x-1.0-rc3» 7.x-1.x-dev
Status:Needs work» Needs review
new4.11 KB
PASSED: [[SimpleTest]]: [MySQL] 3,567 pass(es).
[ View ]

Lets see if this works, I just recreated the patch against the current dev. I still don't understand why the last version failed.

Title:Compare order quantity by product typeCompare order quantity by product type - patch included

Awesome! Super useful rule, I use it all the time now. Thanks mossy2100. I included your authorship in the recreated patch so you get your cred. :)

Patch applies nicely. What testing is required before this can be marked RTBC and brought into the module?

Status:Needs review» Reviewed & tested by the community

A-hem! Is there any reason that this patch is not making its way into the commerce module?

Status:Reviewed & tested by the community» Fixed

I'm betting it was simply the version number mismatch. Reviewed, cleaned up, and committed. Thanks for bringing it back from the dead. : )

Commit: http://drupalcode.org/project/commerce.git/commitdiff/e749374

Awesome thanks!

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.