public function delete($id = null)
 {
     if (!$id) {
         $id = $this->GetData('id');
     }
     $redemption = DiscountRedemption::find_by_id($id);
     if (!$redemption || $redemption->user->id != Site::CurrentUser()->id) {
         throw new Error404();
     }
     $redemption->destroy();
     Site::Flash("notice", "Discount code removed successfully.");
     RedirectBack("bookings/pay/{$cart_id}/");
 }
 public function cost($unpaid_only = false, $ignore_discounts = false)
 {
     if (!$this->object) {
         $this->reload();
     }
     if (!$this->object) {
         // Object can't be found anymore. This is somewhat of a problem
         return 0;
     }
     $cost = $this->initial_cost();
     if ($this->discount->id && !$ignore_discounts) {
         $discount = DiscountRedemption::find_by_id($this->discount->id);
         // Can we discount this item and have a full cart discount redeemed instead?
         $cost = $discount->discount->apply_discount($this->initial_cost());
     }
     return $cost;
 }