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

"Please Note:
  • At the specific request of Ibexa we are changing this projects name to "Exponential" or "Exponential (CMS)" effective as of August, 11th 2025.
  • This project is not associated with the original eZ Publish software or its original developer, eZ Systems or Ibexa".

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}