Update mini cart ajax problem
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!
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Update mini cart ajax problem
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
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
Re: Update mini cart ajax problem
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, give us a star
If you like Aimeos, give us a star
Re: Update mini cart ajax problem
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.
I have set the page of the json api in the content element settings, so that's not the cause of the problem.
Re: Update mini cart ajax problem
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, give us a star
If you like Aimeos, give us a star
Re: Update mini cart ajax problem
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"]}}}]
}
Re: Update mini cart ajax problem
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.
- EfdalKadircanYigitoglu
- Posts: 1
- Joined: 14 Apr 2023, 10:08
Re: Update mini cart ajax problem
Hello,
I have the same issue. Cann you say me, which required class you removed at which js?
Thank You!
I have the same issue. Cann you say me, which required class you removed at which js?
Thank You!