Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the extra free items to their order after they checkout. Of course, it d be nice to automate this entire process.
I ve been mulling over a few ideas, mainly creating a Discount model (I m using Django in this case, but this is more of a logic question) and having that model have a variety of flags and product lists so I could create an instance like so:
Discount(
description="Get one free pair of bands when you buy two pairs of shoes.",
valid_products=[BigProductA, BigProductB],
received_products=[FreebieProductA, FreebieProductB],
special_in_intervals=2, # Whenever the user buys 2, give one for free
)
This logic kind of works. I can then take a look at what is in their cart and test against the existing Discounts in the model and see if they apply for anything. The biggest problem with this is it can get very messy especially if you have multiple specials going on and I just don t see it working out too well.
Unfortunately, that s really my best idea for this right now. So, I come to ask you guys: What do you think is the best approach for this? I m not looking for code, just some ideas of logic and ways to do this. :)
Thanks in advance!