Quantity discounts, currency context in orders, product deletion and more
This release brings several improvements for ERP, PIM and B2B integrations:
- Quantity discounts in products and price lists.
- Currency context in orders: the currency the customer saw and paid in, and the exchange rates applied.
- Price lists of customers, with new filters in the contacts listing.
- Deletion of products and variants.
- Two fixes that change the output in some cases: brand URLs and the language of job messages.
Quantity discounts
Products and price lists now expose their quantity discounts, so that integrations can read and update them through the API.
OpenTiendas has two kinds of quantity discounts, and the API exposes both:
- Catalog quantity discounts belong to the product and are defined for each market. They apply to standard catalog pricing.
- Price list quantity discounts are defined for each variant in a custom price list. They apply to the customers who have that price list assigned.
They are never combined: customers with a custom price list assigned don't get the catalog quantity discounts, only the ones of their price list.
The QuantityDiscount tier
Both use the same tier format:
{
"minimum_quantity": 10,
"discount": { "type": "percentage", "percentage": "5.00" }
}
{
"minimum_quantity": 20,
"discount": {
"type": "fixed_amount",
"amount": { "amount": "2.00", "currency": "EUR" }
}
}
minimum_quantity: the minimum number of units required to apply the discount.discount: the discount applied to each unit, either apercentageof the unit price (greater than 0 and lower than 100) or afixed_amount.
Tiers are returned sorted by minimum_quantity, and only the highest tier reached applies. Each minimum_quantity must be unique, with a maximum of 10 tiers.
Products
The new field quantity_discounts is keyed by market, like the variant prices. Request it via fields:
GET /api/v1/products/1204?locales=es-ES,en-GB&fields=quantity_discounts
{
"id": 1204,
"quantity_discounts": {
"market_es": [
{
"minimum_quantity": 10,
"discount": { "type": "percentage", "percentage": "5.00" }
}
],
"market_en": []
}
}
The units of all the variants of the product are added up to reach each tier.
To update them, send quantity_discounts in POST /api/v1/products/bulk-upsert/:
- If
quantity_discountsis omitted, the quantity discounts are not modified. - Markets not included keep their quantity discounts.
- An empty list removes the quantity discounts of that market.
- A list of tiers replaces the quantity discounts of that market.
All markets share the same set of tiers internally, so the different minimum_quantity values of all the markets together cannot exceed 10.
More details in Localization, Markets & Pricing.
Price lists
Variant prices in price lists have a new quantity_discounts field: a list of tiers for that variant.
{
"variant_internal_id": "VAR-001",
"price": { "amount": "4.75", "currency": "EUR" },
"min_quantity": 5,
"quantity_factor": 5,
"quantity_discounts": [
{
"minimum_quantity": 10,
"discount": { "type": "percentage", "percentage": "5.00" }
}
]
}
It is returned when listing the variant prices of a price list, and it can be updated with POST /api/v1/price-lists/{id}/prices/bulk-update/ in upsert mode:
- If
quantity_discountsis omitted, the quantity discounts are not modified. - An empty list removes the quantity discounts of the variant.
- A list of tiers replaces the existing quantity discounts.
min_quantity and quantity_factor are still independent of the quantity discounts.
Currency context in orders
Orders now tell you in which currency the customer saw the prices and paid, together with the exchange rates that were applied, so that integrations can reconcile orders placed in other currencies.
All monetary amounts of an order (line items, discounts, additional services, shipping, fees and totals) are returned in the base currency of the store, for example EUR. That does not change. Until now, though, an order placed by a customer who browsed the store in another currency could not be told apart from one placed in the base currency, and there was no way to know the exchange rate used.
currency_context
A new field currency_context is available in orders:
{
"currency_context": {
"base_currency": "EUR",
"presentment_currency": "GBP",
"payment_currency": "EUR",
"exchange_rates": {
"presentment_to_base": "1.15420",
"payment_to_base": "1.00000"
}
}
}
| Field | Meaning |
|---|---|
base_currency | Currency in which all the amounts of the order are expressed |
presentment_currency | Currency in which prices were shown to the customer |
payment_currency | Currency in which the payment was processed |
exchange_rates.presentment_to_base | Rate to convert amounts from presentment_currency to base_currency |
exchange_rates.payment_to_base | Rate to convert amounts from payment_currency to base_currency |
The rates always convert to the base currency:
base amount = source amount × exchange rate
When all the currencies are the same, both rates are "1.00000".
When the currencies differ
presentment_currencydiffers frombase_currencywhen the customer placed the order in another currency, for example after choosing a different country in the storefront.payment_currencydiffers frompresentment_currencywhen the payment method does not accept the presentment currency and charges in its fallback currency instead, as the customer is told at checkout. PayPal, Stripe and Adyen always charge in the presentment currency, and SeQura only works in EUR.
Historical exchange rates
The exchange rates are captured when the order is placed. If the customer pays a pending order later and selects the payment method again (even the same one), payment_currency and payment_to_base are captured again at that moment, so the payment uses the exchange rate of that day. They are stored with the order and are never recalculated when the order is retrieved.
For older orders, payment_currency and payment_to_base were filled in when they could be reliably reconstructed: when the payment method accepts the currency of the order or always charges in it, or when it charged in the base currency (rate "1.00000"). Otherwise they are null.
currency_context is part of the default fields of the order, so it is also included in the payload of the order webhooks (order.created, order.paid, order.fulfilled and order.canceled).
Price lists of customers
Contacts have two new read-only fields with the custom price lists assigned to the customer, sorted by price list ID:
price_list_ids: list of price list IDs.price_list_internal_ids: list of price list internal IDs.
They are not default fields, so request them via fields. A customer without price lists returns empty lists.
GET /api/v1/contacts/?view=customers&price_list_ids=3,8&fields=email,price_list_ids,price_list_internal_ids
{
"id": 259,
"email": "customer@example.com",
"price_list_ids": [3],
"price_list_internal_ids": ["distributor-ESP"]
}
GET /api/v1/contacts/ also has three new filters, to be used with view=customers:
| Filter | Returns |
|---|---|
price_list_ids | Customers assigned to at least one of the price lists (up to 10 IDs, comma-separated) |
price_list_internal_ids | Same, with price list internal IDs |
has_price_lists | true: customers with at least one price list. false: customers without price lists |
To get the details of the price lists, use the price_list_ids filter of GET /api/v1/price-lists/: one request per page of customers.
GET /api/v1/price-lists/?price_list_ids=3,8
Deleting products and variants
Integrations that keep the catalog in sync can now delete products and variants, not only unpublish them:
DELETE /api/v1/products/{id}/
DELETE /api/v1/products/{product_id}/variants/{id}/
- Deleting a product also deletes its variants. Deleting a variant keeps the product and its other variants.
- The same rules as in OpenTiendas apply: a product or variant cannot be deleted while it is associated with orders that are still being processed or with other operations that require it to be retained.
- After deletion, the product or variant is no longer available for purchase, but it may remain visible for a few minutes until the change is fully reflected across OpenTiendas.
| Status | Meaning |
|---|---|
204 No Content | Deleted |
404 Not Found | The product or variant does not exist |
409 Conflict | It cannot be deleted. The response describes the restriction |
Deleting a product or variant is permanent: it cannot be recovered, and its data (translations, prices, images, stock…) is lost.
If you only need to stop selling it, unpublish it instead by setting status to unpublished (with POST /api/v1/products/bulk-upsert/ or POST /api/v1/variants/bulk-update/). It disappears from the store and can be published again at any time. Delete it only when it must no longer exist.
Fixes that change the output
Brand URLs in every locale
The url of the brand translations always used the English path, for example /brands/... in translations.es-ES.url, so it pointed to a page that does not exist in that locale. It now uses the path of the translation's own locale:
{
"translations": {
"en-GB": { "url": "https://shop.example.com/brands/urbano/" },
"es-ES": { "url": "https://tienda.ejemplo.com/marcas/urbano/" }
}
}
This affects GET /api/v1/brands/ and the brands included in products (includes=brand).
Job messages in English
The log of the jobs (GET /api/v1/jobs/{job_id}/logs/) mixed messages in English with messages in the default language of the store, such as the validation errors of POST /api/v1/products/bulk-upsert/. Jobs now run in English, like the rest of the API, so all their messages are in English. The content of the store is not affected: translations are still saved in the locale indicated in the request.
If your integration matches the text of these messages, check it against the English version. The code of each log entry does not change.
Availability
GET /api/v1/products/andGET /api/v1/products/{id}/(quantity_discounts)POST /api/v1/products/bulk-upsert/(quantity_discounts)DELETE /api/v1/products/{id}/DELETE /api/v1/products/{product_id}/variants/{id}/GET /api/v1/price-lists/{id}/prices/andPOST /api/v1/price-lists/{id}/prices/bulk-update/(quantity_discounts)GET /api/v1/orders/andGET /api/v1/orders/{id}/(currency_context), and the order webhooksGET /api/v1/contacts/andGET /api/v1/contacts/{id}/(price lists of customers)GET /api/v1/brands/(brand URLs) andGET /api/v1/jobs/{job_id}/logs/(job messages)

