The Ubercart Fee module works great when the cart contains a single product to which a fee is applied or not.
But when I add more products, it starts to behave abnormally (at least in my point of view). Unless I'm using it for something it was never intended for? If so, let me know and please let me know if there are other/better alternatives for my use case (see below for details).
To make things clear, here is my use case.
I have a baseball cap product class. I created a Drupal baseball cap which has a color attribute and 4 options: Red, White, Blue and Black. I want to apply a 5$ fee only to the Red and Blue caps - color is more expensive! :-)
I created a "Fee for Red & Blue caps" fee. The Conditions for this fee are as follows:
[Condition groups:
[Condition group: is baseballcap AND is Red]
OR
[Condition group: is baseballcap AND Blue]
]
- First condition in group: Check an order's products
- Second condition in group: Order has a product with a particular attribute option
My tests & their results:
1. when cart contains 1 Red cap, a $5 fee is added as expected.
2. when cart contains 1 Red cap & 1 Blue cap, a $10 fee is added as expected.
3. but when cart contains 1 Red, 1 Blue and 1 White cap, a $15 fee is added. I was not expecting that.
In test number 3, the total fee should be $10 not $15.
My reasoning. I thought that the total fee was calculated as the sum of fees applied to each product in the cart, recursively. Inother words that the UC_fee module would (A) look and a see a Red cap, evaluate conditions and apply a $5 fee, (B) look and a see a Blue cap, evaluate conditions and apply a $5 fee, (C) look and a see a White cap, evaluate conditions and apply no fee. Total fee: $5 + $5 = $10.
Note: I'm not a programmer - In uc_fee.module, on line 498, the function uc_fee_calculate_fees() loops for each fees. Right? If so, should it not also loop for each product in the cart? Other wise the "Fee for Red & Blue caps" fee is applied to the white cap because their is a Red cap in the cart. Doesn't make sense to me.
Can anybody help me with this one?
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | fees_applied_to_all_12.patch | 833 bytes | mrf |
| Fee for Red & Blue caps.png | 237.22 KB | bisonbleu |
Comments
Comment #1
56rosa commentedHi,
Did you figure it out in the end please? I'm trying to understand myself how Ubercart works for the selling price.
Thanks
Comment #2
bisonbleu commentedUnfortunately, I got no replies to my issue and I don't currently have the knowhow to check/modify the code. :-(
Comment #3
56rosa commentedHello bisonbleu,
I'm more or less in the same case. I think that customizing Ubercart can get complicated when we're not programmers! Even with all the modules available...
Comment #4
m.stentaIt sounds like you should use the price modifiers in the Options themselves, rather than the uc_fee module for what you're doing.
When you add an option to a product (ie: Red, Blue, White) you can define a price that is added when that option is selected by the user.
Comment #5
zkrebs commentedmstenta: that would make the product display price more expensive, we're not talking about the product price itself, but the fee that's added on the checkout screen.
if i sell a product that needs $5 per option fee included, that's not the price, its a fee. I know, its all money, but to the people I'm working with its a big deal. they feel like their sales will be increased if the "fee" is shown later, in the checkout process.
i'm also having the same problem when i'm applying a fee by SKU, it adds the fee to all products in the cart.
Comment #6
zkrebs commentedis this a duplicate of: http://drupal.org/node/977404
also, is there anyone out there willing to fix this?
seems like in uc_fee.module the code that does this is
Comment #7
zkrebs commentedI just added the fee to the product attribute ( This size: (Includes $x.xx fee) : $price ) . Not ideal, but I received no response from anyone here, the module creator, anyone on #drupal or #drupal-ubercart, even with interest in paying someone to fix it.
Comment #8
tajindersingh commentedsubscribing
Comment #9
tajindersingh commentedHi Slavojzizek,
I am interested in fixing that. But currently busy with some already delayed project.
Subscribed to the post, will get back soon.
Best of luck.
Comment #10
zkrebs commentedPlease let me know when you're considering fixing this, its a huge thing for us. :)
Comment #11
mknapp commentedHas anyone had any luck with finding a work around for this bug. I have several products that have different fees based on the number of products set in a conditional which are applied to specific SKUs. Adding other items in the cart (not included in that SKU order total conditional) Multiplies the fee using the total number of products in the cart. .
Subscribing.
Comment #12
mrf commentedIgnore the scary help text on the fee editing page for the active checkbox.
If you uncheck the 'active' checkbox and the fee willl only apply to items that have the fee selected on their edit form (rather than apply the fee to every item in the cart if one of these items is present).
There is still a bug here somewhere after spending a day debugging this what I just said makes no sense to me, but if it works, it works....
I also applied the patch from #1250916: Max Applications does not count properly. which might also be necessary for this to work, but I haven't confirmed.
Comment #13
mrf commentedHere is a patch that just adds my comments I made while working on this, might lead someone else to the real solution...
Comment #14
mrf commentedComment #15
marcus178 commentedI have found that marking the fee as not active and removing
if (ca_evaluate_conditions($predicates['uc_fee_'. $fee->fid], $arguments)) {and the closing bracket means the multiple fees are applied correctly. Now just need to work out why this is to fix it.