There is a lightweight free extension for exactly this scenario: C4B_FreeProduct
It adds a new shopping cart price rules action "free product" where you can enter qty and sku.
These products are added to the cart as non editable items with price 0 during sales rule validation.
You would create two shopping cart price rules with conditions like this:
And then configure the "Add a gift" action.
How it works
- A new rule type is added to the sales rule form, in an observer on
- An observer on
salesrule_validator_process processes the new rule type. It adds the configured SKU to the cart and sets a custom price of 0 and a custom option that identifies the product as free gift.
- Another observer on
sales_quote_collect_totals_before removes existing gift items from the cart (that's what the custom option from before is for), before the rules are processed.
- The cart item template is adjusted to remove qty input and "remove" link from gift items (they would not work anyways).
Disclaimer: I was involved in the development of this extension.