Get products count into cart
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!
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
-
- Advanced
- Posts: 114
- Joined: 08 Nov 2019, 11:56
Get products count into cart
Hello, we are using laravel apis to connect aimeos into mobile applications.
We need API to get products list count in cart. So we can show count over the cart icon.
Thanks
We need API to get products list count in cart. So we can show count over the cart icon.
Thanks
Re: Get products count into cart
Use the basket endpoint and count the products in the basket. Thus, you can also display a small basket immediately in the frontend when a user clicks on the icon. To minimize the transfered data, you can add
to retrieve the products but not the address and service items and you can use
to limit the fields sent to the client
Code: Select all
include=basket/product
Code: Select all
fields[basket]=order.base.price&fields[basket/product]=order.base.product.name,order.base.product.mediaurl,order.base.product.price
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
-
- Advanced
- Posts: 114
- Joined: 08 Nov 2019, 11:56
Re: Get products count into cart
I have tried this api, but it returning all data every time.
{base-url}/default/jsonapi/basket?include=basket/product
{base-url}/default/jsonapi/basket?include=basket/product
Re: Get products count into cart
Sorry, forgot the "include" parameter and there was a problem filtering related basket fields. Please run "composer update" and use an URL like that:
Code: Select all
http://127.0.0.1:8000/jsonapi/basket?included=basket/product&fields[basket]=order.base.price&fields[basket/product]=order.base.product.name,order.base.product.mediaurl,order.base.product.price
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
-
- Advanced
- Posts: 114
- Joined: 08 Nov 2019, 11:56
Re: Get products count into cart
It only filters products from the basket, But still, it returns all data into products object
Re: Get products count into cart
Did you run "composer update"? Both, 2019.10.4 and dev-master only return the fields mentioned in the "fields[basket/product]" parameter:
Code: Select all
aimeos/ai-client-jsonapi 2019.10.4 Aimeos JSON API extension
aimeos/ai-client-jsonapi dev-master 6dd20da Aimeos JSON API extension
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star