Is it possible to add qualification based on products (list of SKUs) in the shopping cart.
For example, there are three products: product A, product B, product C. Product A discount is given if the shopping cart contains a product B and/or product C.

Comments

adrianmak’s picture

Ubercart Discounts (Alternative) can make discount by
1. individual product
2. by taxonomy term
3. by roles

In your case, you can select each individual product during create a discount or

create a special taxonomy term and assign those product into this term and apply discount by this term.

Hope this can help you

rusvid’s picture

Unfortunately, I don't see how this can help me.

Discount on the product should be applied, depending on whether there are certain products in the shopping cart or not.

For example (extended example from the first post):
There are three products: "Product A", "Product B", "Product C". "Product A" discount is given if the shopping cart contains a "Product B" and/or "Product C".

1. Customer adds "Product A" to the shopping cart.
2. Customer adds "Product B" to the shopping cart and receive a discount on the "Product A".
3. Customer adds "Product C" to the shopping cart.
4. Customer removes "Product B" from the shopping cart. Discount on the "Product A" is applied because the cart contains "Product C".
5. Customer removes "Product C" from the shopping cart and lost the discount on the "Product A".

I think this will work if I can set a list of SKUs (like a list of codes) and the discounts will be calculated on the basis of this list.

ryangroe’s picture

I can attempt to add a new filter type on top of products and terms. Let me see how tough this would be.

ryangroe’s picture

Status: Active » Needs review

OK, the SKU filter type is done. It will be part of beta 31.

Sborsody’s picture

Version: 6.x-1.0-beta24 » 6.x-1.0-beta33

I'm not sure I'm understanding how to apply this kind of discount.

Here's a way of looking at this kind of purchase with discount.

Someone purchases a Kindle and they get to choose two free ebooks with that (free items). They can also purchase more ebooks with that order at a discounted price, up to 10 max. Naturally, they can purchase more ebooks at their regular price.

The qualifying product is the Kindle. As long as there is a Kindle in the cart, they can pick up to 10 ebooks, two of which are free and the rest are discounted. What is throwing me off is the form for adding discounts. How do I say there's two free ebooks if a Kindle is in the cart?

Sborsody’s picture

It seems like what needs to take place is an expansion of the operational logic of this module to increase flexibility. Right now there's the "filter" idea which seems to equivocate between both conditions of qualification and what the discount applies to. These perhaps need to be separated. The discount edit form can have different sections grouped together something like so:

- Discount rule information
(name, description, admin description)

- Cart Qualifications with AND/OR conditions

  • discount codes
  • cart meets minimum total amount
  • cart meets minimum quantity amount
  • cart contains specified SKU/s, product class, etc.
  • cart customer has role/s

- Discount

  • discount type
    • percent off total
    • percent off individual cart items (qualifying item is confusing with qualifying type)
    • fixed amount off total
    • fixed amount off individual cart items
  • discount amount
  • filters for individual cart items (discount applies to...)

Also put all the "max" settings together with their appropriate parents.

Sborsody’s picture

StatusFileSize
new16.54 KB

Here's a patch against beta33 of uc_discounts.admin.inc just to change around the form. I also corrected some #description problems. I haven't changed or added any new functionality.. yet. There's the checkbox "Require single product to qualify." (whose functionality probably needs slight changing) and under this should be where one can specify the product so I added a placeholder textfield for now. The discount does not apply to this product. It is only a condition for qualification.

ryangroe’s picture

Thanks, Sborsody. I started work on this but I haven't had any time to work on the module in a month. Unfortunately I won't be able to work on it again for 2-3 weeks still. I'll address all your questions as soon as I can.

Sborsody’s picture

Cool. I'm doing some more work on this (can't really wait 2-3 weeks). I'll post what I got later.

Sborsody’s picture

StatusFileSize
new8.71 KB
new1.13 KB
new18.15 KB

Here's what I've done against beta33. Running update.php is required.

Seems to work. :)

My test discount case is "minimum quantity", quantity amount = 2, filter by sku (around 27 product selected), and required single product checked with a required product (by sku) selected that isn't selected in the "filter by" list.

Sborsody’s picture

For whatever reason, my patch seems to prevent other discounts from being applied... trying again.

IT Guy 3000’s picture

Glad to see some continued interest in this module, Sborsody, which I'm using alongside UC Discount Framework, which uses conditional actions to accomplish some things. Would be great to only use (alt), and the "require single product to qualify" idea would be great. At the moment I'm trying to add a role-based discount to certain cart items if the role is being purchased at the same time. So checking to see if a certain SKU, for instance, is in the cart, and if so, apply an existing role-based discount. Alternately, and more generally, is it already possible to create a discount in (alt) for a set of SKUs when another certain SKU is in the cart? I'm on beta33.

Thanks for any advice. And thanks for the great work on this, ryangroe. Discount modeling can be, and has been, headache-inducing :) I have some other feature ideas that I'll post separately.

Cheers,
ITG3000

Sborsody’s picture

