Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ivorpad/mercadona-cli/llms.txt

Use this file to discover all available pages before exploring further.

cart set-many is the preferred way to build or replace a basket. It reads the current cart once, applies every <id> <qty> change you specify, prices the full resulting basket, enforces the budget cap if set, and issues a single PUT — no race conditions between concurrent reads, and no repeated round-trips to the server.

Synopsis

mercadona cart set-many [-f file] [flags] [id qty ...]

Flags

FlagDefaultDescription
-f <file>File with one <id> <qty> per line (- = stdin)
--max <eur>0/env/configRefuse if resulting cart total exceeds this amount
--wh <code>config/mad1Warehouse code
--lang <code>config/esLanguage code (es, en, ca, eu, vai)
--jsonfalseEmit raw cart JSON (PUT response)

Input format

Supply changes as one <id> <qty> pair per line. A qty of 0 removes that product line. Inline # comments are supported, making the file self-documenting.
basket.txt
5044    1   # Arroz redondo Hacendado
60393   2   # Gambón grande congelado
85499   1   # Mejillón mediterráneo
13406   0   # remove mayonesa
Lines that consist entirely of a comment or whitespace are skipped. The parser accepts fractional quantities for weight and bulk products.

Examples

# From a file
mercadona cart set-many -f basket.txt --max 80

# From stdin
printf '51110 2\n13406 1\n' | mercadona cart set-many -f - --max 80

# Positional pairs
mercadona cart set-many 51110 2 13406 1 --max 80

# Full basket replacement, JSON output
mercadona cart set-many -f basket.txt --max 80 --json

How the budget guard works

When --max is set (or MERCADONA_MAX_EUR/[limits].max_eur is configured), set-many runs a two-stage spending check:
  1. Pre-write estimate — prices the full resulting basket before the PUT. Prices already present in the cart GET response are reused; only new product IDs are fetched. If the estimate exceeds the cap, the command refuses without writing — your cart is untouched.
  2. Authoritative post-write check — after the PUT, the real total returned by the API is compared against the cap. If it still breaches the limit (due to promotions or rounding the estimate missed), the cart is reverted to its pre-change state.
In both cases the command exits with a non-zero status and a BUDGET EXCEEDED error message.

Human output format

After a successful write, a summary line lists the number of changes alongside the new cart totals, with each changed line indented below:
✓ set-many: 3 cambios  |  carrito: 3 productos, total 17.20€
    [5044] Arroz redondo Hacendado → x1
    [60393] Gambón grande congelado → x2
    [85499] Mejillón mediterráneo → x1
A product removed by qty = 0 is shown as → (eliminado). If the basket is below the 60€ delivery minimum, a shortfall hint is printed after the change list.
The price-fetch burst for products not already in the cart is capped at 4 parallel GETs by default. If the API starts throttling you, set MERCADONA_CONCURRENCY=1 to serialize those fetches. The HTTP client also backs off automatically on HTTP 429/503 responses, so a rate-limit surfaces as a brief pause rather than an error.
The same basket file works for both mercadona total -f basket.txt (a no-auth pre-cart price estimate) and mercadona cart set-many -f basket.txt (the actual write). Use total to size and verify the basket before committing it to the cart.

Build docs developers (and LLMs) love