$page_shop="shop";
include "cabecera.php";
/*ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);*/
//////////////////ACCIONES
if ($accion=="anadircesta"){
$atributos = [];
// Recorremos los campos del formulario
foreach ($_POST as $key => $value) {
// Verificamos si la clave empieza con 'valoratributo_'
if (strpos($key, 'valoratributo_') === 0) {
// Extraemos el nombre del atributo
$nombreatributo = substr($key, strlen('valoratributo_'));
// Añadimos a la cadena en formato nombreatributo:$valoratributo
$atributos[] = "$nombreatributo:$value";
}
}
// Unimos todos los atributos en una sola cadena separada por comas
$cadenaatributos = implode(',', $atributos);
//echo $cadenaatributos; // Aquí tienes la cadena final
$sql = "INSERT INTO pagoporconversion_tienda_carrito SET id=null";
$sql.=", sesion='" . $con->real_escape_string($PHPSESSID) . "'";
$sql.=", idusuario=''";
$sql.=", idproducto='" . $con->real_escape_string($idproducto) . "'";
$sql.=", cantidad='1'";
$sql.=", factura=''";
$sql.=", atributos='" . $con->real_escape_string($cadenaatributos) . "'";
$sql.=", atributo1=''";
$sql.=", atributo2=''";
$sql.=", atributo3=''";
$sql.=", timestamp=''";
$sql.=", descuento=''";
$result=$con->query($sql);
}
/////////Cargo contenido pagina
$urlsinshop = str_replace("/shop/","","$urlactual");
$urlsinshop = str_replace("/","","$urlsinshop");
$plantilla="1";
///////////////////////MIGAS DE PAN
$idcategoriaacceso="0";
$sql11tf = "SELECT * FROM pagoporconversion_tienda_cat Where dominio ='$dominioacceso' and lug='$urlsinshop' ";
$result11tf=$con->query($sql11tf);
while($myrow11tf=$result11tf->fetch_assoc())
{
$idparentproductos = $myrow11tf["id"];
$idcategoriaacceso = $myrow11tf["id"];
$nombrecategoria = $myrow11tf["categoria"];
$lugcategoria = $myrow11tf["lug"];
$idcategoriainferior = $myrow11tf["idparent"];
}
if ($lugcategoria!=""){
$cadenamigas = "
$nombrecategoria";
}
////Miro si tiene una categoria inferior
if ($idcategoriainferior!='0'){
$sql11tf = "SELECT * FROM pagoporconversion_tienda_cat Where dominio ='$dominioacceso' and id='$idcategoriainferior' ";
$result11tf=$con->query($sql11tf);
while($myrow11tf=$result11tf->fetch_assoc())
{
$idparentproductos_uno = $myrow11tf["id"];
$idcategoriaacceso_uno = $myrow11tf["id"];
$nombrecategoria_uno = $myrow11tf["categoria"];
$lugcategoria_uno = $myrow11tf["lug"];
}
if ($lugcategoria_uno!=""){
$cadenamigas = "$nombrecategoria_uno".$cadenamigas;
}
}
/////////////////////FIN MIGAS DE PAN
//////////////////////////////////////Busco si es url final
$idelemento="0";
$sqlsub = "SELECT * FROM pagoporconversion_tienda_productos Where slug='$urlsinshop' and (slug!='' and dominio='$dominioacceso') ";
$resultcsub=$con->query($sqlsub);
while($myrow1sub=$resultcsub->fetch_assoc())
{
$idelemento=$myrow1sub["id"];
$nombreelemento=$myrow1sub["nombre"];
$urlelemento=$myrow1sub["slug"];
$categoriaelemento=$myrow1sub["idcat"];
}
if ( $idelemento!="0"){
$sql11tf = "SELECT * FROM pagoporconversion_tienda_cat Where id='$categoriaelemento' ";
$result11tf=$con->query($sql11tf);
while($myrow11tf=$result11tf->fetch_assoc())
{
$idparentproductos = $myrow11tf["id"];
$idcategoriaacceso = $myrow11tf["id"];
$nombrecategoria = $myrow11tf["categoria"];
$lugcategoria = $myrow11tf["lug"];
$idcategoriainferior = $myrow11tf["idparent"];
}
$cadenamigas = "$nombrecategoria
$nombreelemento";
}
if ($idelemento!="" and $idelemento!="0"){$plantilla="0";}
/////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////categorias
//////////////////////Segundo nivel
if ($urlsinshop!=""){
$sql11tf = "SELECT * FROM pagoporconversion_tienda_cat Where dominio ='$dominioacceso' and lug='$urlsinshop' and idparent='$idcategoriaacceso'";
$result11tf=$con->query($sql11tf);
while($myrow11tft=$result11tf->fetch_assoc())
{
$iddcat_dos = $myrow11tft["id"];
$nombrecategoria_dos = $myrow11tft["categoria"];
$nombrecategorialug_dos = $myrow11tft["lug"];
$descripcioncat_dos = $myrow11tft["descripcion"];
$idparent_dos = $myrow11tft["idparent"];
}
if ($iddcat_dos!=""){$plantilla="2";}
// if ($nombredirectorionivel2!=""){$nombredirectorio="$nombredirectorionivel2";}
}
?>
//CATEGORIAS
if ($plantilla=="1" or $plantilla=="2"){
$page="listado";
$idparent="0";
if ($plantilla=="2"){$idparent="$iddcat_dos";}
$objCategorias= new FactoryEN("pagoporconversion_tienda_cat", "categoria ASC", $idioma);
$objCategorias_nav=$objCategorias->get_all("idparent='{$idcategoriaacceso}' AND dominio ='{$dominioacceso}'", null, null);
if (!empty($objCategorias_nav))
{
?>
foreach($objCategorias_nav as $k => $v)
{
$urlamigable=$v->lug;
$tituloseccion=$v->categoria;
$descripcion_meta_pagina=$v->descripcion;
?>
}
?>
}
// fin CATEGORIAS
?>
$objProductos=new ArticuloEN($idioma);
$objProductos_nav=$objProductos->get_by_tabla_cruce3(TRUE, "a", "", null, "a.baja IS NULL AND a.idcat='$idparentproductos' AND a.dominio ='{$dominioacceso}'", "a.posicion DESC", null, null, false);
if(!empty($objProductos_nav))
{
foreach($objProductos_nav as $k => $v)
{
$idProducto=$v->id;
include("includes/item.php");
}
}
?>
//fin PRODUCTOS
}
//FICHA PRODUCTO
if ($plantilla=="0"){
$page="ficha";
$objA=new ArticuloEN($idioma);
$objA->getById($idelemento, "baja IS NULL AND dominio ='{$dominioacceso}'");
$idelemento=$objA->id;
$direccionelemento=$objA->direccion;
$telefonoelemento=$objA->telefono;
$webelemento=$objA->web;
$urlimagenelemento=$objA->imagen;
?>