Save Basket API Response Issue

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!
danishrehman
Posts: 4
Joined: 05 Dec 2020, 09:25

Save Basket API Response Issue

Post by danishrehman » 05 Dec 2020, 09:31

Aimeos Version: 2020.10
Php Version: 7.3.4
Environment: Win 10 (wamp server)

I'm working on API where saving basket after adding products, address and services!

Code: Select all

axios.post('/jsonapi/basket').then(response => {
        console.log(response)
}).catch(error => {
         console.log(error)
});
 
This below error comes up in response every time, configured everything as in documentation mentioned. Please let me know where I go wrong. Thanks

Error!
Checks for available service items in basket failed.

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

Re: Save Basket API Response Issue

Post by aimeos » 06 Dec 2020, 18:01

Do you pass the CSRF token and the session token in your request?
Can you please add more details like last response and full source code for your request?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

danishrehman
Posts: 4
Joined: 05 Dec 2020, 09:25

Re: Save Basket API Response Issue

Post by danishrehman » 07 Dec 2020, 05:57

No, Its not the issue of CSRF!

First of all adding product to basket, and its working.

Code: Select all

addToBasket: function () {
                let data = {
                    "data": [
                        {
                            "attributes": {
                                "product.id": "1",
                                "quantity": 1,
                                "stocktype": "default"
                            }
                        }
                    ]
                };
                axios.post('/jsonapi/basket?id=default&related=product',data).then(response => {
                    console.log(response);
                }).catch((error) => {
});
then adding address, its working too.

Code: Select all

let address = {
                    "data": [
                        {
                            "id": "payment",
                            "attributes": {
                                "order.base.address.firstname": "Walk-in",
                                "order.base.address.lastname": "Customer",
                                "order.base.address.salutation": "mr",
                                "order.base.address.title": "Dr.",
                                "order.base.address.postal": "51310",
                                "order.base.address.countryid": "PK",
                                "order.base.address.address1": "Main Market Street",
                                "order.base.address.city": "Sialkot",
                                "order.base.address.languageid": "en",
                                "order.base.address.email": "danidff@gmail.com",
                            }
                        }
                    ]
                };

                axios.post('/jsonapi/basket?id=default&related=address',address).then(response => {
                    console.log(response);
                }).catch((error) => {
 });
Then adding to services, It's working as well!

Code: Select all

 let service = {
                    "data": [
                        {
                            "id": "payment",
                            "attributes": {
                                /*"service.id": "11",*/
                                "service.id": 6,
                            }
                        },
                    ]};

                axios.post('/jsonapi/basket?id=default&related=service&relatedid=payment', service).then(response => {
                    console.log(response)
                }).catch(error => {

                });
In last when i call for save basket to generate order, error comes up!

Code: Select all

axios.post('/jsonapi/basket?id=default').then(response => {
                  
                  console.log(error)
}).catch(error => {
                    console.log(error)
 });


Error!
Checks for available service items in basket failed.

EXPLAINATION


It working fine when I off these two plugins but issue is, if go for it order doesn't save.
  • Checks for required addresses (billing/delivery)
  • Checks for required services (delivery/payment)

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

Re: Save Basket API Response Issue

Post by aimeos » 08 Dec 2020, 09:46

Does the response you get after adding the delivery/payment services contains all data you've added before?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

danishrehman
Posts: 4
Joined: 05 Dec 2020, 09:25

Re: Save Basket API Response Issue

Post by danishrehman » 09 Dec 2020, 06:33

yes, it does contain all data getting response as success.
I've mentioned two default plugins are conflicting with Save Basket! I've off both of plugins temporary but does not save record in base_order table else saving good.
Just need clarity on this issue how to resolve this issue on my end. Can your team check this issue?
Many Thanks in advance.

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

Re: Save Basket API Response Issue

Post by aimeos » 11 Dec 2020, 11:15

Which application (Laravel, Symfony or TYPO3) are you using? We had problems in the past with MySQL based user sessions. File based session never had problems.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

danishrehman
Posts: 4
Joined: 05 Dec 2020, 09:25

Re: Save Basket API Response Issue

Post by danishrehman » 11 Dec 2020, 12:17

I'm currently using laravel based store as default plus creating POS with vue js!
issue is on save basket end point of api. which is conflicting with two mentioned plugins or something is missing in doc that how to handle.

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

Re: Save Basket API Response Issue

Post by aimeos » 11 Dec 2020, 12:38

The plugis error messages are only the result of an empty basket but not the cause of the problem. Like said, we had problems in the past with baskets being empty between request. Add another request fetching the complete basket so you can check if it's empty or at least addresses and services missing before you try to sent a POST request to persist the basket.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
hassanas
Posts: 3
Joined: 18 Jan 2021, 09:47

Re: Save Basket API Response Issue

Post by hassanas » 24 Feb 2021, 10:57

I am facing the same problem and I am receiving empty response (after add to cart call) on every subsequent call. I am not passing any kind of token or cookie ? what I have to do? please share some code snippet

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

Re: Save Basket API Response Issue

Post by aimeos » 26 Feb 2021, 07:41

You need to pass the session cookie and the CSRF token (if you want to update the basket):
https://aimeos.org/docs/latest/frontend ... i/baskets/
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply