Closed (fixed)
Project:
Commerce Rules Extra
Version:
7.x-2.x-dev
Component:
Documentation
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
12 Sep 2013 at 17:15 UTC
Updated:
11 Feb 2014 at 09:42 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
MarcElbichon commentedI've added an new quantity field to commerce_order. This field is the total quantity of products of the commerce_order.
So now, you can create a condition Total quantity of selected products comparaison and choose commerce-order:commerce-order-quantity in the data selector as quantity comparaison (quantity field).
Comment #2
mrpauldriver commentedThank you that is a massive help.
Comment #3
MarcElbichon commentedDoes this work for you ?
Comment #4
mrpauldriver commentedI haven't yet had time to try, but will take a look tomorrow. I'll report back and let you know.
Comment #5
mrpauldriver commentedI'm struggling with this.
The data selector 'commerce-order:commerce-order-quantity' does not appear to be available to the quantity field.
Comment #6
MarcElbichon commentedHave you flushed cache ?
Comment #7
mrpauldriver commentedI had not flushed the cache but have done so now and find the same:-(
Thank you for the suggestion though.
This is how my condition is formed...
1. Condition to add: Total quantity of selected product comparison
2. Order data selector: commerce-order
3. Tern Reference Field: Value Shipping Options (Vocab)
4. Taxonomy Term Value: Allow discount delivery - £1 per item
5. Search terms in product display, not in product: is not selected.
6. Require All: is not selected
7. Product Type: Product Options
8. Exclude content_type: is not selected
9. Operator is set to =
10. Quantity: Data selector 'commerce-order:commerce-order-quantity' seems not to be available.
Do I understand correctly that the premise of your suggestion is that if the quantity of products with the defined term equals the total quantity of products in the order, then the condition is met? Or put another way, if all commerce-order products have the same term, then the condition is met.
Background info. In most cases my shipping rules are based on order value. However, I wish to trigger different rule of base-rate * quantity, where all items have the term 'Allow discount delivery - £1 per item' term.
Comment #8
MarcElbichon commentedBelow Quantity field, you must have "switch to data selection" button.When clicking, data selector must appear. Select commerce-order. You should see like attachment.
Select commerce-order-quantity.
This means that condition will be fired if total quantity of selected items (by terms and/or content-type) is equal to total quantity of order, in order term, that all products have terms and/or content-type.
Is that what you want ?
Comment #9
mrpauldriver commentedThis is what I am seeing. I'll double check all my settings and modules
Comment #10
MarcElbichon commentedBizarre.
Can you have a look to commerce_rules_extra/commerce_rules_extra.rules.inc and search for commerce_rules_extra_entity_property_info_alter() method (bottom of file).
If found, can you retry to clear cache (registry cache).
If this does'nt work, can you add in commerce_rules_extra_entity_property_info_alter() method this line just after function declaration
Clear the cache again, message must be printed.
Comment #11
mrpauldriver commentedI am not a coder, but copied below is the entirety of what is in commerce_rules_extra.rules.inc
As the zip file at #1, also dev and commit 5e02c5d
If this is all as it should be then I need to take a close look at my rule.
Comment #12
MarcElbichon commentedCan you replace
by
in commerce_rules_extra.rules.inc.
Clear cache and see if the message is printed. This is to be sure hook is done, so you should have commerce-order-quantity field in data selector.
Comment #13
mrpauldriver commentedStill no data selector I'm afraid.
You are investing so much time on this, if it turns out that I have done something fundamentally wrong in setting up the rule, I will need to kick myself and you can too:-) Would it help if you had access to my site?
Comment #14
MarcElbichon commentedI don't think this is a rule configuration problem.
Have you seen message when you have cleared the cache ?
Yes, access to your site can be useful.
Comment #15
mrpauldriver commentedNo messages when clearing the cache.
I'll PM some credentials
Comment #16
mrpauldriver commentedThat appears to be working now. Thank you
When I have my rule finished I will write up the procedure for the benefit of anybody that follows.
Comment #17
MarcElbichon commentedOK. Commit this to dev version and wait for your procedure to close issue
Comment #18
mrpauldriver commentedJust a quick bit of feedback
When updating or deleting certain rules the following is printed as a system message
Was this something that for added in earlier for debugging purposes?
Comment #19
MarcElbichon commentedyes, they are debug messages. Install official dev version, messages should be removed.
Comment #20
mrpauldriver commentedThank you
Comment #21
mrpauldriver commentedThere seems still to be a remanent of the debug message in dev.
The following is displayed when system messages are shown.
sites/all/modules/commerce_rules_extra
sites/all/modules/commerce_rules_extra
The configuration options have been saved.
sites/all/modules/commerce_rules_extra
Comment #22
MarcElbichon commentedYou're right. Commited to dev.
Sorry for the inconvenience
Comment #23
mrpauldriver commentedno problem, thank you for your help
Comment #24
mrpauldriver commentedSorry to inform, but the the latest dev is broken, something which has just come out in testing. The taxonomy (quantity) based shipping rules that I was working on, have ceased to function. Rolling back to 997cf9e corrects the situation for me.
As mentioned above, the last commit which worked correctly was 997cf9e. After this was 47dc84c and then 88e9e2f which both dealt with the removal of debugging messages. Having double checked, it seems that something that was changed or overlooked in 47dc84c which causes the new functionality to fail.
I notice with 47dc84c and 88e9e2f that part of the UI is broken (screenshot) and suspect that this of relevance.
Comment #25
MarcElbichon commentedAs described at https://drupal.org/node/2059325#comment-7900965, term comparison rules has been modified.
A new field, operator (like in your screenshot) allows you to select one of these values (is one of, is all of, is none of, is empty, is not empty).
For your needs, can you try selecting is all of ?
I'm confused about broken rules due to new features. I will try to release a version soon to prevent inconveniences.
Comment #26
mrpauldriver commentedPoint taken about the new operator and I'll do some double checking with the later releases, with this in mind.
Thanks again for your continued help with this.
Comment #27
jcl324I am having this issue too. Can't find the "commerce-order:commerce-order-quantity" data selector, no matter what I do. I have looked at the code and it appears to be moved to the .module file, out of the .inc. One thing I'm not clear on is what event type this condition happens on. I'm assuming "Process checkout pane"?
I'm using 7.x-2.0-alpha3, should I be using the dev version? MrPaulDriver, if you would be so kind as to post your write-up you mentioned in #16? :)
Also, I'm using Kickstart 2.6. Has there ever been a reported problem with this module and KS?
Comment #28
MarcElbichon commentedTo be sure, can you try with dev version ?
Don't forget to flush caches.
Comment #29
jcl324Thanks for the quick reply Marc. I tried the dev version and still same problem. Interesting though is that Drush was confused, even though I specified the dev version it wanted to do the alpha, so I did it manually.
Can you please confirm that the event type should be "Process checkout pane"?
Comment #30
MarcElbichon commentedField is available for any event using commerce_order but only for data comparison condition.
Comment #31
MarcElbichon commentedTo be more precise, field is also avalaible in QUANTITY data selector for Total quantity of selected product comparison or Total product quantity comparison
Comment #32
jcl324Still not seeing it. What am I doing wrong?
Comment #33
MarcElbichon commentedWhich condition do you use ?
Comment #34
jcl324Total quantity of selected product comparison. All I'm trying to do is calculate FedEx shipping rates based on a taxonomy term.
Comment #35
MarcElbichon commentedFor this condition, you do not need quantity field.
Select term and set quantity and operator (for example > 1).
For this example, if total quantity of products with specified term (calculated by the rule) is greater than 1 , action can be ran.
Quantity field could be selected in Data comparaison condition
Comment #36
jcl324So sorry, I was totally looking for it in the wrong place. There is an ORDER data selector, and a QUANTITY one where I did find commerce-order:commerce-order-quantity. Reading back through this thread, it now makes much sense and realize that I didn't need it after all. MrPaulDriver's use case was not the same as mine.
So I have the rule firing correctly and the FedEx or Flat rate (free) is working on the proper terms of a product. However, if I have one product in the cart that gets the FedEx rate and another that gets the free rate, the rates that FedEx come back with are based on both items. Not sure whether this is a rule issue or a FedEx module one, any insights?
Comment #37
MarcElbichon commentedI don't know shipping rates, but i suppose you code your rule like (if order contains a product for xxx term then apply fedex rate).
So you will apply rate to all products if only one product is for tem xxx.
If you want to test if ALL products are for term xxx, you could choose equal operator and quantity field in QUANTITY data selector so rule will be fired only if number of products of term x is equal to total quantity of order.
I close this issue because this is a rule conception problem.