Set the price for an item from a textfield // Variable Price

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
ltwmaster
Posts: 10
Joined: 01 Apr 2017, 20:39

Set the price for an item from a textfield // Variable Price

Post by ltwmaster » 01 Apr 2017, 20:45

Hey Girls and Guys,

following question, you may respond in german if its easier for your:
I want to have an item which has a variable price. I'm selling physical vouchers. Customers should be able to purchase the voucher at any value they want. eg. 55,55€.

My approach would be to price the voucher at 0,01€ and do some easy Javascript magic with the quantityfield. So for example if they enter 55,55€ to translate that in to 5555 in to the quantity.

Any better ideas than this workaround?

Cheers,
LTW

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

Re: Set the price for an item from a textfield // Variable P

Post by aimeos » 02 Apr 2017, 16:52

This way, you would have the problem that you need to adapt the templates where the basket/order data is shown to avoid quantities of "5555" and values of "0.01" which might be confusing to customers.

Another way would be to create a new product type (e.g. "voucher") and implement a new decorator for the basket frontend controller like done for bundles: https://github.com/aimeos/ai-controller ... Bundle.php

You can assign a custom attribute to the voucher product which displays an input field and set the price of the product in your new decorator to that value. Only the ProductPrice basket plugin couldn't be used in that setup because it would reset the price value.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

ltwmaster
Posts: 10
Joined: 01 Apr 2017, 20:39

Re: Set the price for an item from a textfield // Variable P

Post by ltwmaster » 03 Apr 2017, 16:34

Hi Aimeos,

thank you for the quick reply. I'll try that and come back to you incase I have questions, but your answer is very straight forward!

Cheers,
LTW

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

Re: Set the price for an item from a textfield // Variable P

Post by aimeos » 03 Apr 2017, 20:57

If you are successful, we would love to get a pull request of what you've implemented :-)
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

ltwmaster
Posts: 10
Joined: 01 Apr 2017, 20:39

Re: Set the price for an item from a textfield // Variable P

Post by ltwmaster » 15 May 2017, 12:23

Hi Guys,

its me again :)

I'm a bit stuck on the logic of this case:
So I introduce a new product type called "voucher" and this one uses a specific decorator, like in the example for bundles that you have posted above...

Is this also used on the Invoice? In the E-Mails?

Is there really no way to have a variable price? :)

Thank you

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

Re: Set the price for an item from a textfield // Variable P

Post by aimeos » 15 May 2017, 22:18

The "voucher" decorator has to do the same as the implementation for the simple articles, which are only a few lines of code. The only difference to simple articles is that it will set the price according to the given value from the user (including some checks that it isn't negative for example).

At the end, the product is a simple article and displaying the price in the checkout process and the e-mails will be automatically correct.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply