Add price after pressing "add to basket" button
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!
Re: Add price after pressing "add to basket" button
The parameters are read-only. You have to retrieve all, change the one you need and setup the view helper again:
Code: Select all
$params = $view->param();
$params['b_prod'] = [/* modified array */];
$view->addHelper( 'param', new \Aimeos\MW\View\Helper\Param\Standard( $view, $params );
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
-
- Posts: 44
- Joined: 24 Jun 2019, 14:46
Re: Add price after pressing "add to basket" button
Sorry I have another question:
how can I clone the product and change the price of it?
I have the product
Now what I have to do?
Thank you very much
how can I clone the product and change the price of it?
I have the product
Code: Select all
$params = $view->param();
$productManager = \Aimeos\MShop::create( $context, 'product' );
$item = $productManager->getItem( $params['b_prod'][0]['prodid'], ['media', 'price', 'text'] );
Thank you very much
Re: Add price after pressing "add to basket" button
Code: Select all
$priceManager = \Aimeos\MShop::create( $context, 'price' );
$productManager = \Aimeos\MShop::create( $context, 'product' );
$item = $productManager->getItem( $view->param( 'b_prod/0/prodid' ), ['media', 'price', 'text'] );
$listItem = $productManager->createListItem()->setType( 'default' );
$priceItem = $priceManager->createItem()->setType( 'default' )->setCurrencyId( 'EUR' );
$item->addListItem( 'price', $listItem, $refItem );
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
-
- Posts: 44
- Joined: 24 Jun 2019, 14:46
Re: Add price after pressing "add to basket" button
I got this error:
EDIT: the function is createListsItem not createListItem
Code: Select all
Aimeos \ MShop \ Exception
Unable to call method "createListItem"
-
- Posts: 44
- Joined: 24 Jun 2019, 14:46
Re: Add price after pressing "add to basket" button
I got another error:
EDIT: the function is SetCurrencyId
Code: Select all
Call to undefined method Aimeos\MShop\Price\Item\Standard::setCurrency()
-
- Posts: 44
- Joined: 24 Jun 2019, 14:46
Re: Add price after pressing "add to basket" button
Hi,
I created the decorator. I tried to clone the product and sending the new ID to the AddProduct function. The product is in the db correctly but I am getting an error.
I wrote this code:
I am getting this error:
The ID "95" is the new product. Why I am getting this error?
I created the decorator. I tried to clone the product and sending the new ID to the AddProduct function. The product is in the db correctly but I am getting an error.
I wrote this code:
Code: Select all
$priceManager = \Aimeos\MShop::create( $context, 'price' );
$productManager = \Aimeos\MShop::create( $context, 'product' );
$mediaManager = \Aimeos\MShop::create( $context, 'media' );
$item = $productManager->getItem( $view->param( 'b_prod/0/prodid' ), ['media', 'price', 'text']);
$listItem = $productManager->createListsItem()->setType( 'default' );
$priceItem = $priceManager->createItem()->setType( 'default' )->setCurrencyId( 'EUR' )->setValue(5);
$mediaItem = $item->getRefItems('media', 'default');
$mediaItem = array_values($mediaItem)[0];
$clone_item = $productManager->createItem();
$clone_item->addListItem( 'price', $listItem, $priceItem);
$clone_item->addListItem( 'media', $listItem, $mediaItem);
$productManager->saveItem($clone_item);
$tmp = $clone_item->toArray();
$params['b_prod'] = [["prodid"=> $tmp["product.id"], "quantity"=>"1"]];
$view->addHelper( 'param', new \Aimeos\MW\View\Helper\Param\Standard( $view, $params ));
Code: Select all
Adding product with ID "95" is not allowed
Re: Add price after pressing "add to basket" button
Your product has no category assigned and that's required when using the basket frontend controller.
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
-
- Posts: 44
- Joined: 24 Jun 2019, 14:46
Re: Add price after pressing "add to basket" button
How can I assign it?
(it must be the same as the original)
(it must be the same as the original)
-
- Posts: 44
- Joined: 24 Jun 2019, 14:46
Re: Add price after pressing "add to basket" button
i also wrote this:
but I got basket empty
Seems like the file ext/ai-client-html/client/html/src/Client/Html/Basket/Standard/Standard.php is not getting the product in the line
Code: Select all
$clone_item->addListItem( 'catalog', $listItem, $catalogManager->getItem(1));
Seems like the file ext/ai-client-html/client/html/src/Client/Html/Basket/Standard/Standard.php is not getting the product in the line
Code: Select all
// the list has the right ID
$products = $productCntl->product( $list )->slice( 0, count( $list ) )->search();
Re: Add price after pressing "add to basket" button
You have to create the product in the backend first and can't create a product on the fly. There are dependencies that require the product in the database.
Alternatively, if all your products can be bought, you can remove the Category frontend basket decorator:
https://aimeos.org/docs/Configuration/C ... tors/local
Alternatively, if all your products can be bought, you can remove the Category frontend basket decorator:
https://aimeos.org/docs/Configuration/C ... tors/local
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