# Furnify Premium Online Store

PHP storefront for a sofa company with a premium catalog UI, product search/filter/sort, local cart, inquiry checkout, AR preview, PWA install support, and server-side order validation.

## What's upgraded

- Premium modern UI with luxury hero, category cards, trust sections, and responsive product cards
- Product search, category filter, and price/rating sort on the homepage
- Product detail page with quantity selector, swatches, warranty/status details, true-size AR viewer, room fit checker, and related products
- Cart page with quantity controls, clear cart button, subtotal, and safer checkout note
- Checkout page with CSRF token, customer details, address, payment preference, delivery preference, and validation
- `submit-order.php` now recalculates item names/prices/totals from `data/products.php` instead of trusting browser/localStorage prices
- Inquiries are saved as JSON files inside `storage/orders/`
- Generated WebP images for faster loading while keeping the original PNG files
- Updated service worker cache version and PWA manifest
- Added basic security headers in `.htaccess`

## Run locally

Install PHP through XAMPP, Laragon, or PHP 8.1+. Then run:

```bash
php -S localhost:8000
```

Open:

```text
http://localhost:8000/index.php
```

## Order storage

Submitted inquiries are stored here:

```text
storage/orders/FU-YYYYMMDD-XXXXXX.json
```

Make sure the server has write permission to the `storage/orders` folder. The app will attempt to create the folder automatically.

## Production recommendations

For a real production online store, the next steps are:

1. Replace JSON order files with MySQL tables for orders, order items, customers, and products.
2. Add an admin dashboard for order monitoring and status updates.
3. Connect notifications through email, SMS, or Messenger.
4. Add payment gateway integration if you want real checkout instead of inquiry checkout.
5. Self-host Bootstrap, Bootstrap Icons, and `model-viewer` for stronger offline/PWA behavior.
6. Add real `.usdz` models for iOS AR Quick Look.

## AR notes

The product pages use Google's `model-viewer` web component and local `.glb` sofa models in `assets/models`.

This version adds true-size AR behavior:

- Each product has `dimensions_cm` in `data/products.php`.
- The `.glb` models in `assets/models` were resized to match their listed sofa footprint in meters.
- `product.php` uses `ar-scale="fixed"` and `ar-placement="floor"` so buyers cannot pinch-scale the sofa in AR.
- Product pages now include a room fit checker where buyers can enter available width/depth in centimeters.

For mobile AR testing, use HTTPS on a real phone. Android can use GLB with Scene Viewer/WebXR. iOS Quick Look usually needs a matching `.usdz` file per sofa, which can be added later through the `ios-src` attribute.

Important: true-size AR depends on accurate 3D model scale. When replacing GLB files, export them in meters and confirm that X = sofa width, Y = height, and Z = depth.


## New product, AR height, and live chat

See `README_ADD_SOFA_AR_LIVE_CHAT.md` for:

- Adding a new sofa to `data/products.php`
- Correct way to raise/lower a sofa in AR by fixing the GLB model height/origin
- Enabling the configurable live chat widget in `data/settings.php`

This version includes `tools/adjust_glb_height.py`, a helper script that can move supported GLB models up or down by centimeters.

## MySQL + Admin Dashboard

This package includes a MySQL-ready admin dashboard.

Read this guide first:

```text
README_MYSQL_ADMIN.md
```

Admin URL after setup:

```text
/admin/login.php
```

Default admin after importing `database/schema.sql`:

```text
Username: admin
Password: Admin@12345
```

Change the password after first login.


## Custom Sofa Quote

This version includes a personalized custom sofa quote form at `custom-sofa.php` and admin monitoring at `admin/custom-quotes.php`. If you already imported an older database, import `database/migration_custom_sofa_quotes.sql`.

## Customer account upgrade

This package includes customer registration/login, email verification, customer dashboard, order tracking, Re-Up tracking, custom sofa quote tracking, profile update, and forgot/reset password pages.

For existing MySQL installs, import:

```text
database/migration_customer_accounts.sql
```

For fresh installs, import the updated:

```text
database/schema.sql
```

Admin customer management is available at:

```text
/admin/customers.php
```

Full notes are in:

```text
README_CUSTOMER_ACCOUNTS.md
```
