Exemplo n.º 1
0
 function testShouldRemoveFromQuantity()
 {
     $cart = new Cart();
     $cart->add(5);
     $cart->remove(5);
     $this->assertEquals(0, $cart->quantity(5), 'should remove from quantity');
 }
Exemplo n.º 2
0
 public function removeCart($image_id)
 {
     $row = Cart::search(array('id' => $image_id));
     if ($row) {
         //print_r($row);exit;
         Cart::remove($row[0]);
     }
     return Redirect::route('order-cart');
 }
Exemplo n.º 3
0
 public function testCartCanRemove()
 {
     Cart::add(1, 'test', 1, 10.0, array('size' => 'L'));
     Cart::add(2, 'test', 1, 10.0, array('size' => 'L'));
     $rowId = Cart::content()->first()->rowid;
     Cart::remove($rowId);
     $this->assertEquals(Cart::count(), 1);
     $this->assertNull(Cart::get($rowId));
     $this->assertInstanceOf('Gloudemans\\Shoppingcart\\CartCollection', Cart::content());
 }
Exemplo n.º 4
0
 public function dropItem()
 {
     if (Request::ajax()) {
         $id = Input::get('id');
         $cart = Cart::get($id);
         Cart::remove($id);
         $count = Cart::count();
         $total = Cart::total();
         return Response::json(array('type' => 'success', 'id' => $cart->id, 'count' => $count, 'total' => $total));
     }
 }
Exemplo n.º 5
0
 public function ajaxCartRemove()
 {
     Cart::remove(Input::get('idRow'));
     $cartContentObj = Cart::content();
     $cartContentArr = [];
     $cartCount = Cart::count();
     foreach ($cartContentObj as $item) {
         $item->options['thumbnail'] = $item->ware->thumbnail;
         $item->options['slug'] = $item->ware->slug;
         $cartContentArr[] = $item;
     }
     return compact('cartContentArr', 'cartCount');
 }
Exemplo n.º 6
0
 public static function borrarProducto($input)
 {
     $respuesta = array();
     $reglas = array('id' => array('integer'));
     $validator = Validator::make($input, $reglas);
     if ($validator->fails()) {
         $respuesta['mensaje'] = $validator;
         $respuesta['error'] = true;
     } else {
         if (is_null(Session::get('carrito'))) {
             Carrito::agregar($input);
         }
         $producto = Producto::find($input['producto_id']);
         $carrito = Carrito::find(Session::get('carrito'));
         $datos[$producto->id] = array('fecha_baja' => date("Y-m-d H:i:s"), 'estado' => 'B');
         $carrito->productos()->sync($datos, false);
         Cart::remove($input['rowId']);
         $respuesta['mensaje'] = 'Producto carrito borrado.';
         $respuesta['error'] = false;
         $respuesta['data'] = $carrito;
     }
 }
Exemplo n.º 7
0
 function remove()
 {
     // Removing all cart itens
     $carItem = $this->cart[0]["Id"];
     $objItemCart = new Cart($this->bd);
     $objItemCart->remove($this->sessKey);
 }
Exemplo n.º 8
0
 public function minusCart($deal_id)
 {
     $cart = \Cart::get($deal_id);
     $newQuantity = --$cart->quantity;
     if ($newQuantity <= 0) {
         \Cart::remove($deal_id);
     } else {
         \Cart::update($deal_id, ['quantity' => $newQuantity]);
     }
     return redirect('/gio-hang');
 }
 public function deleteItemGaji($rowId, $id)
 {
     Cart::remove($rowId);
     $url = URL::action("MasterKaryawanController@addGaji", ['id' => $id]) . "#datatable";
     return Redirect::to($url);
 }
Exemplo n.º 10
0
 public function action_remove_cart_item($uid = false)
 {
     $item = \Cart::item($uid);
     if ($item) {
         if ($unique_id = $item->get('unique_id')) {
             // Set artwork for delete
             if ($artworks = \Order\Model_Artwork::find(array('where' => array('unique_id' => $unique_id)))) {
                 foreach ($artworks as $artwork) {
                     $artwork->deleted_at = time();
                     $artwork->save();
                 }
             }
         }
         \Cart::remove($uid);
         \Messages::success('Product successfully deleted from cart.');
     } else {
         \Messages::error('There was an error while trying to delete product from cart.');
     }
     \Response::redirect(\Uri::create('order/checkout/cost'));
 }
