3 for 2 discount on specific product.

Thread began 4/16/2009 12:07 am by CraigR | Last modified 5/08/2009 9:53 am by CraigR | 1721 views | 4 replies |

4/16/2009 12:07 am  |  #1 CraigRBeta Tester

3 for 2 discount on specific product.

My client would like to offer 3 for 2 discount on a specific product type (only), so that when 3 items of a certain ItemTypeID are in the cart, either a 33% discount or (preferably) the cheapest of the 3 items is free.

The calculation should allow for groups of 3 items, so that if 4 or 5 items (of this ItemTypeID) are in the cart, the discount will apply so that the customer doesn't save 1/3 off the whole cart, but 1/3 off the 3 items, (or multiple of 3 items)

The ultimate ambition is a formula where i can plug in different variables to allow for 2 for 1, 4 for 3 etc.

I am using a dynamic cart with php and DW CS4, latest version of ecart

On paper, i calculated some scenarios for up to 6 items and their prices
The calculations are based upon the best discount possible

Item1 = 10
Item2 = 12
Item3 = 11
Item4 = 20
Item5 = 18
Item6 = 25

Items 1-3 in cart, total price = (10+12+11) - (10) = 23
Items 1-4 in cart, total price = (10+12+11+20) - (11) = 42
Items 1-5 in cart, total price = (10+12+11+20+18) - (12) = 59
Items 1-6 in cart, total price = (10+12+11+20+18+25) - (18+10) = 68

but would appreciate some advice on the next steps...

4/16/2009 8:47 am  |  #2 Ray BorduinWebAssist

What is your server language. This can be done, but because of the complexity it would probably require some hand scripting in the language you are using.

I would probably write a function to handle it and then write a calculation that refers to that function.

Does it need to account for quantity as well... for instance if you buy two of item1 and one of item2 would you get \$10 off? You would need to account for all of this in your calculation.

Did this help? Tips are appreciated...

4/16/2009 9:21 am  |  #3 CraigRBeta Tester

php

Hi Ray.

I am using php.
I am quite comfortable with hand coding, but have only been using php for about 6 months, (asp before this).

i also want to adopt the best approach wrt ecart

re your question, 3 for 2 would apply to any combination. even 3 of the same item.

4/16/2009 9:39 am  |  #4 Ray BorduinWebAssist

You would need to write the function by hand.

I would write it in the ecart definition include file so you won't have to add the function to every page manually.

Save a backup of the function since the place where I am having you write it would be rewritten any time you update your cart object.

Then you just need to write the function to perform the logic. PHP is exactly like asp, so the logic is identical and the syntax is only slightly different. The main difference is the function library which is documented well at www.php.net.

Did this help? Tips are appreciated...

5/08/2009 9:53 am  |  #5 CraigRBeta Tester

Solved

I have managed to create 3 for 2 (or 4 for 3) or n for n-1 discount, where items are in the same product category, (and only if they are in this category).

With only a little bit of extra hand coding, I have linked the variables with the database so the client can change the product category, date parameters, voucher password etc.

If you are comfortable with creating and manipulating arrays in php, it is fairly straightforward

If you are interested, drop me a line and i will post a 'how-to' guide.

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Everything else!

Close Window

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

Layout

Ease of use

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Window

We were unable to retrieve the attached file

Close Window

Attach and remove files

• Text Formatting
• Insert Element
• Block Formatting
• Cancel
Close Window

Close Window

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --