Closed (fixed)
Project:
UC Discount Framework
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
29 May 2009 at 20:28 UTC
Updated:
1 Jul 2009 at 13:50 UTC
Jump to comment: Most recent file
Comments
Comment #1
Island Usurper commentedThis patch looks for predicates on the three predicate forms that have one of the discount triggers. I don't like the extra call to ca_predicate_load(), but it might not be worth worrying about.
Comment #2
jantoine commentedLyle,
I applied the patch and installed the module and received the following error:
Cheers,
Antoine
Comment #3
Island Usurper commentedD'oh! It's supposed to be ca_load_predicate(). New patch.
Comment #4
Island Usurper commented*Sigh*
Forgot to save before making the diff.
Comment #5
jantoine commentedAfter applying the patch, prices on product nodes automatically reflected a newly created discount. One thing I noticed that might be confusing to customers is that products already in the cart do not reflect the discount, however when you proceed to checkout, the discount is applied. Is there a way to update the cart as well?
Cheers,
Antoine
Comment #6
jantoine commentedAfter further investigation, it appears Ubercart stores the cart cache in the users session and not in the database. I couldn't find a flag to set that would tell Ubercart to rebuild the cart cache, this is only accomplished by passing a 'rebuild' action parameter into the uc_cart_get_contents() function. After considering several options, the best I could come up with was to add a flag to Ubercart that price handling modules could set which uc_cart_get_contents() could then read and rebuild the cart cache if necessary. Is this the best approach, or is there a better option I am overlooking?
Cheers,
Antoine
Comment #7
jantoine commentedAfter reviewing the issue at http://drupal.org/node/488652, I discovered the hook_cart_item hook provided by Ubercart. This hook does exactly what we want by examining items in the cart for any modifications since having been added to the cart. Updated patch attached.
The new code in this patch was provided by andreiashu at this issue: http://drupal.org/node/488652. Committing this patch would also fix that issue.
Cheers,
Antoine
Comment #8
jantoine commentedChanged Status
Comment #9
jantoine commentedCorrection... I could not verify that the supplied patch fixes the issue at http://drupal.org/node/488652. The code supplied by andreiashu doesn't solve that issue on my system, but his code does solve the issue posted here, so the supplied patch is still good for this issue. Sorry for the confusion.
Cheers,
Antoine
Comment #10
Island Usurper commentedOK, I'm a little confused now. :)
I'm still trying to work out a solution for #488652: calculate_product_discounts not triggered when adding products from admin area because I need to find a spot in the ordered product workflow that I can add the discount that isn't also used in the checkout workflow. But I don't think it has much to do with this issue here.
I haven't seen any problems with products in the cart holding on to the old prices when I changed the discount conditions or actions, though, so I don't see a need for using hook_cart_item(). Cart item prices should be recalculated every time the cart is loaded. Maybe I've missed some situation where it's not.
Comment #11
jantoine commentedI am able to reproduce a situation where the cart holds on to the old prices using the following procedures:
1. Add a product to the cart
2. Create a product discount for the product previously added to the cart
3. View the cart
BUG: Discount is not reflected on the product unless the "Update Cart" button is clicked.
Cheers,
Antoine
Comment #12
Island Usurper commentedNo, I don't need to update the cart for the discounted price to show. In fact, as soon as I add the discount action, I see the total in the cart block change. Make sure you've got the latest dev versions of both Ubercart and UC Discount, as that's what I'm working with.
This might be silly of me to point out, but you would have to refresh the cart page to see the new price.
Comment #13
jantoine commentedYou have to refresh the browser?...jk
Didn't have the latest Ubercart 2.x-dev. With the latest Ubercart dev install, the patch from comment #4 is good. Changing status to "reviews & tested by the community".
Cheers,
Antoine
Comment #14
Island Usurper commentedWhoops. Forgot to update the issue after committing it. Fixed as of yesterday.