When adding a coupon with a minimum order value on a site that is using the uc_discounts module, conditional actions and a "product discount" discount we are finding that the order total is being calculated based on the product's undiscounted price.
For example.
Product X is £100
Discount configured to give £10 off Product X
Coupon configured with max order value of £95
User adds product to cart, cart total shows £90 - but the user can still use the coupon.
I have done some debugging, and the issue looks to be in the uc_coupon_validate function - the function iterates through the items returned from uc_cart_get_contents - each of these items has the undiscounted price in it's price field.
I'm not sure where the correct place to fix this is? We could either trigger the product discount ca in the uc_coupon_validate function, OR, look at changing the uc_cart_get_contents function to add the trigger in there?
Trigger could look something like this
ca_pull_trigger('calculate_product_discounts', $node, $user);
Comments
Comment #1
longwaveuc_coupon_validate should call uc_price() to get the altered price for a product rather than using $item->price directly - this should then in turn trigger the CA rules for product discounts, and also mean that any other modules that implement price handlers (such as uc_vat) also get a chance to modify the product prices before they are tested.
However, I have no time to work on this module at present, any patches that implement this functionality are welcome.
Comment #2
longwaveIn -dev, uc_price() is find to get the altered price for products, so this should now work as expected.