/** * */ public function Confirm() { $auth = new Auth(); $shop = new ShoppingCart(); $user = $auth->id(); $myShop = $shop->all(); $objDetails = new DetalleCompra(); $total = 0; if (empty($myShop)) { return false; } foreach ($myShop as $key => $val) { $total += $val->precio * $val->cantidad; } $result_insert = $this->create($user, $total); if ($result_insert->success) { foreach ($myShop as $k => $v) { try { $objDetails->create($result_insert->id, $v->id_prod, $v->name, $v->cantidad, $v->precio, $v->talle, $v->color); //$stock = new TempStock(); //echo $stock->removeTempStock($user,$v->id_prod,$v->id_talle,$v->id_color,$v->type); } catch (Exception $e) { echo $e->getMessage(); } } $auth->restPoints($total); $auth->sumConsumed($total); $shop->removeAll(); return true; } }
public function checkPoints() { $user = Auth::User(); $ShoppingCart = new ShoppingCart(); $ShoppingCart->all(); $credit = $user->dblCredito; $total = $ShoppingCart->getTotal(); if ($credit - $total < 0) { return false; } else { return true; } }
<?php require 'inc/header.php'; $carrito = new ShoppingCart(); $items = $carrito->all(); ?> <!-- Header --> <!--detalle productos--> <div class="carrito-productos col-xs-12 col-sm-12 col-md-12 ol-lg-12"> <!--head-page--> <div class="head-page col-xs-12 col-sm-12 col-md-12 ol-lg-12"> <h3><?php $carrito->cantidad(); ?> productos agregados</h3> </div> <!--end / head-page--> <!-- tabla-detalle --> <table class="tabla-detalle col-xs-12 col-sm-12 col-md-12 ol-lg-12"> <thead > <tr> <th class="col-D text-uppercase">productos</th> <th class="col-B text-uppercase">talle</th> <th class="col-C text-uppercase">color</th> <th class="col-B text-uppercase">unidades</th> <th class="col-B text-uppercase">puntos</th> <th class="col-A text-uppercase"></th>
ini_set('display_errors', 'On'); /** * Verifico los puntos disponibles */ if (!Usuario::sCheckPoints()) { @header('Location: carrito.php'); exit; } /** * Seteo datos para el envio del email */ $user = Auth::User(); $seller = Vendedor::EmailById($user->vendedor); $shop = new ShoppingCart(); $image_url = "http://nufarm-maxx.com/marketingNet/images-clientes/"; $template = new Template('pedido', array("nombre" => $user->strNombre, "apellido" => $user->strApellido, "empresa" => $user->strEmpresa, "fecha" => date('d/m/Y'), "items" => Template::itemPedido($shop->all()), "total" => $shop->getTotal(), "direccion" => !empty($user->domicilio_entrega) ? "Domicilio de entrega: " . $user->domicilio_entrega : "", "ciudad" => !empty($user->ciudad) ? "Ciudad: " . $user->ciudad : "", "codigo_postal" => !empty($user->cp) ? "Codigo Postal: " . $user->cp : "", "telefono" => !empty($user->telefono) ? "Telefono: " . $user->telefono : "", "logo" => !empty($user->logo) ? $image_url . $user->logo : "")); /** * Checkeo el vencimiento * @var TempStock */ $checkVencimiento = new TempStock(); $can = $checkVencimiento->fechaVencimiento($_SESSION['MM_IdUsuario']); if ($can) { header('Location: catalogo.php'); } /** * Confirmo la compra */ if (!(new Compra())->confirm()) { header('Location: catalogo.php'); }