Author Topic: Quantity discount per category  (Read 14678 times)

Willem Couwenberg

• Beginner
• Posts: 9
Quantity discount per category
« on: July 14, 2009, 14:07:52 pm »
Hi,

How can you set up quantity discount for a category op products?

I have a postcard & poster shop vm 1.1.3 . I would like to give the 5th card for free if they buy 5 cards.

There has been posted on this subject here:http://forum.virtuemart.net/index.php?topic=40421.0
but no solutions given yet.

Thanks for your trouble,
Regards,
Willem-Hein

Willem Couwenberg

• Beginner
• Posts: 9
Re: Quantity discount per category
« Reply #1 on: July 16, 2009, 13:12:40 pm »
Well sometimes luck is with you in the world of open source : Lee Willis had a partial solution for quantity discount per category applicable to only one category.
See his website: http://www.leewillis.co.uk/virtuemart-category-discounts/for this solution. Works like charm on my http://www.vespaghetti.eu website

Now I'm trying to figure out how all categories can have category discount.

Regards,
Willem-hein

lwillis

• Beginner
• Posts: 34
Re: Quantity discount per category
« Reply #2 on: July 16, 2009, 13:47:04 pm »
Willem had asked over on my blog if he thought my solution could work for "multiple categories". I previously said no - however a bit of elaboration below!

As I see it there are 2 main solutions that you might want:

Scenario a:
My related products are spread across multiple products (A, B, C). If I buy 2 or more products (Which are all priced identically) from any of these categories then I should receive a discount.

Scenario b:
I have 2 categories (A and B). Each category contains different products both of which have their own discount scheme. If I buy 2+ products from cat A then I receive a special price. If I buy 2+ products from cat B then I receive a special price. However - if I buy 1 product from category A and 1 from category B then there is no discount.

Solution A can be achieved easily with my solution (I do it myself for baby shoes where the products are split across 2 categories - one for boys styles, and one for girls). (Basically you just turn the
Code: [Select]
`if (\$sesprodcat == 28)`check into an OR condition, e.g.
Code: [Select]
`if (\$sesprodcat == 28 || \$sesprodcat == 29) {`
Solution B could be made to work I think but it'd be a bit more work ...

Willem Couwenberg

• Beginner
• Posts: 9
Re: Quantity discount per category
« Reply #3 on: July 16, 2009, 16:10:01 pm »
Now that write about it: there is always a need for more, it seems.... actually I wanted both scenario's but it looked to complicated to fix.

1. a quantum discount within each of the 5 categories, if you buy 5 or more products from the same category you get a lower price.

plus

2. If you buy a combination of  3 products (postcards for €2,85) from category A and product B2 (a poster for €17.95) from Category B you get a discount.

scenario 1 is the most important for me, do you see an solution for this within your hack?

lwillis

• Beginner
• Posts: 34
Re: Quantity discount per category
« Reply #4 on: July 16, 2009, 16:36:10 pm »
Hmm. Thinking about it some more....

The changes I put in my last reply will achieve your scenario 1. So if your categories were IDs 1,2,3,4,5 then it would be:

Code: [Select]
`if (\$sesprodcat == 1 ||          \$sesprodcat == 2 ||          \$sesprodcat == 3 ||          \$sesprodcat == 4 ||          \$sesprodcat == 5) {`
If you want to allow a discount based on products from different categories the fix is slightly different (& more complicated!)

stevenjcarr

• Beginner
• Posts: 2
Re: Quantity discount per category
« Reply #5 on: July 17, 2009, 19:33:20 pm »
Here is a mod to make this work across multiple categories.  Basically you need to copy the list of category ids you used around the if statement at line 1619:
Code: [Select]
` if (\$sesprodcat == 4 || \$sesprodcat == 5 || \$sesprodcat == 6 || \$sesprodcat == 7 || \$sesprodcat == 10 || \$sesprodcat == 13) {`
Down to line 1651 so that they match:
Code: [Select]
`                                                if (\$sesprodchildcat == 4 || \$sesprodchildcat == 5 ||\$sesprodchildcat == 6 ||\$sesprodchildcat == 7 ||\$sesprodchildcat == 10 ||\$sesprodchildcat == 13) {                                                        \$quantity += \$cart[\$i]["quantity"];                                                } } else {`
Hope this helps.

lwillis

• Beginner
• Posts: 34
Re: Quantity discount per category
« Reply #6 on: July 17, 2009, 21:08:12 pm »
You need to be fairly careful with these changes as there are quite a few subtly different results that can be achieved and you need to be sure which one you want!

My post (#4) above is:
Multiple discounts applied if you buy >1 product within cat 1 OR >1 product within cat 2. The discount is based on the number of products being purchase in that category, e.g. If you buy 2 products in cat 1, and 3 products in cat 2 then the products in cat 1 are charged at the price for "2 items" and the products in cat 2 are charged at the price for "3 items".

Steven's post is
Multiple discounts applied if you buy >1 product within cat 1 OR >1 product within cat 2. The discount is based on the number of products being purchase over all participating categories, e.g. If you buy 2 products in cat 1, and 3 products in cat 2 then the products in both categories are charged at the price for "5 items".

stevenjcarr

• Beginner
• Posts: 2
Re: Quantity discount per category
« Reply #7 on: July 17, 2009, 21:21:02 pm »
Correct.  In our case the store sells greeting cards and everything is priced at \$3.75 per card.  Cards are in several categories and our client wanted a blanket policy allowing any cards from any categories of cards to calculate at the same breaks.  In this case, you purchase 5-9 cards they are \$3.00 even and 10+ are \$2.50.

The other thing this allows you to do is omit other categories from the bulk discount.  We have a section of invitations that are not included so that category is omitted from the code above.

Certainly this is not a good solution for all the scenarios, but it seems perfect for out case.

mms

• Beginner
• Posts: 5
Re: Quantity discount per category
« Reply #8 on: November 23, 2009, 23:05:43 pm »
Hi,

I have the exact same scenario where I want to have discounts across multiple categories (buy any grouping from categories A,B,C that adds up to at least 12 items, get them for \$XX.00, but Category D is excluded from all discounts). I have read and re-read both the original blog post and all these informative forum posts, but not being very confident with code of this complexity, I was hoping to find a helpful soul who will lead me by the hand step by step through the process. Do I still need to change all my items to the bulk pricing within VM? And exactly what file and line numbers am I looking for to edit?

This seems like such a vital choice to have in any online store, it's hard to understand why it's not a part of VM's core...

By the way, I'm using J1.5, VM1.1.3

Thanks so much in advance!!
M Snyder

duwel

• Beginner
• Posts: 3
Re: Quantity discount per category
« Reply #9 on: January 19, 2010, 14:22:58 pm »
Hello, i don't know if this is what you're looking for? But it´s worth the try: http://www.bureauvanvliet.com/virtuemart-category-discount.html

sip

• Beginner
• Posts: 18
Re: Quantity discount per category
« Reply #10 on: March 05, 2010, 20:35:55 pm »
Hello, i don't know if this is what you're looking for? But it´s worth the try: http://www.bureauvanvliet.com/virtuemart-category-discount.html

Wow, this was close. I just needed one more step to assign the discount to a group. So, it would be category / discount / group.

It can be done for each product. I may have to see if I can create this solution.

nonki212

• Jr. Member
• Posts: 90
Re: Quantity discount per category
« Reply #11 on: June 02, 2010, 02:37:40 am »
thank you for the hack
it workes perfectly
thank you

Francois

• Beginner
• Posts: 10
Re: Quantity discount per category
« Reply #12 on: August 21, 2010, 21:21:38 pm »
I have been searching for an answer for weeks.
I am looking for what I think is a combination of the two hacks mentioned above.

My scenario:
If the total quantity ordered is more than 5 items, all the individual category discounts apply.

All products in each category has the same price, but each category has different prices. I am trying find a way around the customer not getting any discounts if they order less than 5 items from each category.

Could anybody please point me in the right direction. Does anyone know of a free or commercial plugin that can achieve this? Any help will be appreciated!

closeupman

• Beginner
• Posts: 4
Re: Quantity discount per category
« Reply #13 on: August 29, 2010, 07:16:35 am »
Hello, i don't know if this is what you're looking for? But it´s worth the try: http://www.bureauvanvliet.com/virtuemart-category-discount.html
Nice, but not what this topic was meant for. We want to apply bulk pricing for all products in selected categories. That component, while a great idea(no hacking needed) only applies a discount to a category, it doesn't allow for using bulk pricing.

closeupman

• Beginner
• Posts: 4
Re: Quantity discount per category
« Reply #14 on: August 29, 2010, 08:35:10 am »
Never mind, got it to work using the topic link above, just had to add another category using ||.

Would be nice if there's someway to hack it to allow using the parent category (e.g. I have a parent category with no items in it, but I subdivided it into 3 categories. I'd rather just put the parent category in the patch rather than all 3 child categories. I tried it and it only works if you put in categories with actual items--in my case the child categories).