Before we can give you a reasonable answer, we might want a bit more background on your problem:
What is the purpose of your question? Do you want to write a piece of software which you give as input the quantity and the product type, and as a result you want to obtain the best offers?
If you want to solve the problem you describe, you should look into the subject of Linear programming. Note however that I would categorize this as computer science and not as math. Have a look at this topic: http://www.mathhelpforum.com/math-he...g-problem.html
In this topic, a very similar question is asked.
But than again, it all depends on what you want to learn/achieve.