Test environment
Test the API on a local store with sample data and never against a production store. This repository includes a WordPress + WooCommerce store in Docker with the plugin mounted and the sample store "Smash House": 12 products, extras, hours, tables and loyalty.
| Item | Value |
|---|---|
| Site | http://127.0.0.1:8096 |
| API base URL | http://127.0.0.1:8096/wp-json/notiwoo/v1 |
| Administrator | docs / docs-local-only |
| Customer | ana / docs-local-only |
| Currency and country | COP, Colombia (Bogotá) |
These credentials are public and only work on the local store. The container listens only on 127.0.0.1. Do not expose it to the internet or reuse these passwords.
Requirements
- Docker with Docker Compose.
- The
NotiWoo-Docsandnotiwoo-pluginrepositories in the same folder, or theNOTIWOO_PLUGIN_PATHvariable pointing to the plugin.
Start the store
From the root of this repository:
docker compose -f scripts/screenshots/wp/compose.yml up -d
The first time, install WordPress and load the sample data with the cli service:
WP="docker compose -f scripts/screenshots/wp/compose.yml run --rm cli"
$WP core install --url=http://127.0.0.1:8096 --title="Smash House" \
--admin_user=docs --admin_password=docs-local-only --admin_email=docs@example.test --skip-email
$WP plugin install woocommerce --activate
$WP plugin activate notiwoo-plugin
$WP language core install es_CO en_US
$WP eval-file /fixtures/seed.php
$WP eval-file /fixtures/enrich.php
$WP eval-file /fixtures/images.php
Stop the store with docker compose -f scripts/screenshots/wp/compose.yml down. Data is kept in Docker volumes. To start from scratch, add --volumes.
First call
curl http://127.0.0.1:8096/wp-json/notiwoo/v1/status
Get a token
curl -X POST http://127.0.0.1:8096/wp-json/notiwoo/v1/auth/token \
-H "Content-Type: application/json" \
-d '{"username": "docs", "password": "docs-local-only"}'
Save the value of data.token and use it in the following calls:
TOKEN="paste-the-token-here"
curl "http://127.0.0.1:8096/wp-json/notiwoo/v1/orders?per_page=5" \
-H "Authorization: Bearer $TOKEN"
To test with an application password:
docker compose -f scripts/screenshots/wp/compose.yml run --rm cli \
user application-password create docs api-tests --porcelain
curl -u "docs:<generated-password>" http://127.0.0.1:8096/wp-json/notiwoo/v1/auth/me
In the local environment, WordPress allows application passwords without HTTPS.
Test walkthrough
GET /schedule/delivery/status: check that delivery is open.GET /productswith a token: pick a product.POST /cart/validate: validate a cart with extras. See Hours, delivery and cart.POST /bulk/preview: preview a price increase without applying it. See Bulk changes.DELETE /auth/token: revoke the token when you finish.
Good practices
- Always use made-up data, with the
example.testdomain for emails and URLs. - Do not copy real customer data or Google, WhatsApp or payment gateway keys into this store.
- Delete test application passwords with
user application-password delete docs --all.