**Prerequisites:**

- A WordPress installation with WooCommerce
- SSH or SFTP access to your server
- A Git repository for your theme or plugin
- A DeployHQ account

## Deploying WooCommerce Projects

WooCommerce is the world's most popular e-commerce platform, powering over 5 million stores. Deployment typically involves custom themes, child themes, or custom plugins — not the entire WordPress installation.

**Important:** Never put all of WordPress in Git. Deploy only your custom code (theme or plugin), and manage WordPress core and WooCommerce updates separately via WP-CLI or the admin dashboard.

## What to Deploy

### Option A: Custom Theme / Child Theme

```
my-woo-theme/
├── assets/
│   ├── css/
│   ├── js/
│   └── images/
├── src/                    # Source files (SCSS, ES6)
│   ├── scss/
│   └── js/
├── template-parts/
│   ├── content-product.php
│   └── content-cart.php
├── woocommerce/            # WooCommerce template overrides
│   ├── single-product.php
│   ├── cart/
│   └── checkout/
├── functions.php
├── style.css
├── package.json
└── webpack.config.js
```

Deployment path: `/var/www/html/wp-content/themes/my-woo-theme/`

### Option B: Custom Plugin

```
my-woo-plugin/
├── includes/
├── assets/
├── templates/
├── my-woo-plugin.php
├── composer.json
└── package.json
```

Deployment path: `/var/www/html/wp-content/plugins/my-woo-plugin/`

## Build Pipeline

Most WooCommerce themes compile assets (SCSS → CSS, ES6 → bundled JS):

**Build command:**
```bash
cd %path% && npm ci && npm run build
```

If using Composer for PHP dependencies:
```bash
cd %path% && composer install --no-dev --optimize-autoloader && npm ci && npm run build
```

## Deploy with DeployHQ

1. Create a project and connect your Git repository
2. Add your server (SSH/SFTP)
3. Set **Deployment Path** to:
   - Theme: `/var/www/html/wp-content/themes/my-woo-theme/`
   - Plugin: `/var/www/html/wp-content/plugins/my-woo-plugin/`
4. Configure build commands
5. Add **Post-Deployment SSH Command** (optional):
   ```bash
   cd /var/www/html && wp cache flush && wp rewrite flush
   ```
6. Push and deploy

### Shared Paths

If your theme generates cache files or has an uploads directory, configure as shared paths to persist across deployments.

## WooCommerce Template Overrides

WooCommerce templates can be overridden by placing them in `yourtheme/woocommerce/`. When WooCommerce updates, check if your overridden templates need updating:

```bash
wp wc template-check
```

Include template version comments in your overrides so WooCommerce warns about outdated templates in the admin.

## Staging Workflow

| Branch | Server | Path |
|--------|--------|------|
| `main` | Production | `/var/www/production/wp-content/themes/my-theme/` |
| `staging` | Staging | `/var/www/staging/wp-content/themes/my-theme/` |

Use a staging copy of your WordPress installation with a separate database for testing.

## Troubleshooting

### File Permissions After Deployment

WordPress expects specific permissions. Add a post-deploy command:
```bash
cd /var/www/html/wp-content/themes/my-woo-theme && find . -type d -exec chmod 755 {} \; && find . -type f -exec chmod 644 {} \;
```

### Caching Plugin Conflicts

Object caching plugins (Redis, Memcached) may serve stale content after deployment. Flush caches post-deploy:
```bash
wp cache flush
```

Page caching plugins (WP Super Cache, W3 Total Cache) may also need purging:
```bash
wp w3-total-cache flush all
```

### Database Migrations

WooCommerce handles its own database migrations on update. If your plugin includes custom database tables, use WordPress's `dbDelta()` function on activation and run it via WP-CLI post-deploy if needed.

## Conclusion

Deploy your WooCommerce customisations with confidence — themes, plugins, and template overrides — while keeping WordPress core and WooCommerce updates managed separately.

[Sign up for DeployHQ](https://www.deployhq.com/signup) — free for one project.

Questions? Contact [support@deployhq.com](mailto:support@deployhq.com) or on [Twitter/X](https://x.com/deployhq).