Exemplo n.º 11
0
});
Route::post('/product/{id?}/deletecart', function () {
    if (Request::ajax()) {
        $product_id = Request::get('id');
        //Cart::remove($product_id);
        //Cart::clear();
        $cartData = Cart::getContent();
        return $cartData->toArray();
    } else {
        return "not ajax";
    }
});
Route::post('/product/deletecart', function () {
    if (Request::ajax()) {
        $product_id = Request::get('id');
        Cart::remove($product_id);
        //Cart::clear();
        $cartData = Cart::getContent();
        return $cartData->toJson();
    } else {
        return "not ajax";
    }
});
Route::post('product/add_to_cart', function () {
    if (Request::ajax()) {
        $i = 0;
        $data = Input::all();
        //return $data[];
        //dd($fonts);
        foreach ($data['dataArr'] as $val) {
            echo $val['color'];
Exemplo n.º 12
0
 public function postSearch($item = "")
 {
     if (Request::ajax()) {
         if (isset($_POST['buypid'])) {
             $optionprice = $name = DB::table('products_options')->where('product_id', $_POST['buypid'])->where("option_value", $_POST['buyoption'])->pluck('price');
             return $optionprice;
             exit;
         }
         if (isset($_POST['pid'])) {
             $item = Product::find($_POST['pid']);
             Cart::add(array('id' => $item->id, 'name' => $item->title, 'qty' => 1, 'price' => $item->price, 'options' => array('size' => Input::get("size"), 'buying' => Input::get('buying'), 'volume' => Input::get("volume"), 'optionid' => Input::get("optid"), 'weight' => Input::get("weight"))));
             $content = Cart::content();
             Session::put("cartItems", $content);
             $total = Cart::total();
             $itemHtml = "";
             $itemHtml .= "<div class='beta-select'><i class='fa fa-shopping-cart'></i><span id='cart-count'> Cart (" . Cart::count() . ")</span> <i class='fa fa-chevron-down'></i></div>\n                     <div class='beta-dropdown cart-body'>";
             if ($content) {
                 foreach ($content as $itemRow) {
                     $product = Product::find($itemRow->id);
                     if ($itemRow->options->has('buying') && $itemRow->options->buying != "") {
                         $itemRow->price = DB::table('products_options')->where("product_option_value_id", $itemRow->optionid)->pluck('price');
                     }
                     if (public_path()) {
                         $source_folder = public_path() . '/uploads/images/';
                         $destination_folder = public_path() . '/uploads/images/';
                     } else {
                         $source_folder = '/home/medicalng/public_html/uploads/images/';
                         $destination_folder = '/home/medicalng/public_html/uploads/images/';
                     }
                     $image_info = pathinfo($source_folder . $product->image);
                     $image_extension = strtolower($image_info["extension"]);
                     //image extension
                     $image_name_only = strtolower($image_info["filename"]);
                     //file name only, no extension
                     $imgName = $image_name_only . "-50x50" . "." . $image_extension;
                     $itemHtml .= "<div class='cart-item'>\n                             <!--<a class='cart-item-edit' pid='" . $itemRow->rowid . "' href=\"javascript:void(0);\"><i class='fa fa-pencil'></i></a>-->\n                             <a class='cart-item-delete' pid='" . $itemRow->rowid . "' href=\"javascript:void(0);\"><i class='fa fa-times'></i></a>\n                             <div class='media'>\n                                 <a class='pull-left' href=\"javascript:void(0);\"><img src='" . url() . "/uploads/images/thumbs/{$imgName}' alt=''></a>\n                                 <div class='media-body'>\n                                     <span class='cart-item-title'>" . $itemRow->name . "</span>\n                                     ";
                     $itemHtml .= "<span class='cart-item-options'>";
                     $itemHtml .= $itemRow->options->has('size') ? " - Size: " . $itemRow->options->size : '';
                     $itemHtml .= $itemRow->options->has('buying') ? " - Buying Option: " . $itemRow->options->buying : '';
                     $itemHtml .= $itemRow->options->has('volume') ? " - Volume: " . $itemRow->options->volume : '';
                     $itemHtml .= "</span>";
                     $itemHtml .= "\n                                     <span class='cart-item-amount'>{$itemRow->qty}*<span>&#8358;" . number_format($itemRow->price, 2, '.', ',') . "</span>\n                                 </div>\n                             </div>\n                         </div>\n\n                         ";
                 }
                 $itemHtml .= "<div class='cart-caption'>\n                             <div class='cart-total text-right'>Subtotal: <span class='cart-total-value'>&#8358;" . number_format($total, 2, ".", ",") . "</span></div>\n                             <div class='clearfix'></div>\n\n                             <div class='center'>\n                                 <div class='space10'>&nbsp;</div>\n                                 <a href='" . url() . "/cart' class='beta-btn primary text-center'>Checkout <i class='fa fa-chevron-right'></i></a>\n                             </div>\n                             </div>";
             } else {
                 $itemHtml .= "Cart is empty";
             }
             $itemHtml .= "</div>";
             echo $itemHtml;
         }
         if (isset($_POST['delid'])) {
             //$item = Product::find($_POST['delid']);
             Cart::remove($_POST['delid']);
             //(array('id' => $item->id, 'name' => $item->title, 'qty' => 1, 'price' => $item->price));
             $content = Cart::content();
             Session::put("cartItems", $content);
             $total = Cart::total();
             $itemHtml = "";
             $itemHtml .= "<div class='beta-select'><i class='fa fa-shopping-cart'></i><span id='cart-count'> Cart (" . Cart::count() . ")</span> <i class='fa fa-chevron-down'></i></div>\n                     <div class='beta-dropdown cart-body'>";
             if ($content) {
                 foreach ($content as $itemRow) {
                     $product = Product::find($itemRow->id);
                     if ($itemRow->options->has('buying') && $itemRow->options->buying != "") {
                         $itemRow->price = DB::table('products_options')->where("product_option_value_id", $itemRow->optionid)->pluck('price');
                     }
                     $image_info = pathinfo($source_folder . $product->image);
                     $image_extension = strtolower($image_info["extension"]);
                     //image extension
                     $image_name_only = strtolower($image_info["filename"]);
                     //file name only, no extension
                     $imgName = $image_name_only . "-50x50" . "." . $image_extension;
                     $itemHtml .= "<div class='cart-item'>\n                             <!--<a class='cart-item-edit' pid='" . $itemRow->rowid . "' href=\"javascript:void(0);\"><i class='fa fa-pencil'></i></a>-->\n                             <a class='cart-item-delete' pid='" . $itemRow->rowid . "' href=\"javascript:void(0);\"><i class='fa fa-times'></i></a>\n                             <div class='media'>\n                                 <a class='pull-left' href=\"javascript:void(0);\"><img src='" . url() . "/uploads/images/thumbs/{$imgName}' alt=''></a>\n                                 <div class='media-body'>\n                                     <span class='cart-item-title'>" . $itemRow->name . "</span>\n                                     ";
                     $itemHtml .= "<span class='cart-item-options'>";
                     $itemHtml .= $itemRow->options->has('size') ? " - Size: " . $itemRow->options->size : '';
                     $itemHtml .= $itemRow->options->has('buying') ? " - Buying Option: " . $itemRow->options->buying : '';
                     $itemHtml .= $itemRow->options->has('volume') ? " - Volume: " . $itemRow->options->volume : '';
                     $itemHtml .= "</span>";
                     $itemHtml .= "\n                                     <span class='cart-item-amount'>{$itemRow->qty}*<span>&#8358;" . number_format($itemRow->price, 2, '.', ',') . "</span>\n                                 </div>\n                             </div>\n                         </div>\n\n                         ";
                 }
                 $itemHtml .= "<div class='cart-caption'>\n                             <div class='cart-total text-right'>Subtotal: <span class='cart-total-value'>&#8358;" . number_format($total, 2, ".", ",") . "</span></div>\n                             <div class='clearfix'></div>\n\n                             <div class='center'>\n                                 <div class='space10'>&nbsp;</div>\n                                 <a href='" . url() . "/cart' class='beta-btn primary text-center'>Checkout <i class='fa fa-chevron-right'></i></a>\n                             </div></div>";
             } else {
                 $itemHtml .= "Cart is empty";
             }
             $itemHtml .= "</div>";
             echo $itemHtml;
         }
     }
 }
Exemplo n.º 13
0
 public function action_remove_cart_item($uid = false)
 {
     $item = \Cart::item($uid);
     if ($item) {
         if ($unique_id = $item->get('unique_id')) {
             // Set artwork for delete
             if ($artworks = \Order\Model_Artwork::find(array('where' => array('unique_id' => $unique_id)))) {
                 foreach ($artworks as $artwork) {
                     $artwork->set(array('deleted_at' => time()));
                     $artwork->save();
                 }
             }
         }
         \Cart::remove($uid);
         \Messages::success('Product successfully deleted from cart.');
     } else {
         \Messages::error('There was an error while trying to delete product from cart.');
     }
     echo \Messages::display();
 }
Exemplo n.º 14
0
 public function removeToCart()
 {
     $product = Product::where('code', '=', Input::get('product'))->firstOrFail();
     $rowId = Cart::search(array('id' => $product->code));
     Cart::remove($rowId[0]);
     Session::flash('message', 'Successfully ' . $product->name . ' deattached to the basket');
     return Redirect::to('product');
 }
Exemplo n.º 15
0
 public function removeItem($rowid)
 {
     $rem = Cart::remove($rowid);
     return Redirect::route('store.cart')->with('cartContent', Cart::content())->with('message', 'berhasil menghapus item dari keranjang');
 }
Exemplo n.º 16
0
 public function removeProduct(Request $request)
 {
     \Cart::remove($request->input('rowid'));
     return redirect()->back();
 }