Can't delete product through ajax
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!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Can't delete product through ajax
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)
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
Re: Can't delete product through ajax
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, give us a star
If you like Aimeos, give us a star