# 配方

> 即拷即用的 Shoplazza CLI 片段，用 --jq 串联多条命令：导出商品 ID、统计待处理订单、预览批量折扣、在 CI 中无人值守运行。

组合多条命令完成常见任务的即拷即用片段。均依赖默认 JSON 输出与 `--jq` 过滤。

## 导出所有商品 ID

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

## 链式:逐个取商品详情

stdout 可安全管道,因此可把 ID 喂给下一条命令:

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

## 统计未处理订单

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

## 创建批量折扣前先预览

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

## 建客户并捕获新 ID

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

## 用表格视图快速浏览搜索结果

```shell
shoplazza orders +search --fields "id,status,total_price" --format table
```

## 在 CI 中非交互运行

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

## 参见

* [输出格式](./output-formats)
* [分页与过滤](./pagination-and-filtering)
* [CI/CD 集成](./ci-cd)
