Пример #1
0
 public function postAddtocart()
 {
     $product = Product::find(Input::get('id'));
     $quantity = Input::get('quantity');
     Cart::insert(array('id' => $product->id, 'name' => $product->title, 'price' => $product->price, 'quantity' => $quantity, 'image' => $product->image));
     return Redirect::to('store/cart');
 }
Пример #2
0
 /**
  * Store a newly created resource in storage.
  * POST /carts
  *
  * @return Response
  */
 public function store()
 {
     if ($id = Input::get('id')) {
         $product = Product::findOrFail((int) $id);
         $item = array('id' => $product->id, 'name' => $product->title, 'price' => $product->price, 'quantity' => 1);
         Cart::insert($item);
         return Cart::totalItems(true);
     } else {
         return false;
     }
 }
Пример #3
0
 /**
  * Add to cart
  *
  * @throws HTTP_Exception_404
  * @throws Kohana_Exception
  */
 public function action_add()
 {
     $id = Arr::get($_POST, 'id');
     $obj = ORM::factory('Shop_Product')->where('id', '=', $id)->where('enabled', '=', 1)->find();
     if (!$obj->loaded()) {
         throw new HTTP_Exception_404();
     }
     $product = ['id' => $obj->id, 'qty' => 1, 'price' => $obj->price, 'name' => $obj->title, 'slug' => $obj->slug];
     $cart = new Cart();
     $cart->insert($product);
     $this->json['success'] = true;
     $this->json['content'] = View::factory('shop/frontend/cart/v_cart_top', ['cart' => $cart])->render();
 }
Пример #4
0
 function addToCart()
 {
     if (!Input::get('option')) {
         return Redirect::to('order');
     }
     if (!Input::get('cycle')) {
         return Redirect::to('order');
     }
     $option = ServiceOption::find(Input::get('option'));
     $service = Service::find($option->service_id);
     $cycle = BillingCycle::find(Input::get('cycle'));
     Cart::insert(array('id' => $option->id, 'name' => $service->name . ' ' . $option->option_name, 'price' => $option->base_price, 'quantity' => $cycle->cycle));
     return Redirect::to('order');
 }
 public function addtocart()
 {
     if (Input::get('order') == 1) {
         $group = Input::get('team');
         $id = Input::get('event');
         $qty = Input::get('qty');
         $e = Evento::with('club')->whereId(Input::get('event'))->firstOrFail();
         if (!$group == 1) {
             $item = array('id' => $e->id . $group, 'name' => $e->name . ' - Player Registration', 'price' => $e->fee, 'quantity' => $qty, 'tax' => 0, 'org_name' => $e->club->name, 'org_id' => $e->club->id, 'event' => $e->id, 'player_id' => '');
             Cart::insert($item);
         } else {
             $item = array('id' => $e->id . $group, 'name' => $e->name . ' - Team Registration', 'price' => $e->group_fee, 'quantity' => $qty, 'tax' => 0, 'org_name' => $e->club->name, 'org_id' => $e->club->id, 'event' => $e->id, 'player_id' => '');
             Cart::insert($item);
         }
     }
     return Redirect::action('PaymentController@index');
 }
Пример #6
0
 function add_cart()
 {
     $shop_site = get_post_value('shop_site');
     $image_url = get_post_value('image_url');
     $product = get_post_value('product');
     $product_url = get_post_value('product_url');
     $product_id = get_post_value('product_id');
     $shop_url = get_post_value('shop_url');
     $shop_username = get_post_value('shop_username');
     $qty = get_post_value('qty');
     $sku = get_post_value('sku');
     $sku_name = get_post_value('sku_name');
     $price = get_post_value('price_cn');
     $shop_id = get_post_value('shop_id');
     if (!Login::verifyLogin()) {
         // var_dump($cart_array);
         if (empty($_COOKIE['shop_cart_info'])) {
             //   $cart_info[0]['shop_site'] = $shop_site;
             $cart_info[0]['image_url'] = $image_url;
             //   $cart_info[0]['product'] = $product;
             //   $cart_info[0]['product_url'] = $product_url;
             $cart_info[0]['product_id'] = $product_id;
             // $cart_info[0]['shop_url'] = $shop_url;
             //$cart_info[0]['shop_username'] = $shop_username;
             $cart_info[0]['qty'] = $qty;
             $cart_info[0]['sku'] = $sku;
             $cart_info[0]['sku_name'] = $sku_name;
             // $cart_info[0]['price'] = $price;
             //$cart_info[0]['shop_id'] = $shop_id;
             setcookie("shop_cart_info", serialize($cart_info), time() + 3600 * 24, '/');
             $this->assign('message', 2);
             $this->setReturnType('message');
         } else {
             $cart_array = unserialize(stripslashes($_COOKIE['shop_cart_info']));
             $ar_keys = array_keys($cart_array);
             rsort($ar_keys);
             $max_array_keyid = $ar_keys[0] + 1;
             //  $cur_cart_array[$max_array_keyid]['shop_site'] = $shop_site;
             $cart_array[$max_array_keyid]['image_url'] = $image_url;
             // $cur_cart_array[$max_array_keyid]['product'] = $product;
             // $cur_cart_array[$max_array_keyid]['product_url'] = $product_url;
             $cart_array[$max_array_keyid]['product_id'] = $product_id;
             // $cur_cart_array[$max_array_keyid]['shop_url'] = $shop_url;
             // $cur_cart_array[$max_array_keyid]['shop_username'] = $shop_username;
             $cart_array[$max_array_keyid]['qty'] = $qty;
             $cart_array[$max_array_keyid]['sku'] = $sku;
             $cart_array[$max_array_keyid]['sku_name'] = $sku_name;
             //  $cur_cart_array[$max_array_keyid]['price'] = $price;
             // $cur_cart_array[$max_array_keyid]['shop_id'] = $shop_id;
             setcookie("shop_cart_info", serialize($cart_array), time() + 3600 * 24, '/');
             $this->assign('message', 2);
             $this->setReturnType('message');
         }
     } else {
         if (isset($_SESSION['user_id'])) {
             $user_id = $_SESSION['user_id'];
         } else {
             $this->assign('message', 0);
             $this->setReturnType('message');
             exit;
         }
         // 保存数据
         $m = new Cart();
         $field = array('created' => date('Y-m-d H:i:s', time()), 'user_id' => $user_id, 'shop_username' => $shop_username, 'shop_url' => $shop_url, 'product_id' => $product_id, 'product_url' => $product_url, 'shop_url' => $shop_url, 'shop_username' => $shop_username, 'qty' => $qty, 'sku' => $sku, 'sku_name' => $sku_name, 'status' => '10000', 'product' => $product, 'image_url' => $image_url, 'price' => $price, 'shop_id' => $shop_id, 'shop_site' => $shop_site);
         $m->clear();
         $m->setField($field);
         $m->setTable('vcb_cart');
         $data = $m->insert();
         if (!empty($data)) {
             $data = 1;
         } else {
             $data = 0;
         }
         $this->assign('message', 1);
         $this->setReturnType('message');
     }
 }
Пример #7
0
$objUser = new User($dbusercat);
if (!isset($action)) {
    $PHPSESSID = $sessionId = session_id();
    $INDICE = $_GET['SCENEID'];
    #
    # Insert SESSION ID, SCENEID into Table Cart
    #
    $sqlaux = "SELECT * FROM Cart WHERE Cart.sesskey='{$PHPSESSID}' AND SceneId = '{$INDICE}'";
    if (!$dbcat->query($sqlaux)) {
        $dbcat->error($sqlaux);
    }
    $nscenes = $dbcat->numRows();
    if ($nscenes == 0) {
        $objCart = new Cart($dbcat);
        $objCart->fill($PHPSESSID, $INDICE, $PRODUTO);
        $objCart->insert();
    }
    #
}
if ($action == $strDelete) {
    $objCart = new Cart($dbcat);
    $objCart->removeId($ID);
}
// Searching for cart
$sql = "SELECT * FROM Cart WHERE Cart.sesskey='{$PHPSESSID}'";
$dbcat->query($sql) or $dbcat->error($sql);
$itens = $dbcat->numRows();
if ($itens == 0) {
    echo "<h2>Empty Cart</h2>\n";
    $strWarning = '<h2>To download images, you must either 
                register yourself or, if you are already registered, log in at <a href="index.php" style="font-size:15">Catalog\'s banner (top) main page</a>.</h2><br>';
 public function doPaymentSelect($id)
 {
     $user = Auth::user();
     $member = Member::find($id);
     $title = 'League Together - ' . $member->team->club->name . ' Teams';
     $type = Input::get('type');
     $club = Club::find($member->team->club->id);
     switch ($type) {
         case 'full':
             $price = $member->getOriginal('due');
             $today = Carbon::Now();
             $early = new Carbon($member->early_due_deadline);
             if ($member->early_due_deadline) {
                 if ($today->startOfDay() <= $early->startOfDay()) {
                     $price = $member->getOriginal('early_due');
                 }
             }
             $item = array('id' => $member->team->id, 'name' => "Membership Team " . $member->team->name, 'price' => $price, 'quantity' => 1, 'organization' => $member->team->club->name, 'organization_id' => $member->team->club->id, 'member_id' => $member->id, 'player_id' => $member->player->id, 'user_id' => $user->id, 'type' => $type, 'autopay' => false);
             Cart::insert($item);
             foreach (Cart::contents() as $item) {
                 $item->name = "Membership Team " . $member->team->name;
                 $item->quantity = 1;
             }
             return Redirect::action('MemberController@paymentCreate', array($member->id));
         case 'plan':
             $price = $member->plan->getOriginal('initial');
             $item = array('id' => $member->team->id, 'name' => "Membership Team " . $member->team->name, 'price' => $price, 'quantity' => 1, 'organization' => $member->team->club->name, 'organization_id' => $member->team->club->id, 'member_id' => $member->id, 'player_id' => $member->player->id, 'user_id' => $user->id, 'type' => $type, 'autopay' => false);
             Cart::insert($item);
             foreach (Cart::contents() as $item) {
                 $item->name = "Membership Team " . $member->team->name;
                 $item->quantity = 1;
             }
             return Redirect::action('MemberController@paymentCreate', array($member->id));
         default:
             return Redirect::action('MemberController@paymentSelect', array($member->id))->with('error', 'Opps we are having some trouble processing your request, please try later. Error# 345');
     }
 }
Пример #9
0
<?php

session_start();
require_once '../classes/Config.php';
require_once '../classes/Cart.php';
$obj = new Cart();
switch ($_POST['form']) {
    case 'countCart':
        $result = Cart::selectCount();
        echo json_encode($result);
        break;
    case 'addCartOne':
        $result = $obj->insert($obj->insertSql(), $_POST['id'], 1);
        echo json_encode($result);
        break;
    case 'addCartTwo':
        $result = $obj->insert($obj->insertSql(), $_POST['id'], $_POST['kol']);
        echo json_encode($result);
        break;
    case 'editKol':
        $result = $obj->updateKol($obj->updateKolSql(), $_POST['id'], $_POST['kol']);
        echo json_encode($result);
        break;
    case 'deleteCart':
        $result = $obj->deleteCart($_POST['id']);
        echo json_encode($result);
        break;
}
Пример #10
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $startDate = Carbon::now();
     $from = Carbon::now()->hour(0)->minute(0)->second(0);
     $to = Carbon::now()->hour(23)->minute(59)->second(59);
     $schedules = SchedulePayment::where('status', 0)->whereBetween('date', array($from, $to))->with('member.user.profile')->get();
     //$schedules = SchedulePayment::where('status', 0)->with('member.user.profile')->get();
     $errors = array();
     $totalAmount = array();
     $errorAmount = array();
     //save daylog
     $dayLog = new ScheduleDailyLog();
     $dayLog->started_on = Carbon::now()->toDateTimeString();
     $dayLog->payments_count = count($schedules);
     $dayLog->save();
     Cart::destroy();
     foreach ($schedules as $schedule) {
         try {
             $vault = $schedule->member->user->profile->customer_vault;
             $user = User::find($schedule->member->user->id);
             $player = Player::find($schedule->member->player->id);
             $club = Club::find($schedule->club_id);
             $team = Team::find($schedule->member->team_id);
             $uuid = Uuid::generate();
             $member = Member::find($schedule->member->id);
             $history = SchedulePayment::find($schedule->id);
             //manually login user out before login new user
             Auth::logout();
             //manually login user
             Auth::login($user);
             //clear cart content
             Cart::destroy();
             //set cart item
             $itemCart = array('id' => $team->id, 'name' => "Scheduled payment for " . $team->name, 'price' => $schedule->subtotal, 'quantity' => 1, 'organization' => $club->name, 'organization_id' => $club->id, 'player_id' => $player->id, 'user_id' => $user->id, 'type' => 'full', 'autopay' => true);
             Cart::insert($itemCart);
             //check if vault exist
             if ($vault) {
                 $param = array('customer_vault_id' => $vault, 'discount' => null, 'club' => $club->id);
                 $payment = new Payment();
                 $transaction = $payment->sale($param);
                 //temp json_decode(json_encode($array), FALSE);
                 //$transaction = json_decode(json_encode(array('response' => 1, 'total'=>$schedule->total, 'fee'=>$schedule->fee)), FALSE);
                 if ($transaction->response == 3 || $transaction->response == 2) {
                     $errors[] = array('payment_schedule_id' => $schedule->id, 'error_description' => $transaction->transactionid . ' : ' . $transaction->responsetext, 'error_amount' => $schedule->total, 'daily_log_id' => $dayLog->id);
                     array_push($errorAmount, number_format($schedule->total, 2));
                     //Email error
                     $emailerrorstatus = $payment->error($transaction, $club->id, $player->id);
                 } else {
                     array_push($totalAmount, number_format($transaction->total, 2));
                     $payment->id = $uuid;
                     $payment->customer = $vault;
                     $payment->transaction = $transaction->transactionid;
                     $payment->subtotal = $transaction->subtotal;
                     $payment->service_fee = $transaction->fee;
                     $payment->total = $transaction->total;
                     $payment->promo = $transaction->promo;
                     $payment->tax = $transaction->tax;
                     $payment->discount = $transaction->discount;
                     $payment->club_id = $club->id;
                     $payment->user_id = $user->id;
                     $payment->player_id = $player->id;
                     $payment->event_type = null;
                     $payment->type = $transaction->type;
                     $payment->save();
                     //Email receipt
                     $payment->receipt($transaction, $club->id, $player->id);
                     $sale = new Item();
                     $sale->description = $itemCart['name'];
                     $sale->quantity = $itemCart['quantity'];
                     $sale->price = $itemCart['price'];
                     $sale->fee = $transaction->fee;
                     $sale->member_id = $member->id;
                     $sale->team_id = $team->id;
                     $sale->payment_id = $uuid;
                     $sale->save();
                     //update schedule
                     $history->status = 2;
                     $history->save();
                 }
             } else {
                 //save error that vault didnt exist
                 $errors[] = array('payment_schedule_id' => $schedule->id, 'error_description' => 'Customer Vault not found', 'error_amount' => number_format($schedule->total, 2), 'daily_log_id' => $dayLog->id);
                 array_push($errorAmount, number_format($schedule->total, 2));
             }
         } catch (Exception $e) {
             //save internal error
             $errors[] = array('payment_schedule_id' => $schedule->id, 'error_description' => $e, 'error_amount' => number_format($schedule->total, 2), 'daily_log_id' => $dayLog->id);
             array_push($errorAmount, number_format($schedule->total, 2));
         }
     }
     //end of foreach schedule
     //save log for everything done
     $dayLogEnd = ScheduleDailyLog::find($dayLog->id);
     $dayLogEnd->ended_on = Carbon::now()->toDateTimeString();
     $dayLogEnd->successful_count = Count($totalAmount);
     $dayLogEnd->error_count = Count($errors);
     $dayLogEnd->total_amount = array_sum($totalAmount);
     $dayLogEnd->total_amount_error = array_sum($errorAmount);
     $dayLogEnd->save();
     //save log for errors
     if (Count($errors) > 0) {
         foreach ($errors as $errorItem) {
             $scheduleError = new ScheduleDailyError();
             $scheduleError->error_description = $errorItem['error_description'];
             $scheduleError->error_amount = $errorItem['error_amount'];
             $scheduleError->payment_schedule_id = $errorItem['payment_schedule_id'];
             $scheduleError->daily_log_id = $dayLogEnd->id;
             $scheduleError->save();
         }
     }
     return Log::info($errors);
 }
 function ajax_insert_cart()
 {
     if (empty($_REQUEST['id']) || empty($_REQUEST['qty']) || empty($_REQUEST['price']) || empty($_REQUEST['name']) || !is_numeric($_REQUEST['price']) || !is_numeric($_REQUEST['qty']) || !is_numeric($_REQUEST['id']) || intval($_REQUEST['qty']) <= 0) {
         $this->ajaxReturn('参数错误', '失败', 0);
         exit;
     }
     import('ORG.Util.Cart');
     $items = array(array('id' => (int) $_REQUEST['id'], 'qty' => (int) $_REQUEST['qty'], 'price' => $_REQUEST['price'], 'name' => $_REQUEST['name'], 'option' => array('gtype' => (string) $_REQUEST['gtype'], 'pic' => (string) $_REQUEST['pic'])));
     $cart = new Cart();
     $cart->insert($items);
     $this->ajaxReturn($cart->contents(), '成功', 1);
 }
Пример #12
0
 public function postAddtocart()
 {
     $cake = Cakes::find(Input::get('id'));
     $quantity = Input::get('quantity');
     $delivery_date = Input::get('delivery_date');
     $price = Input::get('price');
     Cart::insert(array('id' => $cake->id, 'code' => $cake->product_code, 'name' => $cake->title, 'price' => $price, 'quantity' => $quantity, 'vendor_id' => Input::get('vend_id'), 'type' => 'p', 'delivery_date' => $delivery_date, 'image' => $cake->image));
     return Redirect::to('home/cart')->with('purchase_type', 'cake');
 }
Пример #13
0
 public function postAddtocart()
 {
     $product = Product::find(Input::get('id'));
     $quantity = Input::get('quantity');
     $delivery_date = Input::get('delivery_date');
     $price = '';
     if (isset($_GET['reg'])) {
         $price = Input::get('reg_price');
     } else {
         if (isset($_GET['dlx'])) {
             $price = Input::get('dlx_price');
         } else {
             if (isset($_GET['pri'])) {
                 $price = Input::get('prm_price');
             }
         }
     }
     Cart::insert(array('id' => $product->id, 'code' => $product->product_code, 'name' => $product->title, 'price' => $price, 'quantity' => $quantity, 'vendor_id' => Input::get('vend_id'), 'type' => 'p', 'delivery_date' => $delivery_date, 'image' => $product->image));
     $addons = Input::get('aid');
     if (!empty($addons)) {
         foreach ($addons as $key => $value) {
             $addon = Addon::find($value);
             Cart::insert(array('id' => $addon->id, 'name' => $addon->description, 'price' => $addon->price, 'quantity' => $quantity, 'vendor_id' => $addon->vendor_id, 'delivery_date' => $delivery_date, 'type' => 'a', 'image' => $addon->image));
         }
     }
     return Redirect::to('home/cart')->with('purchase_type', 'flower');
 }
 public function addToCart()
 {
     $input = Input::all();
     Log::debug('Form input array for addToCart(): ' . print_r($input, TRUE));
     $product = Product::find($input['session_id']);
     // Check to see if item is already in cart.
     // Don't add, if it already is.
     if (!Cart::find($input['session_id'])) {
         $cart_item = array('id' => $product->id, 'name' => Utility::truncateStringWithEllipsis($product->session_title, 35) . ' - ' . $product->speaker_first_name . ' ' . $product->speaker_last_name . ' - ' . $product->prod_code, 'price' => $product->price, 'quantity' => $input['qty'], 'prod_type' => $product->prod_type, 'unit_count' => $product->unit_count, 'prod_code' => $product->prod_code, 'form_id' => $product->form_id, 'workshop_year' => $product->workshop_year, 'session_title' => $product->session_title, 'speaker_name' => $product->speaker_first_name . ' ' . $product->speaker_last_name);
         if (Input::has('MP3') && $input['MP3'] === 'mp3') {
             $cart_item['prod_type'] = 'MP3';
             $cart_item['quantity'] = 1;
             $cart_item['price'] = \Config::get('workshop.unit_price_list')['MP3'];
         }
         Cart::insert($cart_item);
         // Get cart contents and update pop-up (modal) cart window with
         // full cart details.
         $message = 'Item added to cart.';
     } else {
         $message = '<strong>Item already in cart.</strong>';
     }
     // Return user to previous page
     return Redirect::back()->with('message', $message);
 }