I want to give a discount if there are 2 products of the same product class in the cart (not distinct product skus). However the discount is applied if I have 2 items in cart, one of which belongs to the class specified, the second item can be any product from any class.
It should only give discount if cart contains 2 items from specified class..
ie class is small_pizza, discount if 2 small pizzas in cart. But it gives discount if 1 small_pizza and say 1 coke!
Is it supposed to handle my use case?
I have added an attachment with settings for this discount
| Comment | File | Size | Author |
|---|---|---|---|
| screenshot.jpg | 230.11 KB | jimboh |
Comments
Comment #1
jimboh commentedOk After pouring over the code for several hours I discovered that around line 872 of uc_discounts.module:
$result = db_query("SELECT class FROM {uc_discounts_classes} WHERE discount_id=%d AND class<> %d",
$discount_id, ALL_CLASSES
);
ALL_CLASSES is set to "" and it was returning no classes (when it should have and so defaulting to all product ids)..... so I changed the code to:
$result = db_query("SELECT class FROM {uc_discounts_classes} WHERE discount_id=%d AND class<>'%s'"
and it now works as I expected.
I assume around line 854:
$result = db_query("SELECT sku FROM {uc_discounts_skus} WHERE discount_id=%d AND sku<>%d",
$discount_id, ALL_SKUS
);
should be changed to '%s' as well as that is a varchar field with ALL_SKUS set at "" but I havent tested that.
Comment #2
jrust commentedThanks, fixed in git.