cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 1.9 - How to do Observer should be trigger before place an order?

Magento 1.9 - How to do Observer should be trigger before place an order?

After calculated grand total in checkout page observer not trigger,

 

one-1.png

 

Observer :

 

app\etc\modules\Gta_RestrictProductByCountry.xml

 

 

<?xml version="1.0"?>

<config>

	<modules>

		<Gta_RestrictProductByCountry>

			<codePool>local</codePool>
			<active>false</active>

		</Gta_RestrictProductByCountry>

	</modules>

</config>

 

app\code\local\Gta\RestrictProductByCountry\etc\config.xml

 

<?xml version="1.0"?>
<config>
    <modules>
        <Gta_RestrictProductByCountry>
            <version>1.0.0</version>
        </Gta_RestrictProductByCountry>
    </modules>
    <global> 
        <models>
            <gta_restrictproductbycountry>
                <class>Gta_RestrictProductByCountry_Model</class>
            </gta_restrictproductbycountry>
        </models> 
    <frontend>
        <events>
            <sales_order_place_before>
                <observers>
                    <Gta_RestrictProductByCountry_Observer>   
                        <type>singleton</type>
                        <class>Gta_RestrictProductByCountry_Observer</class>
                        <method>cartevent</method>
                    </Gta_RestrictProductByCountry_Observer>
                </observers>
            </sales_order_place_before>      
        </events>
    </frontend>
    </global>   
</config>

app\code\local\Gta\RestrictProductByCountry\Model\Observer.php

 

<?php
class Gta_RestrictProductByCountry_Observer
{
    public function cartevent($Observer)
    {
        // $order = $Observer->getEvent();
        // $shipping = $order->getShippingAddress()->getShippingMethod();
        // Mage::log($shipping->getName(),null,'event.log');

        $cart_product_check = $Observer->getEvent();
        Mage::log($cart_product_check->getName(), null, 'shipping_country_not_matching.log');
    }
}