Needs review
Project:
UC Discounts
Version:
5.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
28 Oct 2008 at 08:17 UTC
Updated:
28 Oct 2008 at 19:20 UTC
Hi,
there is an problem in this module with SQL statement in uc_discounts_product_class_apply function.
Old one:
$sql = "SELECT * FROM {uc_discounts_conditions} WHERE discount_id=%d ";
$sql .= "AND property='product_class' AND item_id='%s' ";
$sql .= "ORDER BY condition_group, weight";
and fixed:
$sql = "SELECT * FROM {uc_discounts_conditions} WHERE discount_id=%d ";
// $sql .= "AND property='product_class' AND item_id='%s' ";
$sql .= "ORDER BY condition_group, weight";
Comments
Comment #1
joachim commentedHi.
Thanks for the code!
Could you explain what the change does please? Why is the old version wrong, and what does the new version fix?
Comment #2
mhrabovcin commentedHi,
I think that lines from 135 to 148 can be deleted, because there is no need to check condition when discount is applied. Conditions are checked in uc_discoutns_apply_discount($node) function. Only if product matches conditions discounts are applied. In uc_discounts_product_class_apply function we need to check only if item is certain node type (by action) - lines from 150.
Its because condition can be checked in other module. Example:
Apply 10% from product type when user has role (authenticated user). - condition (user has role) is checked in uc_discounts_role module.
Node type checking brings me to another bug i've found - discounts aren't applied on cart items, only on nodes. In cart aren't stored whole nodes. So product type isn't available, it has to be loaded. Changes from line 150: