Can't delete product through ajax

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
qvotaxon
Posts: 10
Joined: 21 Dec 2017, 18:11

Can't delete product through ajax

Post by qvotaxon » 26 Jan 2018, 10:24

Good day!

I'm having some trouble getting the remove product ajax/jsonapi functionality to work. I did some debugging and came to the strange conclusion that adding a product works fine. After adding the product the output of $this->get()->getProducts() (in ext\ai-controller-frontend\controller\frontend\src\Controller\Frontend\Basket\Standard.php on line 237) is as expected, it contains the added product. I can also remove the product using $this->get()->removeProduct(0);. However, when I use the standard javaScript function bound to the mini basket remove button, I get an exception: "Product with array key "0" not available". Doing some further debugging, I found out that $this->get()->getProducts() returns an empty array in the deleteProduct function (in ext\ai-controller-frontend\controller\frontend\src\Controller\Frontend\Basket\Standard.php on line 245).

I can however remove products if I don't use the javascript function and call the url /basket?b_action=delete&b_position=0 directly. I'm pretty much starting to run out of ideas as to where the problem may lay.

Many thanks in advance!

My installation details:

- Aimeos 2017.10 (latest via composer)
- Laravel 5.5.*
- PHP 7.1
- Linux (Ubuntu 16.04.1)
<3 Aimeos

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

Re: Can't delete product through ajax

Post by aimeos » 26 Jan 2018, 16:27

You can have a look at the mini basket and how it's made there. Maybe you use an old position value (they are not always begin with zero) or an old CSRF token.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply