Update mini cart ajax problem

Questions around the TYPO3 integration and plugins
Forum rules
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
User avatar
loeffe1
Posts: 51
Joined: 21 Feb 2020, 10:33

Update mini cart ajax problem

Post by loeffe1 » 26 Feb 2020, 13:05

My mini cart will not update when adding a product to the cart.

The update function is being called (the modal window is displaying correctly) but it never reaches the line AimeosBasketMini.updateBasket(basket). An error function added to the first ajax call will trigger, so for some reason this first ajax call fails.

$.ajax(jsonurl, {
"method": "OPTIONS",
"dataType": "json",
error: function(){
alert('error!');
}

})

Any idea what could be causing this?


TYPO3 9.5.14
Aimeos 19.10.5
PHP 7.3.15

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

Re: Update mini cart ajax problem

Post by aimeos » 27 Feb 2020, 07:56

Most likely, you didn't set the JSON REST API page in the flexform of the plugin.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
loeffe1
Posts: 51
Joined: 21 Feb 2020, 10:33

Re: Update mini cart ajax problem

Post by loeffe1 » 28 Feb 2020, 08:36

Sorry for the late reply.
I have set the page of the json api in the content element settings, so that's not the cause of the problem.

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

Re: Update mini cart ajax problem

Post by aimeos » 28 Feb 2020, 15:12

Another problem may be that your TYPO3 installation returns additional HTML around the JSON response. You can check that in the inspector of your web browser if you have a look at the response from the server for your /jsonapi request.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
loeffe1
Posts: 51
Joined: 21 Feb 2020, 10:33

Re: Update mini cart ajax problem

Post by loeffe1 » 02 Mar 2020, 09:36

I am seeing two request to the jsonapi. The response seems correct for both request.

Code: Select all

https://localtest.ddev.site/home/jsonapi?ai%5Bcontroller%5D=Jsonapi&ai%5Baction%5D=options

Code: Select all

{
"meta": {
"prefix": "ai",
"content-baseurl": "/uploads/tx_aimeos"

, "locale": {"locale.id":"15","pos":"2","locale.siteid":"1","locale.languageid":"de","locale.currencyid":"PKT","locale.position":2,"locale.status":1}
, "resources": {"attribute":"https:\/\/localtest.ddev.site\/home\/jsonapi?ai%5Bresource%5D=attribute&ai%5Bcontroller%5D=Jsonapi&ai%5Baction%5D=options","basket":"https:\/\/localtest.ddev.site\/home\/jsonapi?ai%5Bresource%5D=basket&ai%5Bcontroller%5D=Jsonapi&ai%5Baction%5D=options","catalog":"https:\/\/localtest.ddev.site\/home\/jsonapi?ai%5Bresource%5D=catalog&ai%5Bcontroller%5D=Jsonapi&ai%5Baction%5D=options","customer":"https:\/\/localtest.ddev.site\/home\/jsonapi?ai%5Bresource%5D=customer&ai%5Bcontroller%5D=Jsonapi&ai%5Baction%5D=options","locale":"https:\/\/localtest.ddev.site\/home\/jsonapi?ai%5Bresource%5D=locale&ai%5Bcontroller%5D=Jsonapi&ai%5Baction%5D=options","order":"https:\/\/localtest.ddev.site\/home\/jsonapi?ai%5Bresource%5D=order&ai%5Bcontroller%5D=Jsonapi&ai%5Baction%5D=options","product":"https:\/\/localtest.ddev.site\/home\/jsonapi?ai%5Bresource%5D=product&ai%5Bcontroller%5D=Jsonapi&ai%5Baction%5D=options","service":"https:\/\/localtest.ddev.site\/home\/jsonapi?ai%5Bresource%5D=service&ai%5Bcontroller%5D=Jsonapi&ai%5Baction%5D=options","stock":"https:\/\/localtest.ddev.site\/home\/jsonapi?ai%5Bresource%5D=stock&ai%5Bcontroller%5D=Jsonapi&ai%5Baction%5D=options","supplier":"https:\/\/localtest.ddev.site\/home\/jsonapi?ai%5Bresource%5D=supplier&ai%5Bcontroller%5D=Jsonapi&ai%5Baction%5D=options"}
}

}


Code: Select all

https://localtest.ddev.site/home/jsonapi?ai%5Bresource%5D=basket&ai%5Bcontroller%5D=Jsonapi&ai%5Baction%5D=options

Code: Select all

{
"meta": {
"total": 1,
"prefix": "ai",
"content-baseurl": "/uploads/tx_aimeos"

},
"links": {
"self": {
"href": "https://localtest.ddev.site/home/jsonapi?ai%5Bresource%5D=basket&ai%5Bcontroller%5D=Jsonapi&ai%5Baction%5D=get",
"allow": ["DELETE","GET","PATCH","POST"]
}
,
"basket/product": {
"href": "https://localtest.ddev.site/home/jsonapi?ai%5Bresource%5D=basket&ai%5Bid%5D=default&ai%5Brelated%5D=product&ai%5Bcontroller%5D=Jsonapi&ai%5Baction%5D=get",
"allow": ["POST"]
},
"basket/service": {
"href": "https://localtest.ddev.site/home/jsonapi?ai%5Bresource%5D=basket&ai%5Bid%5D=default&ai%5Brelated%5D=service&ai%5Bcontroller%5D=Jsonapi&ai%5Baction%5D=get",
"allow": ["POST"]
},
"basket/address": {
"href": "https://localtest.ddev.site/home/jsonapi?ai%5Bresource%5D=basket&ai%5Bid%5D=default&ai%5Brelated%5D=address&ai%5Bcontroller%5D=Jsonapi&ai%5Baction%5D=get",
"allow": ["POST"]
},
"basket/coupon": {
"href": "https://localtest.ddev.site/home/jsonapi?ai%5Bresource%5D=basket&ai%5Bid%5D=default&ai%5Brelated%5D=coupon&ai%5Bcontroller%5D=Jsonapi&ai%5Baction%5D=get",
"allow": ["POST"]
}

}

,"data": {"id":"default","type":"basket","links":{"self":{"href":"https:\/\/localtest.ddev.site\/home\/jsonapi?ai%5Bresource%5D=basket&ai%5Bid%5D=default&ai%5Bcontroller%5D=Jsonapi&ai%5Baction%5D=get","allow":["DELETE","GET","PATCH","POST"]}},"attributes":{"order.base.id":null,"order.base.sitecode":"","order.base.customerid":"130803","order.base.languageid":"de","order.base.currencyid":"PKT","order.base.price":"10340.00","order.base.costs":"0.00","order.base.rebate":"0.00","order.base.taxvalue":"0.0000","order.base.taxflag":true,"order.base.customerref":"","order.base.comment":""},"relationships":{"basket\/product":{"data":[{"type":"basket\/product","id":0}]}}}
,"included": [{"id":0,"type":"basket\/product","attributes":{"order.base.product.id":null,"order.base.product.price":"10340.00","order.base.product.costs":"0.00","order.base.product.rebate":"0.00","order.base.product.taxrate":"0.00","order.base.product.taxrates":{"":"0.00"},"order.base.product.type":"select","order.base.product.stocktype":"default","order.base.product.suppliercode":"","order.base.product.prodcode":"211099320  BL9","order.base.product.productid":"31251","order.base.product.quantity":1,"order.base.product.name":"Lego Camping Bus T1","order.base.product.description":"","order.base.product.mediaurl":"preview\/0\/3\/03944b837621b5a6d371816acffd87a1.jpg","order.base.product.timeframe":"","order.base.product.position":null,"order.base.product.status":-1,"attribute":[{"order.base.product.attribute.id":null,"order.base.product.attribute.type":"variant","order.base.product.attribute.code":"Modelljahr","order.base.product.attribute.name":"1962","order.base.product.attribute.value":"211099320  BL9","order.base.product.attribute.quantity":1}]},"links":{"self":{"href":"https:\/\/localtest.ddev.site\/home\/jsonapi?ai%5Baction%5D=get&ai%5Bcontroller%5D=Jsonapi&ai%5Bid%5D=default&ai%5Brelated%5D=product&ai%5Brelatedid%5D=0&ai%5Bresource%5D=basket","allow":["DELETE","PATCH"]}}}]

}

User avatar
loeffe1
Posts: 51
Joined: 21 Feb 2020, 10:33

Re: Update mini cart ajax problem

Post by loeffe1 » 02 Mar 2020, 09:52

Ok, I found out this is a problem caused by my template. I might have removed a required class or incorrectly edited some js. With the default template it is working as intended. Sorry for the false alarm.

User avatar
EfdalKadircanYigitoglu
Posts: 1
Joined: 14 Apr 2023, 10:08

Re: Update mini cart ajax problem

Post by EfdalKadircanYigitoglu » 14 Apr 2023, 10:11

Hello,

I have the same issue. Cann you say me, which required class you removed at which js?

Thank You!

Post Reply