Interacting with the Basket
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!
Interacting with the Basket
Based on how we built our custom frontend, we are looking to process a number of rows sent from the client and then add / update / delete each one in the basket.
I have been able to create an empty basket and then add a product BUT it doesn't save from call to call which tells me that I've missed a critical step. The controller method should be returning a JSON object with the updated basket.
We are using 2024.04.1 and Php 8.3
I also don't see the basket getting created in the mshop_order_basket table.
My overall goal is to do the following from within a controller:
Thanks!
I have been able to create an empty basket and then add a product BUT it doesn't save from call to call which tells me that I've missed a critical step. The controller method should be returning a JSON object with the updated basket.
We are using 2024.04.1 and Php 8.3
Code: Select all
$context = app('aimeos.context')->get(true);
$controller = new \Aimeos\Controller\Frontend\Basket\Standard($context);
$include = ['basket/address', 'basket/coupon', 'basket/product'];
$basket = $controller->get()->setCustomerId($context->user());
Log::debug('created basket: ' . json_encode($basket));
$product = MShop::create($context, 'product')->get('7', ['text', 'media', 'price']);
$orderProduct = MShop::create($context, 'order/product')->create();
$orderProduct->copyFrom($product);
$basket->addProduct($orderProduct, 0);
return response(json_encode($basket));
My overall goal is to do the following from within a controller:
- Get the basket from the user's session and create one if it doesn't exist
- add / update / remove products based on what is passed into the controller
- "save" the basket so it is ready for check out
Thanks!
Re: Interacting with the Basket
Call the save() method to store the updated basket:
https://github.com/aimeos/ai-controller ... hp#L45-L50
https://github.com/aimeos/ai-controller ... hp#L45-L50
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,

Re: Interacting with the Basket
Thanks! Do you have any example code of adding attributes (custom or otherwise) to the product in the basket?
Re: Interacting with the Basket
See here:
- https://github.com/aimeos/ai-controller ... #L461-L477
- https://github.com/aimeos/ai-controller ... #L342-L352
Use these methods:
- https://github.com/aimeos/aimeos-core/b ... hp#L24-L30
- https://github.com/aimeos/aimeos-core/b ... /Iface.php
- https://github.com/aimeos/aimeos-core/b ... #L442-L456
- https://github.com/aimeos/ai-controller ... #L461-L477
- https://github.com/aimeos/ai-controller ... #L342-L352
Use these methods:
- https://github.com/aimeos/aimeos-core/b ... hp#L24-L30
- https://github.com/aimeos/aimeos-core/b ... /Iface.php
- https://github.com/aimeos/aimeos-core/b ... #L442-L456
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,
