Skip to main content

Overview

After completing a purchase on Mis Compras, your order is recorded in the platform’s database. This guide covers how orders are stored, the order lifecycle, and available tracking mechanisms.

Order Storage System

Database Structure

Orders are stored across two main database tables:
Main order table containing order-level information:
CREATE TABLE pedidos (
  id_pedido INT PRIMARY KEY AUTO_INCREMENT,
  id_usuario INT,
  total DECIMAL(10,2),
  fecha TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  estado VARCHAR(50)
);
Fields:
  • id_pedido - Unique order identifier
  • id_usuario - Customer user ID (null for guest orders)
  • total - Total order amount
  • fecha - Order creation timestamp
  • estado - Order status (pending, completed, etc.)

Order Creation

When you complete checkout, the system creates records in both tables:
1

Create Order Record

Insert into pedidos table with user ID and total amount
INSERT INTO pedidos (id_usuario, total) 
VALUES (123, 1998.00)
2

Get Order ID

Retrieve the auto-generated id_pedido
$id_pedido = $stmt->insert_id;
3

Create Order Details

Insert each cart item into detalle_pedido
INSERT INTO detalle_pedido (id_pedido, id_producto, cantidad, precio) 
VALUES (1001, 1, 2, 999.00)

Order Information

What’s Included in an Order

Each order record contains:

Order Header

  • Order ID - Unique tracking number
  • Customer ID - Your user account ID
  • Order Total - Final purchase amount
  • Order Date - Timestamp of purchase
  • Order Status - Current fulfillment status

Order Line Items

For each product in the order:
  • Product ID - Reference to product catalog
  • Product Name - Stored at time of purchase
  • Quantity - Number of units ordered
  • Unit Price - Price per item
  • Line Total - Quantity × Unit Price

Example Order Data

{
  "order": {
    "id_pedido": 1001,
    "id_usuario": 123,
    "total": 1998.00,
    "fecha": "2026-03-11 14:30:00",
    "estado": "pending"
  },
  "items": [
    {
      "id_detalle": 5001,
      "id_producto": 1,
      "nombre": "iPhone 15 Pro",
      "cantidad": 2,
      "precio": 999.00,
      "subtotal": 1998.00
    }
  ]
}

Order Confirmation

Immediate Confirmation

After successful checkout, you receive immediate confirmation:
1

Success Modal

A modal appears with celebration emoji and success message:
🎉 ¡Compra realizada con éxito!
Tu pedido ha sido registrado correctamente.
2

Thank You Page

Redirect to gracias.html after 3 seconds:
<h1>🎉 ¡Gracias por tu compra!</h1>
<p>Tu pedido ha sido procesado correctamente.</p>
Currently, the platform does not send email confirmations. The on-screen confirmation is your primary receipt.

Viewing Your Orders

Current Implementation

As of the current version, Mis Compras does not have a customer-facing order history page. Users cannot view their past orders through the UI.

Accessing Order Information

Currently, orders can only be viewed by:
  1. Database Access - Direct queries to the pedidos and detalle_pedido tables
  2. Admin Panel - If available (not documented in current codebase)
  3. Customer Support - Contacting platform administrators

Future Order History Feature

A typical order history page would include:

Recommended Features

  • List of all orders by logged-in user
  • Order date and total amount
  • Order status (pending, processing, shipped, delivered)
  • View order details (items, quantities, prices)
  • Download receipts or invoices
  • Reorder functionality
  • Cancel pending orders

Order Tracking API

Querying Orders

To retrieve orders for a user, you would query:
// Example query for user's orders
$sql = "SELECT * FROM pedidos 
        WHERE id_usuario = ? 
        ORDER BY fecha DESC";
$stmt = $conn->prepare($sql);
$stmt->bind_param("i", $usuario_id);
$stmt->execute();
$result = $stmt->get_result();

Getting Order Details

To fetch line items for a specific order:
// Example query for order details
$sql = "SELECT dp.*, p.nombre, p.imagen 
        FROM detalle_pedido dp
        LEFT JOIN productos p ON dp.id_producto = p.id_producto
        WHERE dp.id_pedido = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("i", $id_pedido);
$stmt->execute();
$result = $stmt->get_result();

Order Status Lifecycle

Status Field

The estado column in the pedidos table tracks order progress:
1

Pending

Initial status when order is created
  • Order received but not processed
  • Awaiting seller confirmation
2

Processing

Order is being prepared
  • Seller has confirmed order
  • Items being packed
3

Shipped

Order has been dispatched
  • Package with delivery service
  • Tracking number may be available
4

Delivered

Order received by customer
  • Delivery confirmed
  • Order complete
5

Cancelled

Order was cancelled
  • By customer request or seller
  • May include refund processing
