Beispiel #1
0
 public function redeem_cart()
 {
     $obj = new helpers();
     $points = Request::input('user_points');
     $member = DB::table('brandmembers')->where("id", Session::get('member_userid'))->first();
     if ($points > $member->user_points) {
         Session::flash('error', "You don't have enough points to redeem.");
         return redirect('show-cart');
     }
     $setting_point_price = DB::table('sitesettings')->where('name', 'price_for_point')->first();
     $setting_point = DB::table('sitesettings')->where('name', 'points_for_price')->first();
     $amount = $points * $setting_point_price->value;
     $total_amount = Cart::total();
     if ($amount > $total_amount) {
         Session::flash('error', "Your redeem value is higher than total amount.");
         return redirect('show-cart');
     }
     $obj->demandredeem($points, $amount);
     Session::flash('success', '$' . $amount . ' Is applied as redeem amount in your cart.');
     return redirect('show-cart');
 }