Add price after pressing "add to basket" button

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!
lucadambros
Posts: 44
Joined: 24 Jun 2019, 14:46

Add price after pressing "add to basket" button

Post by lucadambros » 22 Aug 2019, 08:01

Hi,
I have a product without a price. How can I add the price after pressing the "add to basket" button?

Thank you very much

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

Re: Add price after pressing "add to basket" button

Post by aimeos » 22 Aug 2019, 08:13

What's your use case?
Aimeos contains a custom price attribute where customers can enter an arbitrary price, e.g. when buying vouchers and the price is added to the basket product then
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

lucadambros
Posts: 44
Joined: 24 Jun 2019, 14:46

Re: Add price after pressing "add to basket" button

Post by lucadambros » 22 Aug 2019, 08:30

Use case:

The product can have a strange type of calculation of the price that depends on external factors like the betting system or something like creation of gadgets.

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

Re: Add price after pressing "add to basket" button

Post by aimeos » 22 Aug 2019, 09:08

Write a decorator for the basket frontend controller, that calculates the price and adds it to the product item:
https://github.com/aimeos/ai-controller ... /Decorator
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

lucadambros
Posts: 44
Joined: 24 Jun 2019, 14:46

Re: Add price after pressing "add to basket" button

Post by lucadambros » 22 Aug 2019, 09:12

What happens if another user adds the same product but has a different price?

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

Re: Add price after pressing "add to basket" button

Post by aimeos » 22 Aug 2019, 09:15

What happens in your decorator and how the prices are calculated is totally up to you (and your external factors).

If you have configurable products (with additonal options that have an additional price), you can also assign one or more config attributes with own prices to the product. Customers can then choose the options they want and the total price of the product is calculated automatically.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

lucadambros
Posts: 44
Joined: 24 Jun 2019, 14:46

Re: Add price after pressing "add to basket" button

Post by lucadambros » 22 Aug 2019, 09:36

aimeos wrote: 22 Aug 2019, 09:15 If you have configurable products (with additonal options that have an additional price), you can also assign one or more config attributes with own prices to the product. Customers can then choose the options they want and the total price of the product is calculated automatically.
I know that but i don't have configurable products.

Creating an identical product with the price I calculate while adding it into the basket, can be a solution?

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

Re: Add price after pressing "add to basket" button

Post by aimeos » 22 Aug 2019, 09:40

lucadambros wrote: 22 Aug 2019, 09:36 Creating an identical product with the price I calculate while adding it into the basket, can be a solution?
Sure, the basket decorator will be your friend in that case :-)
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

lucadambros
Posts: 44
Joined: 24 Jun 2019, 14:46

Re: Add price after pressing "add to basket" button

Post by lucadambros » 22 Aug 2019, 09:51

Thank you very much!

lucadambros
Posts: 44
Joined: 24 Jun 2019, 14:46

Re: Add price after pressing "add to basket" button

Post by lucadambros » 22 Aug 2019, 13:39

Last question: how can I change the value of a param into the decorator?

I have the array

Code: Select all

$view->param( 'b_prod' );
How can I change the value of that?

Post Reply