Storing conditions for further selecting from a database. Design challenge
===

Let’s assume I have a online computer shop and I want to add a new feature - advertising. 
As a manager of the shop I want to create an advert about particular product. Let’s say it goes like this: “IF a client is already signed up for at least 2 months AND during purchase the value of his order exceeded 150$ OR product A OR B is already in his shopping cart THEN show him this ad”.

My question is how to store such statements (condition “A or B”, “A and B”, “(A or B) and C”, etc.) in a database and then, how to select the records and display (or not) desired ad?

One of my idea:

    Adverts
    1. id,
    2. name,
    3. description,
    …
    4. criterias_pattern [i.e “(1 OR 5) AND 4”]

Second table:   

    AdvertsCriterias
    1. id
    ...
    2. type
    3. value

In short:
I parse the pattern stored in “criterias_pattern” field, extract criterias_id and then I check the conditions.

It should work but it has many obvious drawbacks.