Page 1 of 1

Can't delete product through ajax

Posted: 26 Jan 2018, 10:24
by qvotaxon
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)

Re: Can't delete product through ajax

Posted: 26 Jan 2018, 16:27
by aimeos
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.