close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Calculating Discount - Buy Two Get Another Free

Thread began 11/20/2019 9:48 am by Me | Last modified 11/21/2019 9:04 am by Ray Borduin | 686 views | 5 replies |

Me

Calculating Discount - Buy Two Get Another Free

I am scratching my head on this...its not as simple as it first appears.

I can easily calculate if there are three of the same item in the cart and then discount (in cash) the amount equal to the cost of one of them.

For example: Say Item price is 30.00. The user sticks three (3 x 30.00 = 90.00) in the cart and because then the quantity threshold for this item has been met, it shows in the discounts 30.00...easy so far!

Now, my client has asked me, "what if a customer puts six in the cart", it should give a discount totalling 60.00.

What the client is saying is that "for every 3 of the same item in the cart, it should show a 30.00 discount"

So, if there was (say) 4 or five items of the same in the cart, it would only show a 30.00. Once it hits 6, then show 60.00 discount...again it remains at 60.00 if the customer adds 7 or 8 unless the customer updates the quantity to 9...and so on and so on?

There's probably an easy way to do this...anyone out there got a tip or hint?

Thanks in advance.

Sign in to reply to this post

Ray BorduinWebAssist

I think you can do this with a custom column in the cart.

You can create a column like: QuantityDiscount = floor([Quantity]/3) * [Price]

Then create the rule to discount the total of the QuantityDiscount column instead of just discounting the 30.00.

Sign in to reply to this post
Did this help? Tips are appreciated...

Me

They say you should always sleep on it. I woke this morning and realised I was approaching this in completely the wrong way. It was never a programatic code issue, it was a math issue, and so...

([Quantity] > [DiscountUnitThreshold]) ? (floor([Quantity] / ([DiscountUnitThreshold] + 1))) * [DiscountAmount] : ''

I guess its another way of doing what Ray has done with my own columns.

Thanks Ray...I will take a look at your method...it might be a little less code :-)

Sign in to reply to this post

Ray BorduinWebAssist

You don't need the check in the front or the +1 I don't think. This might be right:

([DiscountUnitThreshold] > 0) ? (floor([Quantity] / ([DiscountUnitThreshold]))) * [DiscountAmount] : 0

Sign in to reply to this post
Did this help? Tips are appreciated...

Me

The check at the front is to check if the quantity ordered is > than the DiscountUnitThreshold (which is variable for each product)...and yes, I updated the code slightly and I did not need to include +1.

Thanks for your replies Ray!

Sign in to reply to this post

Ray BorduinWebAssist

Yes, but the math will result in zero if the quantity is < the DiscountUnitThreshold anyway, so no need to check. You just need to check that the DiscountUnitThreshold is not zero since you can't divide by zero.

Sign in to reply to this post
Did this help? Tips are appreciated...

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.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

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

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

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 Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

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

Uploading file...