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 :)

Thanks!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

essbee’s picture

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.

essbee’s picture

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.
http://drupal.org/project/commerce_conditions

Cheers,
Sam

mossy2100’s picture

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!

mossy2100’s picture

Did anyone from commerce look at my patch?

acrazyanimal’s picture

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.

acrazyanimal’s picture

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???

mossy2100’s picture

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.

mossy2100’s picture

Status: Needs review » Needs work

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

acrazyanimal’s picture

Version: 7.x-1.0-rc3 » 7.x-1.x-dev
Status: Needs work » Needs review
FileSize
4.11 KB

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

acrazyanimal’s picture

Title: Compare order quantity by product type » Compare 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. :)

mgifford’s picture

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

acrazyanimal’s picture

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?

rszrama’s picture

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

acrazyanimal’s picture

Awesome thanks!

Status: Fixed » Closed (fixed)

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