Page 1 of 1
Get products count into cart
Posted: 11 Feb 2020, 11:14
by traiyani75
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
Re: Get products count into cart
Posted: 12 Feb 2020, 13:08
by aimeos
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
Code: Select all
fields[basket]=order.base.price&fields[basket/product]=order.base.product.name,order.base.product.mediaurl,order.base.product.price
to limit the fields sent to the client
Re: Get products count into cart
Posted: 15 Feb 2020, 07:38
by traiyani75
I have tried this api, but it returning all data every time.
{base-url}/default/jsonapi/basket?include=basket/product
Re: Get products count into cart
Posted: 16 Feb 2020, 09:19
by aimeos
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
Re: Get products count into cart
Posted: 25 Feb 2020, 11:50
by traiyani75
It only filters products from the basket, But still, it returns all data into products object
Re: Get products count into cart
Posted: 26 Feb 2020, 08:44
by aimeos
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