コード例 #1
0
ファイル: Discounts.php プロジェクト: forthrobot/inuvik
 /**
  * Match promotion item rules and add the matching items to the discount
  *
  * @author Jonathan Davis
  * @since 1.3
  *
  * @param ShoppOrderPromo $Promo A promotion object
  * @param ShoppOrderDiscount $Discount A discount object
  * @return void
  **/
 private function items(ShoppOrderPromo $Promo, ShoppOrderDiscount $Discount)
 {
     $Cart = ShoppOrder()->Cart;
     $rules = $Promo->rules['item'];
     $discounts = array();
     // See if an item rule matches
     foreach ($Cart as $id => $Item) {
         if ('Donation' == $Item->type) {
             continue;
         }
         // Skip donation items
         $matches = 0;
         foreach ($rules as $rule) {
             $ItemRule = new ShoppDiscountRule($rule, $Promo);
             if ($ItemRule->match($Item) && !$Discount->hasitem($id)) {
                 $matches++;
             }
         }
         if (count($rules) == $matches) {
             // all conditions must match
             $Discount->item($Item);
         }
     }
 }