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}

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 02:01:38
Script start
Timing: Jan 18 2025 02:01:38
Module start 'layout'
Timing: Jan 18 2025 02:01:38
Module start 'content'
Timing: Jan 18 2025 02:01:39
Module end 'content'
Timing: Jan 18 2025 02:01:39
Script end

Main resources:

Total runtime0.9008 sec
Peak memory usage4,096.0000 KB
Database Queries46

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0064 588.1719152.6563
Module start 'layout' 0.00640.0023 740.828139.5156
Module start 'content' 0.00870.8906 780.3438463.6484
Module end 'content' 0.89930.0014 1,243.99228.0938
Script end 0.9007  1,252.0859 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00350.3911160.0002
Check MTime0.00130.1443160.0001
Mysql Total
Database connection0.00090.095910.0009
Mysqli_queries0.857595.1929460.0186
Looping result0.00050.0550440.0000
Template Total0.868196.420.4341
Template load0.00240.270820.0012
Template processing0.865796.106720.4328
Template load and register function0.00010.016010.0001
states
state_id_array0.00080.084910.0008
state_identifier_array0.00090.102820.0005
Override
Cache load0.00180.2002110.0002
Sytem overhead
Fetch class attribute can translate value0.00080.093410.0008
Fetch class attribute name0.00120.128520.0006
XML
Image XML parsing0.00050.053610.0005
class_abstraction
Instantiating content class attribute0.00000.000620.0000
General
dbfile0.00090.0961160.0001
String conversion0.00000.000940.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
2content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 8
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs