6

I am trying something for a social cause website where there are trying to provide a user choice price for a NGO's product which can be any price. this is for promotional activity where user can set the any price for product.

closed as too broad by 7ochem, mbalparda, Marius Jun 30 '15 at 19:43

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

3

Yes, it is possible, this blog post (German) uses exactly this as a simplified example for dynamic pricing: http://www.avs-webentwicklung.de/nc/blog/artikel/magento-umsetzung-von-flexiblen-preisen.html

Summary:

  1. Add an input field "price" to the form on the product page.
  2. Create a custom module with an observer for catalog_product_get_final_price:

    <events>
        <catalog_product_get_final_price>
            <observers>
                <modulename_catalog_product_get_final_price>
                    <type>singleton</type>
                    <class>Namespace_Modulename_Model_Observer</class>
                    <method>getFinalPrice</method>
                </modulename_catalog_product_get_final_price>
            </observers>
        </catalog_product_get_final_price>
    </events>
    
  3. In the observer, set the final price based on the request:

    /**
     * Update price for product items
     *
     * @param Varien_Event_Observer $observer
     */
    public function getFinalPrice($observer) {
    
        /* @var Mage_Catalog_Model_Product $product */
        $product = $observer->getEvent()->getProduct();
    
        if ($buyRequest = $product->getCustomOption('info_buyRequest')) {
    
            $buyRequest = unserialize($buyRequest->getValue());
    
            if (is_array($buyRequest) && isset($buyRequest['price'])) {
    
                $product->setFinalPrice(floatval($buyRequest['price']));
            }
        }
    }
    

(this example does not validate the price to be greater than zero, I'll leave that part as an exercise to the reader)

1

You even don't need coding. Depending on the range of chooseable prices, you can just use custom options with a price.

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