In local folder your extension file create etc, Helper and Modal folder.

  1. In the first step create etc folder which contain “config.xml” file with the below code.

<?xml version=”1.0″?>

<config>

<modules>

<WebeTutorial_ExtraOptions>

<version>0.1.0</version>

</WebeTutorial_ExtraOptions>

</modules>

<global>

<helpers>

<extraoptions>

<class>WebeTutorial_ExtraOptions_Helper</class>

</extraoptions>

</helpers>

<models>

<extraoptions>

<class>WebeTutorial_ExtraOptions_Model</class>

<resourceModel>extraoptions_mysql4</resourceModel>

</extraoptions>

</models>

<events>

<catalog_product_load_after> <!– identifier of the event we want to catch –>

<observers>

<catalog_product_load_after_handler> <!– identifier of the event handler –>

<type>model</type> <!– class method call type; valid are model, object and singleton –>

<class>extraoptions/observer</class> <!– observers class alias –>

<method>catalogProductLoadAfter</method>  <!– observer’s method to be called –>

<args></args> <!– additional arguments passed to observer –>

</catalog_product_load_after_handler>

</observers>

</catalog_product_load_after>

<sales_convert_quote_item_to_order_item> <!– identifier of the event we want to catch –>

<observers>

<sales_convert_quote_item_to_order_item_handler> <!– identifier of the event handler –>

<type>model</type> <!– class method call type; valid are model, object and singleton –>

<class>extraoptions/observer</class> <!– observers class alias –>

<method>salesConvertQuoteItemToOrderItem</method>  <!– observer’s method to be called –>

<args></args> <!– additional arguments passed to observer –>

</sales_convert_quote_item_to_order_item_handler>

</observers>

</sales_convert_quote_item_to_order_item>

<checkout_cart_product_add_after> <!– identifier of the event we want to catch –>

<observers>

<checkout_cart_product_add_after_handler> <!– identifier of the event handler –>

<type>singleton</type> <!– class method call type; valid are model, object and singleton –>

<class>extraoptions/observer</class> <!– observers class alias –>

<method>checkoutCartProductAddAfter</method>  <!– observer’s method to be called –>

<args></args> <!– additional arguments passed to observer –>

</checkout_cart_product_add_after_handler>

</observers>

</checkout_cart_product_add_after>

</events>

</global>

</config>

  1. In the second step create Helper folder with “Data.php” file with the code below.

<?php

class WebeTutorial_ExtraOptions_Helper_Data extends Mage_Core_Helper_Abstract

{

}

 

  1. In the third step create Model folder with “Cart.php” and “Observer.php” file name and add below codes in respective file.

Cart.php:-

<?php

class Foo_Bar_Model_Checkout_Cart extends Mage_Checkout_Model_Cart

{

/**

* Create checkout_cart_product_add_before event observer

*

* @param   int|Mage_Catalog_Model_Product $productInfo

* @param   mixed $requestInfo

* @return  Mage_Checkout_Model_Cart

*/

public function addProduct($productInfo, $requestInfo=null)

{

$product = $this->_getProduct($productInfo);

Mage::dispatchEvent(‘checkout_cart_product_add_before’, array(‘product’ => $product));

 

return parent::addProduct($productInfo, $requestInfo=null);

}

}

Observer.php:-

<?php

class WebeTutorial_ExtraOptions_Model_Observer

{

public function checkoutCartProductAddAfter(Varien_Event_Observer $observer)

{

$action = Mage::app()->getFrontController()->getAction();

$extra_data = $action->getRequest()->getPost();

//echo “<pre>”;

//print_r($extra_data); die;

// Here you can add your custom price in respective array.

}

}

Please login or Register to submit your answer
Not the answer you are looking for? Browse other questions tagged or ask your own question.