StatusFileSize
new18.64 KB
new2.98 KB
new23.8 KB

Here's a new version against beta33.

This version accomplishes two things
1) Adds Filter by product class
2) Adds "required product" by SKU pull down list

The functionality of "requires single product" before my changes was that it required either a minimum price or minimum qty of a single product that was selected by the "Filter by" drop down. So what one could do was select two products in the "Filter by" dialog, check "requires single product" and set min price/qty as say 5. So it would check if in the cart there was 5 of one of the two product or $5 of one of the two product. Then the discount would be applied to both product. The difference is subtle.

With my change, the same thing can be done, but one would need to set "can be combined", select a single product in "required product", and then create another discount for the other product. In effect there would be two different discounts, one each for the two different products. This is how I'm going to be using it. Each discount has a name like "3 free items with product X purchase" and "2 free items with product Y purchase".

Imaginably it may not be desirable for some to create so many discounts. The "required product" pull down list could probably be converted to allow the selection of multiple product. Another option is to replicate the whole "filter by" selections in order to allow someone to create a discount like "if any of product class X is in cart, apply discount to any product class Y that is in cart". But then the "requires single product" function might be lost (i.e., you have to buy 5 of the same product to get the discount, not just 5 of multiple products).

Sborsody’s picture

IT Guy 3000,

You can't exactly do that on beta33 because SKUs listed in the discount are both order qualifiers and product that the discount gets applied to. So if you had another SKU in the cart that must be there for the order to qualify, it could also be discounted.

With the patch I made, you could copy your existing role-based discount then have the "role product" SKU selected as the "required product" and "by role" turned off. The "required product" is not selected for discounting if it isn't also listed in "filter by".

I agree this module is great and has a lot of potential going forward.

ezra-g’s picture

Status: Needs review » Needs work
StatusFileSize
new48.92 KB

After applying this patch, role-based discounts for users who already have the role stopped working, and role-based discounts for users who would create an account and be granted a role as part of checkout also did not receive discounts. I tried checking " Require single product to qualify" and specifying a product but with no luck. I did run update.php.

Any suggestions, or does this need a re-roll?

Attached is a straight re-roll of the patches in #13 using the cvs diff -upR flags. The -R makes the patch recursive, so it includes multiple files in a single patch.

ezra-g’s picture

Status: Needs work » Needs review

Hmm, after rolling back this patch and the database, we still don't have discounts working. This might be caused by something else. Setting back to needs review.

Sborsody’s picture

Did you figure out your role-based discount issue?

ezra-g’s picture

Version: 6.x-1.0-beta33 » 6.x-2.x-dev
Status: Needs review » Needs work

I think we were having an unrelated problem and managed to clear it up.

Unfortunately, this patch no-longer applies and needs to be re-rolled. I'd love to commit this to the 6.x-2.x branch :).

Bumping version # and marking as needs work.

Sborsody’s picture

I'll do it later. I need to make two separate patches anyway. One is for filtering product by class and the other is this. Right now I'm running beta-36.

OsterD’s picture

Please have a look on this partially related issue.
http://drupal.org/node/566514
Thanks.

ezra-g’s picture

Status: Needs work » Needs review
StatusFileSize
new54.06 KB

Here's a re-roll that was done in part by committing to an older version of uc_discounts_alt and then running coder_format, then diffing against the 6-2 branch, then diffing that against cvs.

ezra-g’s picture

StatusFileSize
new55.18 KB

Here's a re-roll that clears up some syntax errors and fixes the discount form so that the discount amount is saved. It seems likely we'll find more bugs due before this is RTBC. We should also go back and verify that anything committed since August 4th is not disturbed by this reroll.

ezra-g’s picture

StatusFileSize
new54.38 KB

This re-roll removes a call to fprint and restores compatibility with percentage off per qualifying product.

ezra-g’s picture

Title: Qualification based on products (list of SKUs) » Qualification based on products (list of SKUs), Single Product
Status: Needs review » Fixed

The hunks that failed here are because #587270: Percentage off per qual. product calculates discount incorrectly has already been committed.

This patch is now committed -- We'll get some testing in the next release.

Thanks!

Status: Fixed » Closed (fixed)

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

steveoliver’s picture

Sborsody, In your last paragraph you wrote

The "required product" pull down list could probably be converted to allow the selection of multiple product. Another option is to replicate the whole "filter by" selections in order to allow someone to create a discount like "if any of product class X is in cart, apply discount to any product class Y that is in cart". But then the "requires single product" function might be lost (i.e., you have to buy 5 of the same product to get the discount, not just 5 of multiple products).

This is exactly what I would like to do. How can this be done?

Thanks,

-Steve

Sborsody’s picture

Which is exactly what you would like to do? There's two different options up there.

steveoliver’s picture

"required product" pull down list could probably be converted to allow the selection of multiple product(s).

Poieo’s picture

+1 to see require a single product, class, or term to qualify for a discount.

This would give you the ability to discount all 'widgets' if any 'widget' is in your cart.