Skip to main content

Overview

Your seller profile (perfil.html) is your command center on Mis Compras. It provides a comprehensive view of your account, products, and performance metrics all in one unified dashboard.

Profile Structure

The profile page is organized into four main sections:

Profile Header

User information and session management

Personal Information

Account details with edit capabilities

Product Management

Grid view of all your published products

Statistics Dashboard

Real-time performance metrics

Profile Header

Located at the top of the page, the header provides quick access to essential functions.

Components

avatar
component
User Avatar
  • 70x70px circular avatar with gradient background
  • Blue gradient: linear-gradient(135deg, #3b82f6, #1d4ed8)
  • Displays user icon (Font Awesome: fa-user)
  • Clean, minimalist design
profile-text
component
Profile Title
  • Heading: “Mi Perfil” (2rem, bold)
  • Subtitle: “Administra tu cuenta y productos”
  • Clear hierarchy with distinct text sizes
logout-button
button
Logout Button
  • Transparent background with blue text
  • Sign-out icon + “Cerrar sesión” label
  • Hover effect: Changes to red color
  • Confirms before logging out

Authentication Flow

function cerrarSesion() {
    if (confirm("¿Cerrar sesión?")) {
        localStorage.removeItem("id_usuario");
        window.location.href = "index.html";
    }
}
Logging out removes your session ID from localStorage and redirects you to the homepage. You’ll need to log in again to access seller features.

Personal Information Section

This section displays your account details in a clean, card-based grid layout.

Data Fields

Label: “Nombre completo”Source: data.usuario.nombreDisplays your registered name on the platform

Loading User Data

The profile fetches user information from the backend on page load:
document.addEventListener("DOMContentLoaded", async () => {
    const id = localStorage.getItem("id_usuario");

    if (!id) {
        alert("Debes iniciar sesión para ver tu perfil.");
        window.location.href = "index.html";
        return;
    }

    try {
        const resp = await fetch("php/obtener_usuario.php?id=" + id);
        const data = await resp.json();

        // Render user data in grid
        const datosHTML = `
            <div class="dato-item">
                <span class="dato-label">Nombre completo</span>
                <div class="dato-valor">${data.usuario.nombre}</div>
            </div>
            // ... more fields
        `;

        document.getElementById("datos-usuario").innerHTML = datosHTML;
    } catch (error) {
        // Display error message
    }
});

Edit Profile (Future Feature)

The interface includes an “Editar” button for profile editing:
<button id="btn-editar-perfil" class="btn-editar-perfil">
    <i class="fas fa-pencil-alt"></i> Editar
</button>
Profile editing functionality is partially implemented in the UI. The backend implementation may be added in future updates.

Card Design

Each data item is displayed in a hover-animated card:
.dato-item {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    transition: transform 0.2s ease;
}

.dato-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

Product Management Section

This is the core of your seller dashboard where all your products are displayed and managed.

Section Header

section-title
heading
“Mis productos”Displays a box icon (fa-box) alongside the title
product-counter
badge
Product CounterShows total count: “X producto(s)”Updates dynamically based on API response

Product Grid

Products are displayed in a responsive auto-fill grid:
.productos-lista {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}
Each product card includes:
  • Product image (180px height, object-fit: cover)
  • Product name (bold, 1.1rem)
  • Price (blue, large font: $XX.XX)
  • Description (truncated to 100 characters)
  • Metadata: Views and publication date
  • Action buttons: View, Edit, Delete

Loading Products

async function cargarMisProductos() {
    const id = localStorage.getItem("id_usuario");
    
    try {
        const resp = await fetch("php/mis_productos.php?id=" + id);
        const data = await resp.json();

        if (!data.exito || data.productos.length === 0) {
            // Show "no products" message
            return;
        }

        // Update counter
        document.getElementById("contador-productos").textContent = 
            `${data.productos.length} producto${data.productos.length !== 1 ? 's' : ''}`;
        
        // Update statistics
        document.getElementById("vistas-totales").textContent = 
            data.productos.reduce((sum, p) => sum + (p.vistas || 0), 0);
        
        // Render product cards
        // ...
    } catch (error) {
        // Handle errors
    }
}

Empty State

When no products are published, an encouraging message is shown:
📦

No tienes productos publicados

Comienza a vender publicando tu primer producto

Publish Button

A prominent call-to-action button appears at the bottom:
<button onclick="window.location.href='publicar_producto.html'" class="boton-publicar">
    <i class="fas fa-plus"></i> Publicar nuevo producto
</button>
Styling:
  • Full width with centered content
  • Blue background (#3b82f6)
  • White text with plus icon
  • 16px padding for prominence
  • Hover animation: Lifts 2px up

Statistics Dashboard

The statistics section provides real-time insights into your seller performance with three key metrics.

Total Views

Metric: Number of times your products have been viewedCalculation: Sum of all product viewsIcon Color: Blue (#3b82f6)

Sales Made

Metric: Total number of completed salesCalculation: Sum of all product salesIcon Color: Blue (#3b82f6)

Seller Rating

Metric: Your average seller rating (out of 5)Display: X/5 formatIcon Color: Blue (#3b82f6)

Statistics Calculation

// Total Views
document.getElementById("vistas-totales").textContent = 
    data.productos.reduce((sum, p) => sum + (p.vistas || 0), 0);

// Total Sales
document.getElementById("ventas-realizadas").textContent = 
    data.productos.reduce((sum, p) => sum + (p.ventas || 0), 0);

// Seller Rating (placeholder in current implementation)
document.getElementById("calificacion").textContent = "0";

Card Design

Each statistic is displayed in a minimalist card with:
.estadistica-minimal {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    text-align: center;
}
Structure:
  1. Icon (1.5rem, blue)
  2. Value (1.8rem, bold, dark gray)
  3. Label (0.85rem, muted gray)
Statistics are calculated dynamically from your product data. They update automatically whenever you load your profile or make changes to your products.

Visual Design System

The profile uses a cohesive design language throughout:

Color Palette

Blue Accent: #3b82f6Used for prices, buttons, and primary actions

Typography

font-family: 'Inter', sans-serif;
Hierarchy:
  • H1: 2rem, weight 700 (Profile title)
  • H2: 1.3rem, weight 600 (Section titles)
  • H3: 1.1rem, weight 600 (Product names)
  • Body: 1rem, weight 400 (Default text)
  • Small: 0.85rem (Labels, metadata)

Spacing & Layout

The profile uses a consistent spacing system:
.perfil-contenedor {
    backdrop-filter: blur(5px);
    background: rgba(255, 255, 255, 0.277);
    border-radius: 20px;
    padding: 40px;
    margin: 40px auto;
    max-width: 1000px;
}
  • Container width: Max 1000px, centered
  • Padding: 40px all around
  • Section spacing: 40-50px between sections
  • Card gaps: 15-20px between elements

Background

body {
    background: 
        linear-gradient(rgba(255, 255, 255, 0.25), rgba(255, 255, 255, 0.25)),
        url('imagenes/fondo3.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}
The profile features a beautiful layered background:
  • Background image (fondo3.jpg)
  • White overlay (25% opacity)
  • Fixed attachment for parallax effect
  • Backdrop blur on main container

Responsive Design

The profile adapts seamlessly to different screen sizes:

Mobile Breakpoint (≤768px)

@media (max-width: 768px) {
    .perfil-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 20px;
    }

    .productos-lista {
        grid-template-columns: 1fr;
    }

    .datos-grid {
        grid-template-columns: 1fr;
    }

    .estadisticas {
        grid-template-columns: 1fr;
    }

    .producto-acciones {
        flex-direction: column;
        gap: 10px;
    }
}
Changes on Mobile:
  • Header stacks vertically
  • Product grid becomes single column
  • Data grid becomes single column
  • Statistics stack vertically
  • Product action buttons stack

Error Handling

The profile includes comprehensive error handling:

Authentication Check

if (!id) {
    alert("Debes iniciar sesión para ver tu perfil.");
    window.location.href = "index.html";
    return;
}

Data Loading Errors

catch (error) {
    document.getElementById("datos-usuario").innerHTML = `
        <div class="dato-item" style="grid-column: 1 / -1; text-align: center; color: #ef4444;">
            <i class="fas fa-exclamation-circle"></i>
            <div class="dato-valor">Error al cargar los datos</div>
        </div>
    `;
}

Product Loading Errors

catch (error) {
    cont.innerHTML = `
        <div class="sin-productos" style="grid-column: 1 / -1; color: #ef4444;">
            <i class="fas fa-exclamation-triangle"></i>
            <p>Error al cargar los productos</p>
        </div>
    `;
}

Best Practices

Why: Stay informed about your seller performanceActions:
  • Monitor your view counts to see which products attract attention
  • Track sales statistics to measure success
  • Review your product catalog for updates needed
Why: Accurate information builds buyer trustActions:
  • Update product descriptions when details change
  • Remove or mark sold items
  • Refresh product images for better appeal
Why: Data-driven decisions improve resultsActions:
  • Identify high-performing products and replicate their success
  • Update low-view products with better descriptions
  • Adjust pricing based on market response
Why: Professional profiles attract more buyersActions:
  • Use high-quality product images
  • Write detailed, accurate descriptions
  • Respond promptly to any inquiries
  • Keep your product catalog well-organized

Public Seller Profile

In addition to your private dashboard, Mis Compras also provides a public-facing seller profile page (vendedor.html).

Public Profile Features

When buyers click on your name from a product listing, they see:
1

Seller Information

  • Large avatar (90x90px) with first letter of your name
  • Full name as heading
  • Member since date
  • Average rating and number of reviews
2

Product Listings

All your published products displayed in a grid format, allowing buyers to browse your entire catalog

Public Profile Data

fetch('php/obtener_vendedor.php?id=' + encodeURIComponent(id))
    .then(r => r.json())
    .then(data => {
        const v = data.vendedor;
        // Display: name, fecha_registro, rating, valoraciones
    });
Your public profile shows only information relevant to buyers. Personal details like email and edit functions are not visible to other users.

Troubleshooting

Issue: Redirected to homepage or see login promptSolution:
  • Ensure you’re logged in
  • Check that localStorage.id_usuario exists
  • Try logging out and back in
  • Clear browser cache and cookies
Issue: See “loading” spinner indefinitelySolution:
  • Check browser console for errors
  • Verify API endpoint is accessible
  • Ensure proper authentication
  • Check database connection
Issue: All stats display 0 despite having productsSolution:
  • Verify products have view/sale data in database
  • Check product data structure matches expected format
  • Ensure calculation logic is running correctly
Issue: Product images show placeholder/broken imageSolution:
  • Verify image paths in database
  • Check that image files exist in imagenes/ directory
  • Ensure proper file permissions
  • Fallback to default-product.svg is implemented

Next Steps

Publish Your First Product

Ready to start selling? Learn how to create product listings

Manage Your Listings

Optimize and maintain your product catalog

Build docs developers (and LLMs) love