# Emporio Sport - cPanel Quick Start Guide

## 🚀 Quick Deployment (5 Steps)

### Step 1: Upload to cPanel
1. Open **cPanel File Manager**
2. Navigate to **public_html**
3. Upload entire **emporio-sport** folder
4. Verify all files are uploaded (check for /data, /css, /pics_ecom folders)

### Step 2: Verify Installation
1. Go to: `yourdomain.com/validate_deployment.php`
2. Check all items show **PASS** or **INFO**
3. If any show **FAIL**, see troubleshooting below

### Step 3: Test Homepage
1. Visit: `yourdomain.com`
2. Verify:
   - Logo displays ✓
   - Navigation shows ✓
   - "MORE" dropdown appears on hover ✓
   - Images load ✓

### Step 4: Test Shop
1. Visit: `yourdomain.com/shop.php`
2. Verify:
   - Products display with images ✓
   - Categories show in sidebar ✓
   - Filters work (click a category) ✓
   - Pagination appears at bottom ✓

### Step 5: Clean Up
1. Delete `validate_deployment.php` from server
2. Website is ready for production!

---

## 🔧 Troubleshooting (Most Common Issues)

### Issue: Images Not Showing

**Check these in order:**

1. **Verify folders exist on cPanel:**
   - Go to cPanel > File Manager
   - Navigate to emporio-sport folder
   - Check `/pics_ecom/` exists
   - Check `/sport-pics/` exists

2. **Check image file permissions:**
   ```
   Right-click folder > Change Permissions > Set to 755
   ```

3. **Verify image paths in JSON:**
   - Check `/data/products.json`
   - Images should have paths like: `"image": "tennis.jpg"` or `"image": "sport-pics/soccer/calcio.jpg"`
   - NOT full paths like `/emporio-sport/pics_ecom/tennis.jpg`

4. **Check browser console (F12 > Network):**
   - Look for failed image requests
   - Note what URL it's trying to load
   - Compare with actual file paths on server

### Issue: Pages Dropdown Empty

**The "MORE" button shows but dropdown is empty:**

1. **Verify `/data/pages.json` exists:**
   - File Manager > Navigate to `/data/`
   - Should see `pages.json`

2. **Verify JSON is valid:**
   - Visit: `yourdomain.com/data/pages.json`
   - Should show raw JSON starting with `[` and ending with `]`
   - If shows error, JSON is corrupted

3. **Check navigation helper:**
   - Visit: `yourdomain.com/validate_deployment.php`
   - Look for section "10. Navigation Helper"
   - Should show pages found

4. **For debugging:**
   - Edit `/header.php` around line 242
   - Add after `$featuredPages = NavigationHelper::getFeaturedPages();`
   - Add: `echo "<!-- DEBUG: Featured = " . count($featuredPages) . " -->"`
   - Reload page and view source (Ctrl+U)
   - Should show the count

### Issue: Shop Page Not Loading

**Blank shop page or products not showing:**

1. **Check `/data/products.json` exists and is valid:**
   - Visit: `yourdomain.com/data/products.json`
   - Should show JSON array
   - If error, JSON is corrupted - contact support

2. **Check file permissions:**
   ```
   /data/ folder: 755 permission
   /data/products.json: 644 permission
   ```

3. **Check error log:**
   - cPanel > Error Log
   - Look for PHP errors
   - Check line numbers match shop.php

4. **For debugging:**
   - Add to top of `/shop.php` after `<?php`:
   - Add: `error_log('Shop page loaded');`
   - Check cPanel Error Log
   - If you don't see the log message, PHP isn't executing

### Issue: Filters Not Working

**Shop loads but filters (category, rating, price) don't work:**

1. **Check products have required fields:**
   - Open `/data/products.json`
   - Each product needs:
     - `"cat": "Category Name"` (for category filter)
     - `"rating": 4.5` (for rating filter)
     - `"price": 29.99` (for price filter)

2. **Verify filter logic:**
   - Visit `yourdomain.com/validate_deployment.php`
   - Check "5. Products Data" section
   - Should show product count > 0

3. **Test filter manually:**
   - Click a category in sidebar
   - Products should filter
   - If not, check browser console for JavaScript errors (F12)

### Issue: Pagination Missing

**Shop page shows products but no Previous/Next buttons:**

1. **Check total products > 18:**
   - Visit: `yourdomain.com/data/products.json`
   - Count total product objects
   - If < 18, add more products

2. **Check show-per-page dropdown works:**
   - Select "36" from "Show" dropdown
   - Page should reload with 36 products
   - Previous/Next buttons should appear

3. **Verify CSS is loading:**
   - Right-click shop page > Inspect (F12)
   - Search for `class="pagination"`
   - Should exist in HTML
   - Check if it has `display: none` or hidden

### Issue: Footer Missing

**Page ends abruptly, no footer visible:**

1. **Check `/footer.php` exists:**
   - Should be in root directory

2. **Check footer is included in pages:**
   - End of `/shop.php` should have: `<?php include __DIR__ . '/footer.php'; ?>`
   - Check `/index.php` same thing

3. **Verify footer CSS:**
   - Press F12 > Search for `.site-footer`
   - Should NOT have `display: none;`

4. **Check body height:**
   - F12 > Inspect `<body>` element
   - Should NOT have fixed height
   - Should allow scrolling

---

## 🔍 Advanced Debugging

### Enable Debug Mode (Temporary)

Edit `/config/db_config.php`:
```php
// Add these lines:
ini_set('display_errors', 1);
ini_set('error_reporting', E_ALL);
```

**IMPORTANT:** Remove these lines before going live!

### Check Error Logs

1. **cPanel Error Log:**
   - cPanel > Metrics > Error Log
   - Look for recent PHP errors
   - Note file paths and line numbers

2. **Browser Console:**
   - Press F12
   - Go to Console tab
   - Look for JavaScript errors
   - Go to Network tab to see failed requests

3. **Test JSON Loading:**
   - Visit `yourdomain.com/data/products.json`
   - Should show raw JSON (not download)
   - If shows 404, file not uploaded

### Database Optional

**The system works WITHOUT a database!**

- If database unavailable, system automatically uses JSON files
- No action needed
- Check `/helpers/navigation_helper.php` for fallback logic

---

## 📋 File Checklist (What You Uploaded)

✓ Core Files:
- [ ] index.php
- [ ] shop.php
- [ ] header.php
- [ ] footer.php
- [ ] .htaccess

✓ Data Folders:
- [ ] /data/products.json
- [ ] /data/categories.json
- [ ] /data/pages.json
- [ ] /data/brands.json (if used)
- [ ] /data/site_config.json (if used)

✓ Image Folders:
- [ ] /pics_ecom/ (with images)
- [ ] /sport-pics/ (with images and subfolders)

✓ Style & Script Folders:
- [ ] /css/ (all CSS files)
- [ ] /js/ (all JavaScript files)

✓ Helper Folders:
- [ ] /helpers/ (all PHP helpers)
- [ ] /config/ (configuration files)

✓ Validation:
- [ ] validate_deployment.php (for testing, delete after)

---

## 🚨 Critical Points to Remember

1. **Web Base Path is Auto-Detected:**
   - Localhost: `/emporio-sport`
   - cPanel: `/`
   - No manual configuration needed!

2. **Image Paths Must Match:**
   - If products.json says: `"image": "tennis.jpg"`
   - File must exist at: `/pics_ecom/tennis.jpg`

3. **JSON Files Are Required:**
   - products.json
   - categories.json
   - pages.json
   - These MUST be present and valid JSON

4. **Permissions Matter:**
   - Folders: 755
   - Files: 644
   - Set via: Right-click > Change Permissions

5. **Database is Optional:**
   - Can be used OR skipped entirely
   - System has JSON fallback
   - No setup required if using JSON only

---

## ✅ Verification Commands

Test your deployment without browser:

### Check if file exists:
```
yourdomain.com/data/products.json
```
Should show JSON, not 404 error

### Check if PHP works:
```
yourdomain.com/validate_deployment.php
```
Should show validation page with results

### Check basic page loads:
```
yourdomain.com/index.php
```
Should show homepage

---

## 📞 Support Checklist

Before contacting support, verify:
- [ ] All files uploaded to cPanel public_html
- [ ] File permissions set correctly (755/644)
- [ ] JSON files are valid (visit them in browser)
- [ ] Run `validate_deployment.php` and note errors
- [ ] Check cPanel Error Log for PHP errors
- [ ] Check browser console (F12) for JavaScript errors
- [ ] Clear browser cache (Ctrl+Shift+Delete)

---

## 🎯 Expected Behavior After Deployment

| Feature | Expected |
|---------|----------|
| Homepage | Loads instantly, shows logo, featured products |
| Navigation | "MORE" dropdown appears on hover, shows all pages |
| Shop | All products display with images, filters work, pagination shows when > 18 products |
| Images | All product and category images display correctly |
| Footer | Shows at bottom of all pages |
| Mobile | Responsive on phones and tablets |

---

**Last Updated:** January 29, 2026  
**Version:** 1.0 Complete Deployment Guide  
**Status:** Ready for Production ✅
