# Recipes

> Copy-ready Shoplazza CLI snippets that chain commands with --jq: export product IDs, count open orders, preview a bulk discount, and run unattended in CI.

Copy-ready snippets that combine multiple commands for common tasks. All rely on JSON output and `--jq` filtering. JSON is the default only when stdout is piped or in CI, so standalone commands below pass `--format json`.

## Export all product IDs

```shell
shoplazza products list --format json --jq '.data.products[].id'
```

This returns one page; follow `cursor` while `has_more` is `true` (see [Pagination & filtering](./pagination-and-filtering)).

## Chain: get details for each product

stdout is safe to pipe, so you can feed IDs into another command:

```shell
shoplazza products list --jq '.data.products[].id' \
  | xargs -I {} shoplazza products get --params '{"product_id":"{}"}'
```

## Count open orders

```shell
shoplazza orders +count --format json --jq '.data.count'
```

## Preview a bulk discount before creating it

```shell
shoplazza discounts +rebate --target order --tiers "200:20,500:50,1000:120" --dry-run
```

## Create a customer and capture the new ID

```shell
shoplazza customers +create --email test@example.com --format json --jq '.data.customer.id'
```

## Search with a table view for quick scanning

```shell
shoplazza orders +search --format table
```

## Non-interactive run in CI

```shell
export SHOPLAZZA_UAT=your-token
shoplazza auth login --store-domain my-store.myshoplaza.com
shoplazza products +search --keyword "shirt" --jq '.data.products | length'
```

## See also

* [Output formats](./output-formats)
* [Pagination & filtering](./pagination-and-filtering)
* [CI/CD integration](./ci-cd)
