Back to Examples
Example Implementation

E-commerce with Product Inquiries

A modern e-commerce experience with product inquiries, inventory tracking, and customer management - without complex backend infrastructure.

The Problem

E-commerce sites need product inquiry forms, inventory tracking, and customer data management, but full e-commerce platforms are overkill for many businesses.

StaticBox Solution

StaticBox enables lightweight e-commerce features like product inquiries, inventory management, and customer data collection with simple APIs.

Key Features Implemented

Product Inquiry Forms

Let customers inquire about products, request quotes, or ask questions.

<!-- Product inquiry form -->
<form action="https://staticbox.io/api/forms/[your-project-id]/[slug-name]/submit" method="POST">
  <input name="product_id" type="hidden" value="product-123" />
  <input name="customer_name" type="text" placeholder="Your Name" required />
  <input name="customer_email" type="email" placeholder="Email" required />
  <input name="company" type="text" placeholder="Company (optional)" />
  <select name="inquiry_type">
    <option value="quote">Request Quote</option>
    <option value="bulk">Bulk Order</option>
    <option value="custom">Customization</option>
    <option value="general">General Question</option>
  </select>
  <textarea name="message" placeholder="Your message..." required></textarea>
  <input name="quantity" type="number" placeholder="Quantity needed" />
  <button type="submit">Send Inquiry</button>
</form>

Inventory Tracking

Track stock levels, product availability, and inventory updates.

// Update inventory levels
await fetch('https://staticbox.io/api/projects/[your-project-id]/datastores/[collection-name]/data', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer your-api-key',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    product_id: 'product-123',
    sku: 'WIDGET-001',
    stock_level: 50,
    reorder_point: 10,
    last_updated: new Date().toISOString(),
    location: 'warehouse_a'
  })
});

// Check stock levels
const inventory = await fetch(
  'https://staticbox.io/api/projects/[your-project-id]/datastores/[collection-name]/data'
);

Customer Management

Build customer profiles, track purchase history, and manage relationships.

// ⚠️  SECURITY: Customer data operations must be server-side only!
// API keys should never be exposed in frontend code

// Server-side customer profile creation (Next.js API route)
export async function POST(request) {
  const customerData = await request.json();
  
  // Validate and sanitize data server-side
  const response = await fetch('https://staticbox.io/api/projects/[your-project-id]/datastores/[collection-name]/data', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer ' + process.env.STATICBOX_API_KEY, // Secure!
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      customer_id: generateSecureCustomerId(),
      name: sanitize(customerData.name),
      email: customerData.email,
      company: customerData.company,
      first_inquiry: new Date().toISOString(),
      inquiry_count: 1,
      customer_segment: calculateSegment(customerData),
      created_by_ip: request.headers.get('x-forwarded-for')
    })
  });
  
  return Response.json({ success: response.ok });
}
⚠️

Important Security Notice

API Keys must NEVER be used in frontend code. StaticBox API keys should only be used in:

  • Server-side code (API routes, server actions, backend functions)
  • Environment variables (process.env.STATICBOX_API_KEY)
  • Serverless functions (Vercel Functions, Netlify Functions)

Forms API can be used directly from frontend (no API key needed)

⚠️ DataStore API requires API keys and must be server-side only

Implementation Steps

1

Create Product Pages

Add inquiry forms to your product pages.

<!-- Product page with inquiry form -->
<div class="product-page">
  <h1>Product Name</h1>
  <div class="product-details">
    <!-- Product info -->
  </div>
  
  <form action="https://staticbox.io/api/forms/[your-project-id]/[slug-name]/submit" method="POST">
    <input name="product_id" type="hidden" value="{{product.id}}" />
    <input name="product_name" type="hidden" value="{{product.name}}" />
    <input name="customer_name" type="text" placeholder="Name" required />
    <input name="customer_email" type="email" placeholder="Email" required />
    <select name="inquiry_type">
      <option value="pricing">Pricing Information</option>
      <option value="availability">Check Availability</option>
      <option value="bulk">Bulk Order Quote</option>
    </select>
    <textarea name="message" placeholder="Your inquiry..."></textarea>
    <button type="submit">Contact Us</button>
  </form>
</div>
2

Setup Inventory System

Track your product inventory and stock levels securely.

// ⚠️  CRITICAL: Inventory operations must be server-side only!
// Never expose API keys or inventory logic in frontend code

// Server-side inventory management (Next.js API route)
// app/api/inventory/update/route.js
export async function POST(request) {
  const { productId, stockChange } = await request.json();
  
  // Server-side validation and business logic
  const response = await fetch('https://staticbox.io/api/projects/[your-project-id]/datastores/[collection-name]/data', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer ' + process.env.STATICBOX_API_KEY, // Secure!
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      product_id: productId,
      stock_change: stockChange,
      last_updated: new Date().toISOString(),
      updated_by: 'system' // Track who made changes
    })
  });
  
  return Response.json({ success: response.ok });
}

// Frontend: Safe inventory display (read-only, no API keys)
async function displayInventory() {
  // Public inventory view (no authentication needed for display)
  const response = await fetch('/api/inventory/public');
  const inventory = await response.json();
  updateInventoryDisplay(inventory);
}
3

Customer Data Collection

Build customer profiles from inquiries with secure server-side processing.

// ⚠️  SECURITY: Customer data must be processed server-side!

// Server-side inquiry processing (Next.js API route)
// app/api/process-inquiry/route.js
export async function POST(request) {
  const formData = await request.formData();
  
  // 1. Save inquiry (forms API - no auth needed)
  await fetch('https://staticbox.io/api/forms/[your-project-id]/[slug-name]/submit', {
    method: 'POST',
    body: formData
  });
  
  // 2. Update customer record (DataStore - requires auth)
  await fetch('https://staticbox.io/api/projects/[your-project-id]/datastores/[collection-name]/data', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer ' + process.env.STATICBOX_API_KEY, // Server-only!
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      email: formData.get('customer_email'),
      name: formData.get('customer_name'),
      company: formData.get('company'),
      last_inquiry: new Date().toISOString(),
      inquiry_count: 1,
      source: 'website_inquiry'
    })
  });
  
  return Response.json({ success: true });
}

// Frontend form submission (safe)
document.querySelector('#inquiry-form').addEventListener('submit', async (e) => {
  e.preventDefault();
  const formData = new FormData(e.target);
  
  await fetch('/api/process-inquiry', {
    method: 'POST',
    body: formData
  });
});
4

Deploy & Monitor

Go live and track your e-commerce performance.

Monitor inquiries, track conversion rates, and manage customer relationships through your StaticBox dashboard.

Benefits

No complex e-commerce platform needed
Lightweight and fast
Customer inquiry management
Inventory tracking
No transaction fees
Easy integration
Scalable solution

Tech Stack

StaticBox Forms
Product inquiries and quotes
StaticBox DataStore
Inventory and customer data
Static Site Generator
Product pages and catalog
Payment Gateway
Order processing (optional)

Ready to build your own e-commerce store?

Start with StaticBox today and have your backend ready in minutes.

Start Building Now