Forums / Developer / is it possible to make shop discount rule on number of items

is it possible to make shop discount rule on number of items

Author Message

Vytautas Germanavičius

Tuesday 11 January 2011 7:56:20 am

I need to apply XX% discount to basket item, if user orders more than X items.

 

I made trigger "shop addtobasket after", there i thought all order items

foreach($basket->productCollection()->itemList() as $item)

{
  if($item->attribute( 'item_count') > $xxx)
  {
    $item->setAttribute( 'discount', $discountValue );

    $item->store();
  }
}


Debug print shows that values are updated.
But when shop/basket page is called , discounts are reset back to 0.

{set-block scope=root variable=cache_ttl}0{/set-block}