Questions About Order History API Response

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
User avatar
PaoloLegaspi
Posts: 35
Joined: 07 Nov 2024, 15:02

Questions About Order History API Response

Post by PaoloLegaspi » 26 Dec 2024, 08:05

Hi! We’re working on the order history page for our frontend and ran into a couple of questions:
  • For an ordered product that has a granted rebate value set up in the price panel, we noticed that in the JSON API response, order.product.rebate is showing "0.00" instead of the expected "59.00". Could you help us figure out why this might be happening?
  • Also, would it be possible to include the product URL segment in the order.product response? It would really help us easily redirect users to the product details page for the ordered item.
Thanks in advance for your help!

//Rebate screenshots
Attachments
Screenshot 2024-12-26 at 3.54.51 PM.png
Screenshot 2024-12-26 at 3.54.51 PM.png (134.92 KiB) Viewed 13858 times
Screenshot 2024-12-26 at 3.47.47 PM.png
Screenshot 2024-12-26 at 3.47.47 PM.png (149.74 KiB) Viewed 13858 times

User avatar
aimeos
Administrator
Posts: 8616
Joined: 01 Jan 1970, 00:00

Re: Questions About Order History API Response

Post by aimeos » 28 Dec 2024, 10:37

The granted rebate value in the price item used for displaying the original price isn't stored in the order product item because rebate values there are discounts from coupon codes. The fetch the original price rebate and the product URL segment, use "...&include=order.product,product,price"
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
PaoloLegaspi
Posts: 35
Joined: 07 Nov 2024, 15:02

Re: Questions About Order History API Response

Post by PaoloLegaspi » 29 Dec 2024, 07:41

Hi, thank you for getting back to us

We’ve tried your suggestion using this URL: http://localhost:8000/jsonapi/order?include=order.product,product,price We have some questions and concerns about the response:
  • The JSON API does return the prices of the products (which is great!), but we’re having trouble identifying which product each price is linked to. In the response, all prices are under the included array, but there’s no ID to clearly map a price to its corresponding product.
    • Our goal is to show both the original price and the discounted price (if there's a granted rebate) in the order history listing. Without this mapping, it’s challenging to display the correct information.
  • Regarding the product data, when using include=product, the response only includes the product ID in the relationships array but doesn’t return the actual product details.
    Screenshot 2024-12-29 at 3.35.59 PM.png
    Screenshot 2024-12-29 at 3.35.59 PM.png (224.97 KiB) Viewed 12702 times
    • Ideally, we’d like the product data (or at least the URL segment) to be included directly in the jsonapi/order route response. Since we rely on the URL segment to fetch or redirect to the product, having it in the response would eliminate the need for additional requests to retrieve product details. This would help streamline the process and enhance frontend performance.
We’d really appreciate any guidance on how to address these issues. Thanks!

User avatar
aimeos
Administrator
Posts: 8616
Joined: 01 Jan 1970, 00:00

Re: Questions About Order History API Response

Post by aimeos » 30 Dec 2024, 09:54

In the JSON:API standard, all related items are referenced via the "relationships" key in the data items and the related items are stored in the "included" array. See https://aimeos.org/docs/latest/frontend ... -resources

You can simplify the returned structure of the JSON:API by using a JS package which maps the related items directly to the data like https://www.npmjs.com/package/json-api-models
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply