function choiceDetail() { $choiceList = $this->uri->segment(2); $choice = explode("-", $choiceList); $product = new Product(); $product->where_in('id', $choice); $product->get_iterated(); $dis['mainProduct'] = $choice[0]; $dis['base_url'] = base_url(); $dis['product'] = $product; $this->load->view('front/product/choiceList', $dis); }
public function get_index() { $getCartInformation = Cache::get('user_cart.' . Sentry::user()->id); $items = array(); if ($getCartInformation) { foreach ($getCartInformation as $key => $value) { array_push($items, $key); } } else { return false; } $prods = Product::where_in('id', $items)->get(); return View::make('checkout.index')->with('product', $prods)->with('cache', $getCartInformation); }
public function get_index() { Title::put('Alışveriş Sepeti'); $getCartInformation = $this->getCache(); $items = array(); $prods = false; if ($getCartInformation) { foreach ($getCartInformation as $key => $value) { array_push($items, $key); } $prods = Product::where_in('id', $items)->get(); } return View::make('cart.index')->with('product', $prods)->with('cache', $getCartInformation); }
function index_get() { $filters = $this->get("filter")["filters"]; $page = $this->get('page') !== false ? $this->get('page') : 1; $limit = $this->get('limit') !== false ? $this->get('limit') : 50; $sort = $this->get("sort"); $data["results"] = array(); $data["count"] = 0; $obj = new Product(null, $this->entity); //Sort if (!empty($sort) && isset($sort)) { foreach ($sort as $value) { $obj->order_by($value["field"], $value["dir"]); } } //Filter if (!empty($filters) && isset($filters)) { $deleted = 0; foreach ($filters as $value) { if (!empty($value["operator"]) && isset($value["operator"])) { if ($value["operator"] == "where_in") { $obj->where_in($value["field"], $value["value"]); } else { if ($value["operator"] == "or_where_in") { $obj->or_where_in($value["field"], $value["value"]); } else { if ($value["operator"] == "where_not_in") { $obj->where_not_in($value["field"], $value["value"]); } else { if ($value["operator"] == "or_where_not_in") { $obj->or_where_not_in($value["field"], $value["value"]); } else { if ($value["operator"] == "like") { $obj->like($value["field"], $value["value"]); } else { if ($value["operator"] == "or_like") { $obj->or_like($value["field"], $value["value"]); } else { if ($value["operator"] == "not_like") { $obj->not_like($value["field"], $value["value"]); } else { if ($value["operator"] == "or_not_like") { $obj->or_not_like($value["field"], $value["value"]); } else { if ($value["operator"] == "startswith") { $obj->like($value["field"], $value["value"], "after"); } else { if ($value["operator"] == "endswith") { $obj->like($value["field"], $value["value"], "before"); } else { if ($value["operator"] == "contains") { $obj->like($value["field"], $value["value"], "both"); } else { if ($value["operator"] == "or_where") { $obj->or_where($value["field"], $value["value"]); } else { if ($value["operator"] == "by_vendor") { $obj->where_related("stock", $value["field"], $value["value"]); } else { if ($value["operator"] == "search") { $obj->like("sku", $value["value"], "after"); $obj->or_like("name", $value["value"], "both"); $obj->or_like("description", $value["value"], "both"); } else { $obj->where($value["field"] . ' ' . $value["operator"], $value["value"]); } } } } } } } } } } } } } } } else { if ($value["field"] == "deleted") { $deleted = $value["value"]; } else { $obj->where($value["field"], $value["value"]); } } } $obj->where("deleted", $deleted); } //Result $obj->get_paged_iterated($page, $limit); $data["count"] = $obj->paged->total_rows; if ($obj->result_count() > 0) { foreach ($obj as $value) { $priceList = array(); foreach ($value->price_list->get() as $p) { $priceList[] = array("id" => $p->id, "currency_id" => $p->currency_id, "product_id" => $p->product_id, "unit_id" => $p->unit_id, "price" => floatval($p->price), "unit_value" => floatval($p->unit_value), "locale" => $p->currency->get()->locale, "unit" => $p->unit->get()->name); } $cost = array(); // foreach ($value->stock->order_by("issued_date", "desc")->get() as $c) { // $cost = array( // "id" => $c->id, // "quantity" => floatval($c->quantity), // "price" => floatval($c->price), // "locale" => $c->currency->get()->locale, // "unit" => $c->unit->get()->name // ); // } $data["results"][] = array("id" => $value->id, "category_id" => $value->category_id, "unit_id" => $value->unit_id, "sku" => $value->sku, "name" => $value->name, "description" => $value->description, "on_hand" => floatval($value->on_hand), "order_point" => floatval($value->order_point), "favorite" => $value->favorite == 0 ? false : true, "image_url" => $value->image_url, "status" => $value->status == 0 ? false : true, "deleted" => $value->deleted, "unit" => $value->unit->get()->name, "cost" => $cost, "price_lists" => $priceList); } } //Response Data $this->response($data, 200); }
function itemsTotal($currentcart = null) { if ($currentcart != null) { $items = array(); foreach ($currentcart as $key => $value) { array_push($items, $key); } $prods = Product::where_in('id', $items)->get(); $price = array("price" => 0, "discount" => 0, "total" => 0); foreach ($prods as $item) { $qty = $currentcart[$item->id]['_qty']; $_price = getItemPrice($item); $price['price'] += floor($_price->price_raw) * $qty; $price['total'] += floor($_price->tax_raw) * $qty; } return arrayToObject(array_map("getTotal", $price)); } else { return false; } }
function getVisitedProduct() { $cartDetail = $this->getProductCookie(); array_push($cartDetail, 0); $product = new Product(); $product->where_in('id', $cartDetail); $product->get_iterated(); return $product; }
private static function checkModel($model = array()) { return Product::where_in('model', $model)->find_many(); }
function goods($deep = false) { if ($deep) { return Product::where_in('group', prop('id', $this->subgroups())); } else { return $this->has_many(NS . 'Product', 'group'); } }