Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Change product price when product click on Add To Cart Button for simple product
 
Jignesh Chauhan
Sr. Member
 
Total Posts:  176
Joined:  2009-12-23
 

Hello everyone,

I am working on jewelry site and i have created custom product view page.

Please have a look at below page.

On this page i have done customization currently i have added ajax feature to update the product price.

So some one can please let me know what should i do in this case to work site in normal way.

Thanks,
Jignesh

 
Magento Community Magento Community
Magento Community
Magento Community
 
dipen_vichhi
Jr. Member
 
Total Posts:  21
Joined:  2011-07-28
 

Hello JigneshBhai,

Below is the solution for you problem.

Use the following event in you config.xml
<events>
<checkout_cart_product_add_after>
<observers>
<provide name>
<type>singleton</type>
<class>Test_Testing_Model_Cart_Observer</class>
<method>calculateAddToCart</method>
</provide name>
</observers>
</checkout_cart_product_add_after>
</events>

and create the observer for this with the following content.

public function calculateAddToCart($observer){
$customPrice = Mage::getSingleton(’core/session’)->getCustomPriceCalcuation(); // Provide you price i have set with session
$p = $observer->getQuoteItem();
$p->setCustomPrice($customPrice)->setOriginalCustomPrice($customPrice);
}

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top