Esempio n. 1
0
 public function mark_paid($payment = null, $note = null)
 {
     if ($note) {
         $this->note = $note;
     }
     foreach ($this->items() as $item) {
         $id = mysql_real_escape_string($this->id);
         $newitem = CartItem::find_by_id($id);
         $result = $item->object->mark_paid(true);
         $item->paid = true;
         $item->save();
     }
     $this->paid = true;
     $this->save();
     $id = mysql_real_escape_string($this->id);
     $redemptions = DiscountRedemption::find_all("discount_redemptions.cart_id = '{$id}'");
     foreach ($redemptions as $redemption) {
         $discount_id = mysql_real_escape_string($redemption->discount_id);
         $user_id = mysql_real_escape_string($this->user_id);
         $loyalty_discounts = LoyaltyDiscount::find_all("loyalty_discounts.discount_id = '{$discount_id}' AND loyalty_discounts.user_id = '{$user_id}'");
         foreach ($loyalty_discounts as $loyalty_discount) {
             $loyalty_discount->spent = true;
             $loyalty_discount->save();
         }
     }
 }