1

Does anyone know how to make a product with not fixed price?

By default the product price is $1. But it can be changed by user dragging a price product slider (the product is a donation product).

So how to implement that? How to give an ability for the user to change the product price?

I was thinking about the configurable product with attribute set but I'm not sure that it's really elegant way to do so.

Thank you in advance!

5

2 Answers 2

1

The easiest way I can think of is to create a product in magento to use as a template.

Then create a observer

<events>
    <sales_quote_add_item>
        <observers>
            <priceupdate_observer>
                <type>singleton</type>
                <class>mymodule/observer</class>
                <method>updatePrice</method>
            </priceupdate_observer>
        </observers>
    </sales_quote_add_item>
</events>

Then in your observer method you does something like this:

public function updatePrice($observer) {
    $event = $observer->getEvent();
    $quote_item = $event->getQuoteItem();
    $new_price = <insert logic to check if this is the custom product and to get value from ajax>
    $quote_item->setOriginalCustomPrice($new_price);
    $quote_item->save();
}

(note that a user could always fake the post and change the item price)

See Customize Magento using Event/Observer

0

I would use a custom option for that, with 100(?) options, each in 1$ steps (or maybe higher steps later).

Than you can implement a slider, write some JS to change the select box for the custom option, hide it and finished.

1
  • Is it really elegant solution if I need $10 000 maximum price? I don't think so that creating 10 000 options would be great idea. Commented Sep 25, 2014 at 19:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.