# Configuration

Environment and plugin settings that affect behaviour.

## Sentry (optional)

Error reporting is optional and controlled by constants, typically set in `wp-config.php`:

| Constant | Description |
|----------|--------------|
| `PARCEL2GO_SENTRY_ENVIRONMENT` | Environment name sent with events (e.g. `staging`, `production`). Defaults to `production` if not set. |

If `PARCEL2GO_SENTRY_ENVIRONMENT` is not defined, the plugin falls back to `WP_ENVIRONMENT_TYPE` when that constant is set. These values are passed to the frontend via `parcel2goShipping.dsn` and `parcel2goShipping.environment` in `includes/Admin/Setup.php` (used when initializing Sentry in the React app).

## Parcel2Go API

Backend calls to the Parcel2Go API use the constants and list in `includes/Constants/P2GApi.php`:

| Constant | Purpose |
|----------|--------|
| `P2GApi::BASE_URL` | Base URL for the P2G API. |
| `P2GApi::TENANT_ID` | Tenant identifier. |
| `P2GApi::CACHE_EXPIRY` | Cache TTL in seconds (e.g. 300). |
| `P2GApi::P2G_SERVICES` | List of P2G service identifiers used for validation or filtering. |

These are currently set to dev/test values in code. For production, consider making base URL and tenant configurable (e.g. via plugin settings or environment constants) instead of editing the class.

## Store and plugin settings

- **Store address:** Used as origin for quotes and shipping. Configured in WooCommerce (e.g. **WooCommerce → Settings → General**). The plugin exposes it via the REST endpoint `GET /parcel2go-shipping/v1/settings/store` and links to the store address settings from the Settings UI (`storeAddressUrl` in localized config).
- **Plugin settings / default services:** The Settings page in the admin (path `/parcel2go-shipping/settings`) and the REST endpoints under `parcel2go-shipping/v1/settings` and `.../settings/default-services` let you view and update plugin options and default service configuration. The exact fields are defined in the Settings UI and in `includes/Api/SettingsController.php`.
