Magento – Dynamic price calculation for product

price

I'm completely new to magento and i've read some threads in this forum but i'm not quite sure whether my solution is correct.

I have a product which can change its price depending on the customers choice. for example customer can choose how many square meters of the product he wants to buy. Depending on that choice the price has to be recalculated and should be displayed immediately.

This is done via ajax call to my customized controller which overrides the "Mage_Core_Controller_Front_Action"

Second, i have registered an observer for the "catalog_product_get_final_price" event. This observer overrides the final price in the product with my own calculated final price.

My questions now are:

  1. Is this the best possible solution for this problem?
  2. Are there any problems with this solution? Did i miss something very important?
  3. What do i have to test?

Best Answer

I think there is a far better possibility to implement this:

You implement everything client side with "a few lines of JavaScript" (you know what I mean) to calculate the price,based on the square meter.

The square meter is implemented as custom option.

And server side, you hook into some event, I would try checkout_cart_product_add_after to set the price on the quote item. This way you don't have any rewrites, which is highly recommended and you don't need any AJAX-Request to get the price.

Related Topic