# shipmondo-for-woocommerce

[Wordpress Plugin Store page](https://wordpress.org/plugins/shipmondo-for-woocommerce/)

## Development

### Setting up the project

The following tools are used for developing new versions of this plugin:

| Tool                                                      | Usage                                                                   | Required |
| --------------------------------------------------------- | ----------------------------------------------------------------------- | -------- |
| `node`                                                    | Used for building service point picker frontend                         |   X      |
| `npm`                                                     | Used to install service point picker frontend dependencies              |   X      |
| `composer`                                                | Used to install stubs (type declarations) for Wordpress and WooCoomerce |          |
| [`WP-CLI`](https://developer.wordpress.org/cli/commands/) | Used to generate i18n files                                             |          |

#### Install Node dependencies

Node is used for building the service point picker block.

```shell
npm install
```

#### Install PHP dependencies

```shell
composer install
```

#### Updating translation file

The translation file can be updated by running the following command, or by running `mise i18n`.

```shell
wp i18n make-pot . ./languages/shipmondo-for-woocommerce.pot
```

## Building the project

### Development

To build the frontend run `npm run build`.

That command will take the frontend files (`resources/`) and transpile an output (`public/`) that can be references in the PHP plugin files.

### Production

To build the plugin for production run the `build-release.sh` script.

The script will generate a zip (`shipmondo-for-woocommerce.zip`) which can be uploaded to a Wordpress website.

```shell
./build-release.sh
```

## Testing

1. Set permalink structure to post name
2. Go to Shipmondo settings
   - Set Delivery Checkout key
   - Show service point in to dropdown
3. Go to pages and add a classic-checkout page
   - Set company name to optional
4. Add the following shipping methods
   - Home delivery
   - Business delivery
   - The following with SP
     - All service point types
     - One with BOX
     - One with LOCKER
5. Perform an order with home delivery
6. Perform an order with business delivery
   - Verify company name is required
7. Perform an order with each SP delivery methods, and validatate that the correct service points are shown in the modal/dropdown
8. Perform the orders using both classic-checkout and "modern" checkout.
