public function cart_addproduct() { $data = Input::all(); $product = Product::find((int) $data['id']); if ($product->getDiscount) { $price = getItemPrice($product->price, $product->getTax, $product->getDiscount); } else { $price = getItemPrice($product->price, $product->getTax); } $images = getProductImages($product); $maxQty = $product->quantity; $quantity = ceil($data['stock']); // ceil for the abuse floats and decimals if ($quantity >= $maxQty) { $quantity = $maxQty; } elseif ($quantity < 0) { $quantity = 1; } }
public function post_JXcreate() { $data = Input::all(); $product = Product::find((int) $data['id']); $price = getItemPrice($product); $images = getProductImages($product); $maxQty = $product->quantity; $quantity = ceil($data['stock']); // ceil for the abuse floats and decimals //Checking measures of our number if negative or is float or its more than our stock. if ($quantity >= $maxQty) { $quantity = $maxQty; } elseif ($quantity < 0) { $quantity = 1; } $Identifier = $this->getIdentifier(); if (Cache::has('user_cart.' . $Identifier)) { $currentcart = Cache::get('user_cart.' . $Identifier); if (array_key_exists($product->id, $currentcart)) { $currentcart[$product->id]['_qty'] = $currentcart[$product->id]['_qty'] + $quantity; //999 if ($currentcart[$product->id]['_qty'] >= $maxQty) { $currentcart[$product->id]['_qty'] = $maxQty; //girilen sayı, toplam stoktaki sayıdan büyük veya eşitse her daim max stok sayısı gir. } Cache::forever('user_cart.' . $Identifier, $currentcart); $message = Lang::line('cart_lang.add_cart_fix', array('name' => $product->getDetail->name, 'number' => $quantity))->get(); } else { $currentcart[$product->id] = array('_sku' => $product->sku, '_qty' => $quantity); Cache::forever('user_cart.' . $Identifier, $currentcart); $message = Lang::line('cart_lang.add_cart', array('name' => $product->getDetail->name))->get(); } } else { $arrayval = array($product->id => array('_sku' => $product->sku, '_qty' => $quantity)); Cache::forever('user_cart.' . $Identifier, $arrayval); $message = Lang::line('cart_lang.add_cart', array('name' => $product->getDetail->name))->get(); } $images = $images != null ? $images->main->tiny : null; return Response::json(array('product_name' => $product->getDetail->name, 'product_price' => $price, 'variant' => $product->getDetail->variant, 'img' => $images, 'message' => $message)); }
public function get_index($alias) { //We need Category ID for grabbing products $category_id = CategoryDescription::with('getCategory')->where('alias', '=', $alias)->only('id'); if ($category_id == null) { return \Laravel\Redirect::to('/'); } //getting the products which belongs to this category! $data = Input::all(); //Category attrs for filters. $catAttr = Category::with(array("getAttributeListing", "getAttributeListing.getAttributes"))->where('id', '=', $category_id)->first(); $filter = array(); if (isset($data['Filter'])) { foreach ($data['Filter'] as $cLine) { $kvp = explode('[-]', $cLine); // [0] = Enerji Sınıfı , [1] = A++ $groupID = 0; $attrID = 0; foreach ($catAttr->getAttributeListing as $item) { if ($kvp[0] === $item->name) { $groupID = $item->id; foreach ($item->getAttributes as $item2) { if ($kvp[1] === $item2->value) { $attrID = $item2->id; $filter[$kvp[0]] = array("val" => $kvp[1], "id" => $attrID, 'GID' => $groupID); } } } } } } $price_range = array(); if (isset($data['Price_Range'])) { $price_range = explode(' - ', $data['Price_Range']); if ($price_range[0] == "2500TL ve üzeri") { $price_range[0] = 2500; $price_range[1] = 999999; } } $countforCache = Category::with('getProducts')->where('id', '=', $category_id)->first()->getProducts()->count(); if (Cache::has('category.products.' . $category_id)) { $a = Cache::get('category.products.' . $category_id); $a = count($a->getProducts); if ($a !== $countforCache) { Cache::forget('category.products.' . $category_id); } } if (!Cache::has('category.products.' . $category_id)) { $result = Category::with(array("getProducts", "getProducts.getDetail", "getProducts.getBrand", "getProducts.getImages", "getProducts.getTax", "getProducts.getDiscount", "getProducts.getAttributes", "getChildren", "getChildren.getDescriptions", "getChildren.getProducts", "getSlideshow", "getSlideshow.getItems", "getAttributeListing", "getAttributeListing.getAttributes", "getAttributeListing.getAttributes.productSpecific"))->where('id', '=', $category_id)->first(); Cache::forever('category.products.' . $category_id, $result, 3); } $result = Cache::get('category.products.' . $category_id); $products = array(); $attributes = array(); $brands = array(); $price = array(); $range = array(); if (isset($filter)) { foreach ($result->getProducts as $product) { $mami = array(); $prodPrice = getItemPrice($product)->tax_raw; foreach ($product->getAttributes as $mam) { $mami[] = $mam->id; } $invalid = FALSE; foreach ($filter as $filtresingle) { if (array_search($filtresingle['id'], $mami) === FALSE) { $invalid = TRUE; break; } } if ($invalid == FALSE) { //check for price range! if (!empty($price_range)) { if ($prodPrice > $price_range[0] && $prodPrice <= $price_range[1]) { $brands[] = $product->getBrand->name; $price[] = getItemPrice($product)->tax_raw; foreach ($product->getAttributes as $attribute) { array_push($attributes, $attribute->id); } array_push($products, $product); } } else { $brands[] = $product->getBrand->name; $price[] = getItemPrice($product)->tax_raw; foreach ($product->getAttributes as $attribute) { array_push($attributes, $attribute->id); } array_push($products, $product); } } else { } } } if ($price != null) { $price = PriceRange::create($price); } if ($brands != null) { $brands = array_unique($brands); } $attributes = array_count_values($attributes); $attrgroup = array(); foreach ($result->getAttributeListing as $groups) { foreach ($groups->getAttributes as $attr) { if (array_key_exists($attr->id, $attributes)) { array_push($attrgroup, $groups->id); } } } Title::put($result->getDescriptions->name . ' Kategorisi'); return View::make('category.index')->with('result', $result)->with('brands', $brands)->with('products', $products)->with('filters', $filter)->with('attribute_filter', $attributes)->with('ranges', $price)->with('selected_ranges', $price_range); }
</div> </div> <div class="row-fluid"> @foreach($result as $res) @if($res->getProductsMostView4sq) <?php $count = 0; $numItems = count($res->getProductsMostView4sq); ?> @foreach($res->getProductsMostView4sq as $item) <?php $images = getProductImages($item); ?> @if($item->getImages) <?php $price = getItemPrice($item); ?> @endif <div class="span3"> <div class="thumbnail" style="padding: 0"> <div style="padding:4px"> @if($item->getImages) <a href="{{URL::base()}}/product/<?php echo $item->alias; ?> " class="thumbnailimg"> <img alt="{{$item->getDetail->name}}" src="{{$images->main->small}}" style="display:block;margin:0 auto;" /></a> @else <img style="display:block;margin:0 auto;" alt="300x200" style="width: 100%" src="http://placehold.it/200x150"> @endif </div>
<th style="width: 5%"><p class="text-center">Sipariş</p></th> <th style="width: 10%"><p class="text-left">Ürün Bilgileri</p></th> <th style="width: 5%"><p class="text-center">Adet</p></th> <th style="width: 10%"><p class="text-center">Fiyat</p></th> <th style="width: 7%"><p class="text-center">Kargo Bilgileri</p></th> <th style="width: 15%"><p class="text-center">Sipariş Durumu</p></th> <th style="width: 10%"><p class="text-center">Sipariş Tarihi</p></th> </tr> </thead> <tbody> @foreach($order as $item) <tr> <td><a href="/user/order/{{$hasher->encrypt($item->id)}}">{{$hasher->encrypt($item->id)}}</a></td> <?php $images = getProductImages($item->getProduct); $price = getItemPrice($item->getProduct->price, $item->getProduct->getTax, $item->getProduct->getDiscount); ?> <td> <div class="order-prod"> <img alt="{{$item->getProduct->getDetail->name}}" src="<?php echo $images->main->tinym; ?> "> <p class="text-center"><strong><?php echo $item->getProduct->getDetail->name; ?> </strong></p> <span><?php echo $item->getProduct->getDetail->variant; ?> </span>
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; } }
$anagrafica = new Anagrafica(); $partner = $anagrafica->getPartner($_POST['clfoco']); $form['search_partner'] = substr($partner['ragso1'],0,4); $form['clfoco'] = 0; } if (isset($_POST['newitem'])) { $result = gaz_dbi_get_row($gTables['artico'],"codice",$_POST['artico']); $form['search_item'] = substr($result['codice'],0,4); $form['artico'] = ""; } if (isset($_POST['Return'])) { header("Location: ".$_POST['ritorno']); exit; } if ($_POST['hidden_req']=='new_price') { $form['prezzo']=getItemPrice($form['artico'],$form['clfoco']); $form['hidden_req']=''; } if (!empty($_POST['Insert'])) { // Se viene inviata la richiesta di conferma totale ... $utsreg = mktime(0,0,0,$form['mesreg'],$form['gioreg'],$form['annreg']); $utsdoc = mktime(0,0,0,$form['mesdoc'],$form['giodoc'],$form['anndoc']); if (!checkdate( $form['mesreg'], $form['gioreg'], $form['annreg'])) $msg .= "16+"; if (!checkdate( $form['mesdoc'], $form['giodoc'], $form['anndoc'])) $msg .= "15+"; if ($utsdoc > $utsreg) { $msg .= "17+"; } if (empty($form['artico'])) { //manca l'articolo $msg .= "18+"; }
$buyitemprice = getItemPrice($buyitemid, 0); if ($hero['gold'] < $buyitemprice) { echo "<div class='alert'>Not enough gold!</div>"; } else { mysqli_query($conn, "UPDATE Inventory SET equip = 0, time = 0, owner = {$cookie['0']} WHERE inventoryid = '{$_POST['buyitemid']}' AND time > 0"); mysqli_query($conn, "UPDATE Hero SET gold = gold - {$buyitemprice} WHERE id = '{$cookie['0']}'"); } } $items = mysqli_query($conn, "SELECT * FROM Inventory LEFT JOIN ItemBase ON Inventory.base = ItemBase.baseid Left JOIN ItemPrefix ON Inventory.prefix = ItemPrefix.prefixid LEFT JOIN ItemSuffix ON Inventory.suffix = ItemSuffix.suffixid LEFT JOIN Hero ON Inventory.owner = Hero.id WHERE Inventory.time > 0 ORDER BY time ASC"); $itemlist = []; while ($row = mysqli_fetch_assoc($items)) { if ($row['time'] <= time()) { mysqli_query($conn, "DELETE FROM Inventory WHERE inventoryid = '{$row['inventoryid']}' AND time > 0"); continue; } $row['price'] = getItemPrice($row['inventoryid'], 0); $row['sdam'] = getItemStats($row['inventoryid'], "sdam"); $row['pdam'] = getItemStats($row['inventoryid'], "pdam"); $row['bdam'] = getItemStats($row['inventoryid'], "bdam"); $row['adam'] = getItemStats($row['inventoryid'], "adam"); $row['ddam'] = getItemStats($row['inventoryid'], "ddam"); $row['sarm'] = getItemStats($row['inventoryid'], "sarm"); $row['parm'] = getItemStats($row['inventoryid'], "parm"); $row['barm'] = getItemStats($row['inventoryid'], "barm"); $row['aarm'] = getItemStats($row['inventoryid'], "aarm"); $row['darm'] = getItemStats($row['inventoryid'], "darm"); $row['hpreg'] = getItemStats($row['inventoryid'], "hpreg"); $row['mpreg'] = getItemStats($row['inventoryid'], "mpreg"); $row['itemdes'] = getItemDes($row['inventoryid'], 0, 0, 0); $itemlist[] = $row; }
@layout('layouts.default') @section('content') {{-- Getting Images --}} <!-- TODO: fiyatlara cache ekle ürün başına --> <?php $productObj = $product->getProducts[0]; $images = getProductImages($productObj); $price = getItemPrice($productObj); ?> {{-- Getting Images --}} <div class="row-fluid"> <div class="span12"> <div id="breadcrumb"> <ul class="breadcrumb" style="margin-bottom: 5px;"> <li> <a href="{{URL::base()}}">Ana Sayfa</a> <span class="divider">/</span> </li> <li> Ana Kategori : <a href="{{URL::base()}}/category/{{$product->getTopCat->getDescriptions->alias}}">{{$product->getTopCat->getDescriptions->name}}</a> <span class="divider">/</span> </li> <li> Kategori : <a href="{{URL::base()}}/category/{{$product->getDescriptions->alias}}">{{$product->getDescriptions->name}}</a> <span class="divider">/</span> </li> <li class="active">{{$productObj->getDetail->name}}</li> </ul> </div>
function calculatePrice($ITD, $Price, $newStock) { $CPrice = getItemPrice($ITD); $Cstock = getStockALL($ITD); $StockTotal = $Cstock + $newStock; $total = $CPrice * $Cstock + $Price * $newStock; $final = $total / $StockTotal; return $final; }
echo "<div class='alert'>Here's where you'll find your hoard of <span class='red'>items</span> you pick up from adventuring. If you don't want them you can sell them to the <a href='market.php'><span class='red'>Market</span></a>, or equip them on your <a href='profile.php'><span class='red'>Profile</span></a>.</div>"; mysqli_query($conn, "UPDATE Hero SET tutorial = CONCAT(tutorial, 'inventoryintro|') WHERE id = '{$cookie['0']}'") or die(mysqli_error($conn)); } if (isset($_POST['sellitemid'])) { //protect these inputs from injection //protect other people items from f12ing $sellitemid = mysqli_real_escape_string($conn, $_POST['sellitemid']); $sellitemprice = getItemPrice($sellitemid, 0.4); $markettime = time() + 3 * 24 * 60 * 60; mysqli_query($conn, "UPDATE Inventory SET equip = 0, time = {$markettime} WHERE inventoryid = '{$_POST['sellitemid']}'"); mysqli_query($conn, "UPDATE Hero SET gold = gold + {$sellitemprice} WHERE id = '{$cookie['0']}'"); } $items = mysqli_query($conn, "SELECT * FROM Inventory LEFT JOIN ItemBase ON Inventory.base = ItemBase.baseid Left JOIN ItemPrefix ON Inventory.prefix = ItemPrefix.prefixid LEFT JOIN ItemSuffix ON Inventory.suffix = ItemSuffix.suffixid WHERE Inventory.owner = {$cookie['0']} AND Inventory.time = '0' AND Inventory.equip = '0' ORDER BY inventoryid DESC"); $itemlist = []; while ($row = mysqli_fetch_assoc($items)) { $row['value'] = getItemPrice($row['inventoryid'], 0.4); $row['sdam'] = getItemStats($row['inventoryid'], "sdam"); $row['pdam'] = getItemStats($row['inventoryid'], "pdam"); $row['bdam'] = getItemStats($row['inventoryid'], "bdam"); $row['adam'] = getItemStats($row['inventoryid'], "adam"); $row['ddam'] = getItemStats($row['inventoryid'], "ddam"); $row['sarm'] = getItemStats($row['inventoryid'], "sarm"); $row['parm'] = getItemStats($row['inventoryid'], "parm"); $row['barm'] = getItemStats($row['inventoryid'], "barm"); $row['aarm'] = getItemStats($row['inventoryid'], "aarm"); $row['darm'] = getItemStats($row['inventoryid'], "darm"); $row['hpreg'] = getItemStats($row['inventoryid'], "hpreg"); $row['mpreg'] = getItemStats($row['inventoryid'], "mpreg"); $row['itemdes'] = getItemDes($row['inventoryid'], 0, 0, 0); $itemlist[] = $row; }