Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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!
Comment | File | Size | Author |
---|---|---|---|
#11 | commerce-order_product_type_rule-1249442-10.patch | 4.11 KB | acrazyanimal |
#3 | commerce-order_product_type_rule-1249442-1.patch | 3.73 KB | mossy2100 |
Comments
Comment #1
essbee CreditAttribution: essbee commentedI 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.
Comment #2
essbee CreditAttribution: essbee commentedI 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
Comment #3
mossy2100 CreditAttribution: mossy2100 commentedI 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!
Comment #4
mossy2100 CreditAttribution: mossy2100 commentedDid anyone from commerce look at my patch?
Comment #5
acrazyanimal CreditAttribution: acrazyanimal commentedI second the request for this to be added to the commerce module itself. Thanks.
Comment #7
acrazyanimal CreditAttribution: acrazyanimal commentedI'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???
Comment #8
mossy2100 CreditAttribution: mossy2100 commentedThanks 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.
Comment #9
mossy2100 CreditAttribution: mossy2100 commented#3: commerce-order_product_type_rule-1249442-1.patch queued for re-testing.
Comment #11
acrazyanimal CreditAttribution: acrazyanimal commentedLets see if this works, I just recreated the patch against the current dev. I still don't understand why the last version failed.
Comment #12
acrazyanimal CreditAttribution: acrazyanimal commentedAwesome! 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. :)
Comment #13
mgiffordPatch applies nicely. What testing is required before this can be marked RTBC and brought into the module?
Comment #14
acrazyanimal CreditAttribution: acrazyanimal commentedA-hem! Is there any reason that this patch is not making its way into the commerce module?
Comment #15
rszrama CreditAttribution: rszrama commentedI'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
Comment #16
acrazyanimal CreditAttribution: acrazyanimal commentedAwesome thanks!