# Revoty - Sales Booster for WooCommerce

A WordPress plugin that enhances WooCommerce stores with photo reviews and other sales-boosting features.

## Overview

Revoty is a WooCommerce plugin that helps increase sales through customer engagement features, primarily focusing on photo reviews. The plugin is built with modern technologies including React, PHP, and follows WordPress coding standards.

## Requirements

- **PHP**: >= 7.4
- **WordPress**: >= 6.0
- **WooCommerce**: >= 7.0 (tested up to 9.0)
- **Node.js**: >= 14.x (for development)
- **Composer**: >= 2.x

## Tech Stack

### Backend
- PHP 7.4+
- WordPress Plugin API
- WooCommerce
- PSR-4 Autoloading
- PHP CodeSniffer (WordPress Coding Standards)
- PHPStan for static analysis

### Frontend
- React 19.2.x
- React Router DOM
- Mantine UI Components
- Emotion (CSS-in-JS)
- Tabler Icons
- Webpack 5
- Babel
- SCSS/Sass

## Development Setup

### 1. Clone the Repository

```bash
# Navigate to your WordPress plugins directory
cd /path/to/wordpress/wp-content/plugins/

# If this is already cloned, navigate to the plugin directory
cd revoty
```

### 2. Install PHP Dependencies

```bash
composer install
```

For production builds, use:
```bash
composer install --no-dev --optimize-autoloader
```

### 3. Install Node Dependencies

```bash
npm install
```

If you encounter issues with legacy dependencies, use:
```bash
npm install --force
```

### 4. Build Assets

#### Development Mode (with watch)
```bash
npm run dev
```

This will watch for changes in your JavaScript and SCSS files and rebuild automatically.

#### Production Build
```bash
npm run build
```

For environments requiring OpenSSL legacy provider:
```bash
export NODE_OPTIONS=--openssl-legacy-provider
npm run build
```

## Project Structure

```
revoty/
├── .github/
│   └── workflows/          # GitHub Actions workflows
├── assets/                 # Compiled assets (generated)
│   ├── css/               # Compiled CSS files
│   └── js/                # Compiled JavaScript files
├── languages/             # Translation files
├── resources/             # Source files
│   ├── js/               # JavaScript/React source files
│   │   ├── admin.js
│   │   ├── admin-app.jsx
│   │   └── modules/
│   └── sass/             # SCSS source files
│       ├── admin.scss
│       └── modules/
├── src/                   # PHP source files
│   ├── Abstracts/        # Abstract classes
│   ├── Admin/            # Admin functionality
│   ├── Core/             # Core plugin functionality
│   └── Modules/          # Feature modules
├── vendor/               # Composer dependencies
├── composer.json         # PHP dependencies
├── package.json          # Node dependencies
├── webpack.config.js     # Webpack configuration
├── phpcs.xml            # PHP CodeSniffer configuration
└── revoty.php           # Main plugin file
```

## Available NPM Scripts

```bash
# Development mode with file watching
npm run dev

# Production build
npm run build

# Lint JavaScript files
npm run lint:js

# Lint SCSS files
npm run lint:css

# Lint PHP files (uses WordPress standards)
npm run lint:php

# Auto-fix PHP formatting issues
npm run format:php
```

## Available Composer Scripts

```bash
# Lint PHP files
composer run lint

# Auto-fix PHP formatting
composer run format

# Run static analysis with PHPStan
composer run analyze
```

## Development Workflow

### 1. Start Development Server

```bash
# In terminal 1: Watch and compile assets
npm run dev
```

### 2. Make Changes

- **PHP**: Edit files in [src/](src/) directory
- **JavaScript/React**: Edit files in [resources/js/](resources/js/) directory
- **Styles**: Edit files in [resources/sass/](resources/sass/) directory

### 3. Code Quality

Before committing, ensure your code meets quality standards:

```bash
# Check PHP code style
composer run lint

# Fix PHP code style automatically
composer run format

# Run static analysis
composer run analyze

# Check JavaScript
npm run lint:js

# Check SCSS
npm run lint:css
```

## WordPress Integration

### Autoloading

The plugin uses PSR-4 autoloading:

```php
"Revoty\\": "src/",
"Revoty\\Modules\\": "src/Modules/"
```

### Plugin Initialization

The plugin is initialized in [revoty.php:38](revoty.php#L38):

```php
\Revoty\Core\Plugin::instance()->init();
```

## Building for Production

The plugin includes a GitHub Actions workflow for automated releases. When you push a tag, it will:

1. Install npm dependencies
2. Build production assets
3. Install Composer dependencies (without dev packages)
4. Create a ZIP file excluding development files
5. Create a GitHub release

### Manual Production Build

```bash
# Install and build
npm install --force
npm run build

# Install production dependencies only
composer install --no-dev --optimize-autoloader

# Create a distribution package (excluding dev files)
zip -r revoty.zip . -x \
  ".git/*" \
  "composer.lock" \
  ".github/*" \
  "node_modules/*" \
  ".editorconfig" \
  ".gitignore" \
  "package-lock.json" \
  ".distignore" \
  "bin/*" \
  "tests/*" \
  "phpunit.xml.dist" \
  ".cursorrules" \
  "docs/*" \
  ".eslintrc.js" \
  ".prettierrc" \
  "phpcs.xml" \
  ".claude/*" \
  "languages/.gitkeep"
```

## Key Features

### Photo Reviews Module

The plugin includes a photo reviews module for WooCommerce products, allowing customers to upload photos with their reviews.

**Frontend**: [resources/js/modules/photo-reviews.js](resources/js/modules/photo-reviews.js)
**Settings UI**: [resources/js/modules/photo-reviews-settings.jsx](resources/js/modules/photo-reviews-settings.jsx)
**Styles**: [resources/sass/modules/photo-reviews.scss](resources/sass/modules/photo-reviews.scss)

## Troubleshooting

### OpenSSL Issues

If you encounter OpenSSL errors during build:

```bash
export NODE_OPTIONS=--openssl-legacy-provider
npm run build
```

### Node Module Issues

If dependencies are not installing correctly:

```bash
# Remove existing modules and lockfile
rm -rf node_modules package-lock.json

# Reinstall
npm install --force
```

### Composer Autoload Issues

If classes are not being found:

```bash
composer dump-autoload
```

## Contributing

1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Run code quality checks
5. Submit a pull request

## License

GPL-2.0-or-later

## Author

**Çağdaş Dağ**
Website: [https://cagdasdag.com](https://cagdasdag.com)

## Plugin Information

- **Plugin URI**: [https://revoty.com](https://revoty.com)
- **Version**: 1.0.0
- **Text Domain**: revoty
