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

CommentFileSizeAuthor
screenshot.jpg230.11 KBjimboh

Comments

jimboh’s picture

Ok 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.

jrust’s picture

Title: Specified discount by product class and Min qty (of 2). But giving discount when item of class plus any other item in cart » Exclude all SKUs and exclude all Classes not working
Status: Active » Fixed

Thanks, fixed in git.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.