## WooCommerce Essentials - Paysera
Paysera plugin for WordPress (WooCommerce)

---

## Code style
[PSR-12](https://www.php-fig.org/psr/psr-12)

---

## Built with
- [PSR](https://www.php-fig.org/psr/)

---

## Temporary while under development
1. _Create dir `ssh`_
2. _Copy to `ssh` id_rsa, id_rsa.pub, and known_hosts from ~/.ssh. If your files has another names - copy files and rename them to id_rsa, id_rsa.pub, and known_hosts_
3. _Copy `auth.json.dist` to `auth.json`_
4. _Set your personal gitlab access token to `auth.json`_
---

## Installation (will be updated soon)

**Before installing make sure that you local machine has NodeJS 20.x and NPM!**

Install `wp-env` tool:
```bash
npm -g i @wordpress/env
```

When `wp-env` installation done, install Composer and NPM dependencies:
```bash
make install
```

Then you can deploy WordPress for testing plugin:
```bash
make build-dev-env
```
By default WordPress will be available by http://localhost:8888 

If port 8888 already busy, you can redefine container configurations via `.wp-env.overrride.json` (you may copy it from `.wp-env.overrride.json`)
More information about available settings you can find here https://developer.wordpress.org/block-editor/reference-guides/packages/packages-env/

Now you can work on the plugin.

### Frontend Development Guide

The frontend source files are located in the `packages` directory. The plugin does **not** use these source files directly — it uses the built application instead.

For development, it’s recommended to run:

```bash
npm start
```

This command will watch for changes and automatically update the build.

To generate the final production build, run:

```bash
npm run build
```

---

## ⚙️ Makefile Commands

> The following commands are available to simplify development and plugin packaging.

### `make install`

Runs both backend and frontend dependency installation inside Docker:
- composer install for PHP
- npm install for JS

### `make install-backend`

Installs only PHP dependencies via Composer inside Docker.

### `make install-frontend`

Installs only JS dependencies via npm inside Docker.

### `make build-plugin`

Builds the final plugin ZIP archive inside Docker:
- Removes old ZIPs from the `/build` folder
- Builds Docker image from `.docker/build.Dockerfile`
- Copies resulting `.zip` file into `build/` directory
- Cleans up temporary containers and image

The resulting ZIP file will be named like:  
`build/payment-gateway-paysera-smart-YYYY-MM-DD.zip`

### `make build-dev-env`

Creates a WordPress environment for plugin testing. Deploys a Docker container with WordPress (6.7.2) and WooCommerce (9.8.1), mounting the project folder as a separate plugin inside the WordPress container. No additional WordPress configuration is required after deployment.

### `make rebuild-dev-env`

Re-creates a WordPress environment for plugin testing.

### `make stop-dev-env`

Stops WordPress container

### `make run-dev-env`

Runs stopped WordPress container

### `make drop-dev-env`

Destroys WordPress container

---
