The Cart Blog

Saturday, December 8, 2012

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

Filed under: Discounting,That Software Guy,Zen Cart — thatsoftwareguy @ 8:31 am

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.

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress