how to implement dynamic calculating price in magento based on weight ?

我与影子孤独终老i 提交于 2020-01-04 06:04:38

问题


Hi i’m developing a eCommerce site in Magento for jewellery business and its based on a “weight”, not the price because gold rate is changing in day by day or more then 3 times in a day.So it is not possible to change the product price every time according to gold rate. Then, how to manage the prices on this scenario?

Example case: Today I have added a 18K gold ring of 10gm to my site and right now gold rate is Rs30,000 per 10gm, so today price of this ring is Rs30,000 but, Next day the rate will be changed (Rs32,000 per 10gm) then, my product price must be changed from Rs30,000 to Rs32,000.

This is not possible to update the price of all products every time. I am using Magento platform. Please, Share your idea regarding this situation.


回答1:


To make this simple, you should work on a 2 ways solutions.

In the frontend, do not show price ($_product->getPrice()) but just show the real price according to weight.

Example if you have price/grm stored in the backend use $product->getWeight * Mage::getStoreConfig('mycompany/gold/dayprice').

That way price will be shown dynamically in the product page or list page.

Now you should use an Observer on the add to cart event to change the price to the good one.

This way, don't matter what price is set on the product because showing and adding will use the formulae.



来源:https://stackoverflow.com/questions/20801596/how-to-implement-dynamic-calculating-price-in-magento-based-on-weight

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!