Hi,<br>I am new to rules engine, after going through the examples shipped (shopping.drl, petstore.drl)<br>I am trying to implement promotional discounting using drools 5.2.0 final, stateful session. assume cart has all the items that customer wants to buy,<br>

I am trying to bundle them together with the existing offers<br><br>rule &quot;Buy X units of Product A and Get Y units of Product B Free&quot;<br>    dialect &quot;java&quot;<br>
when<br>    $itemsA : ArrayList( size &gt;= 2) from collect( CartItem( getProductId() == &quot;A&quot;, !isProcessed()))<br>    $itemsB : ArrayList( size &gt;= 1) from collect( CartItem( getProductId() == &quot;B&quot;, !isProcessed()))<br>

then<br>    // current scenario buy 2*A and get 1*B <br>    int x = 2;<br>    int y = 1;<br>    for(int i=0 ; i &lt; x ; i++){<br>        CartItem $ci = (CartItem) $itemsA.get(i);<br>        // modify($ci){setProcessed(true) ... } dosent work<br>

        $ci.setProcessed(true);<br>        $ci.setItemDiscount(0.0);<br>        $ci.setBundleId(bundler.getId());<br>    }<br>    <br>    for(int i=0 ; i &lt; y  ; i++){<br>        CartItem $ci = (CartItem) $itemsB.get(i);<br>

        $ci.setProcessed(true);<br>        $ci.setItemDiscount($ci.getPrice());<br>        $ci.setBundleId(bundler.getId());<br>    }<br>    // global counter to identify bundled items<br>    bundler.increment();<br>end<br>

<br>the above rule calculates only for 1 set of offer i.e first 2*A &amp; 1*B are considered, rest in the cart are not bundled.<br>if customer buys 4*A + 2*B it dosent consider it. am I missing anything? is this the right way to do it?<br>

any feedback is appreciated.<br><br><br><br clear="all"><br>-- <br>Regards,<br>Sandeep Bandela.<br><br>