Background: I have a store with two products. Produce one is the purchase of role R for $100 (I use uc_role for this). Product two costs $100, but for purchasers with role R it costs only $50 (I use uc_price_per_role for this).
Scenario: an anonymous user comes to the store and puts both products in his cart.
Expected behavior: a total cart cost of $150 ($100 for product one, the purchase of role R, and $50 for product two, with the price_per_role discount)
Actual behavior: a total cart cost of $200 ($100 for each product). This is because the role R is not granted until after checkout.
Is this a configuration problem? If this ISN'T a configuration problem -- if this is just how uc_price_per_role works -- then I think the right place to fix it is in hook_cart_item. Iterate over the items in the cart, and if any of them are role purchases, apply the discount. Does that sound right?
Thanks!
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | uc_price_per_role-apply-pricing-to-cart-1199358.patch | 1.87 KB | Jonathan Peterson |
Comments
Comment #1
Jonathan Peterson commentedJust to clarify -- I am willing to write a patch for this if necessary. I am just double-checking that uc_price_per_role doesn't already behave this way, and asking for guidance whether hook_cart_item is the right place to add the feature.
Comment #2
Jonathan Peterson commentedThe attached patch applies any role-specific pricing to products in the cart itself, as outlined in the issue description above. It doesn't look at options or attributes, as I don't need them in my use case; but I figure better to submit a patch with what I have so maybe I can help the next guy.
If others think this functionality is useful I'm happy to add the option and attribute code too.
Comment #3
Anonymous (not verified) commentedWow, thanks! I can't believe this isn't already included.
Could you add the logic for options? That would be really helpful.
Thanks again.
Comment #4
scotwith1tThis is great and should definitely be considered as part of this module. It only makes sense that the person should get the discount that their new role affords them! It works really well and takes the discount away if the role product is removed from their cart too. changing status to see if it can get consideration for committing. maybe extending to cover options for troubador and maybe a setting somewhere to turn make this functionality optional might be a good idea...nicely done Jonathan Peterson!
Comment #5
scotwith1tHere we are 4 months later and another, different e-commerce project and I've come across this again...Jonathan Peterson's patch works great as long as attributes aren't a factor (which they aren't in my case). Any way to get this committed so I don't have to keep this in my custom modules folder or continue to patch it? Either way, thanks again for the patch!!
Comment #6
scotwith1tp.s. even works with ajax cart, which is a huge bonus for us :)