Status management is not currently implemented in the UI. Status updates would need to be performed manually in the database or through an admin interface.

Order Management for Sellers

Viewing Orders

Sellers can view orders for their products by querying:
// Orders containing seller's products
$sql = "SELECT DISTINCT p.*, u.nombre as cliente
        FROM pedidos p
        JOIN detalle_pedido dp ON p.id_pedido = dp.id_pedido
        JOIN productos pr ON dp.id_producto = pr.id_producto
        JOIN usuarios u ON p.id_usuario = u.id_usuario
        WHERE pr.id_vendedor = ?
        ORDER BY p.fecha DESC";

Fulfillment Workflow

1

Receive Notification

Seller notified of new order (manual check currently)
2

Confirm Order

Verify product availability and update status to “processing”
3

Prepare Shipment

Pack items and arrange delivery
4

Update Status

Mark as “shipped” with tracking info
5

Confirm Delivery

Update to “delivered” once customer receives

Price Preservation

Historical Pricing

The order system preserves prices at time of purchase:
// Price stored in detalle_pedido
INSERT INTO detalle_pedido (id_pedido, id_producto, cantidad, precio) 
VALUES (?, ?, ?, ?)
Even if product prices change later, your order records show the price you paid at checkout. This ensures accurate order history and accounting.

Guest Order Tracking

Orders Without Account

If you checked out as a guest (usuario_id = null):
  • Order is still created in database
  • No way to retrieve order through standard login
  • Would need order ID to track
  • Consider creating account for future purchases
Guest orders are difficult to track without an order confirmation email or order ID. We strongly recommend creating an account before checkout.

Building Order History (Implementation Guide)

Creating Order History Page

To implement an order history feature, you would need:
<!-- mis-pedidos.html -->
<div class="orden-history">
  <h1>Mis Pedidos</h1>
  <div id="lista-pedidos">
    <!-- Orders loaded here -->
  </div>
</div>

Order Search and Filtering

Search by Order ID

Allow users to search for specific order by ID number

Filter by Date Range

Show orders within specific date range

Filter by Status

View only pending, completed, or cancelled orders

Search by Product

Find orders containing specific products

Order Notifications

To keep buyers informed, implement:
1

Order Confirmation Email

Send email immediately after successful checkout
  • Order number
  • Items purchased
  • Total amount
  • Seller contact info
2

Status Update Notifications

Alert when order status changes
  • Order confirmed by seller
  • Order shipped with tracking
  • Order delivered
3

In-App Notifications

Show notifications in user dashboard
  • Badge count for new updates
  • Notification center

Contact and Support

Getting Order Help

If you need assistance with an order:

Contact Seller Directly

Click seller’s name to view their profile and contact information

Platform Support

Contact Mis Compras customer service (if available)

Order Information Needed

  • Order date and approximate time
  • Products purchased
  • Total amount paid
  • Your account email

Data Privacy

Order Data Storage

Your order information is stored securely:
  • Orders linked to your user account
  • Payment information not stored (not currently processed)
  • Product details preserved for history
  • Personal information handled per privacy policy
Review the platform’s privacy policy for details on how order data is used, stored, and shared with sellers.

Troubleshooting

  • Ensure you’re logged into the correct account
  • Check if you completed checkout or just added to cart
  • Verify payment was processed (when feature available)
  • Contact support with order date and products
  • Order total reflects prices at time of purchase
  • Check for multiple quantities of same product
  • Verify all items in order details
  • Contact support if discrepancy persists
  • Status updates may be manual and delayed
  • Contact seller directly for status
  • Check email for seller communications
  • Allow 24-48 hours for status changes
  • Guest orders have no tracking capability
  • Create account and contact support to link order
  • Save order confirmation for reference
  • Register account for future purchases

Best Practices

1

Create Account Before Purchase

Always register an account for proper order tracking
2

Save Order Confirmation

Screenshot or note order details immediately after purchase
3

Monitor Email

Watch for seller communications about your order (when available)
4

Contact Sellers Proactively

Don’t wait for updates - reach out to sellers after ordering
5

Keep Records

Save receipts, screenshots, and correspondence for your records

Future Enhancements

Planned Order Tracking Features

Order History Page

Dedicated page showing all past orders

Email Notifications

Automated order confirmation and status emails

Real-time Status Updates

Live order status tracking

Shipping Integration

Direct integration with delivery services

Technical References

Checkout Process

How orders are created

Shopping Cart

Managing items before purchase

Code References

  • Order creation: php/checkout.php:29-52
  • Database schema: Order tables structure
  • Thank you page: gracias.html
  • Seller orders: Would need new php/obtener_pedidos.php

Build docs developers (and LLMs) love