“Buy some quantity, get specific item free” in Zen Cart Big Chooser

Most people, when doing an item-count based discount, just want the least expensive item to be discounted. This kind of discount – “Buy 3, get a 4th item free” can be done with Zen Cart Big Chooser. But sometimes people want to specify a particular item: “Buy 3, get product 768 free.” This will work as long as product 768 is less expensive than the other 3 items in the cart – because Big Chooser selects items to meet the condition from most expensive to least expensive, and selects items to be discounted from least expensive to most expensive.

One customer had a high-priced item that was old stock that they wanted to clear out, so Big Chooser changes were required. So to allow I modified the behavior of set_negative_constraint in Big Chooser to make it work the way Big Spender does – simply eliminating the item from the decision about whether or not the constraint is met, but keeping it as a possibly discountable item. So you can say

   $this->add_condition("Buy any 3 items, get item 768 free", false); 
      $this->set_constraint(MINPRICE, 0.01, 3);
      $this->set_negative_constraint(PROD, 768);
      $this->set_discount(PROD, 768, 1, "%", 100);

and product 768 will be discounted even if it’s the most expensive item in the cart.

The change to allow discounting the negative constraint was added to Big Chooser for Zen Cart 1.2.16, released last week.

This entry was posted in Discounting, That Software Guy, Zen Cart. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s