You should start by creating your own module in app/code/local.
Create for example the directories Moak/Vip. It will be the root of your module.
Magento var biliyorum için için, aşağıdaki içerikle, etc / modüller Moak_Vip.xml adlı bir dosya oluşturun:
<?xml version="1.0"?>
<config>
<modules>
<Moak_Vip>
<active>true</active>
<codePool>local</codePool>
<self_name>Moak VIP module</self_name>
</Moak_Vip >
</modules>
</config>
Ardından, modül dizininde, aşağıdaki yapıyı ve dosyalar gerekir:
- etc / config.xml
- Model / Observer.php
Config.xml Modülünüzü tanımlayan ve belirli bir olay (onepage ödeme işlemi tamamlandığında checkout_onepage_controller_success_action
ödeme teyit edildiğinde sales_order_payment_pay
gönderilir, gönderilen) için olay dinleyicisi bildirir.
You don't need any DB setup since you will not save any new entity.
So your config file should look something like the following :
<?xml version="1.0"?>
<config>
<modules>
<Moak_Vip>
<version>0.1.0</version>
</Moak_Vip>
</modules>
<global>
<models>
<moak>
<class>Moak_Vip_Model</class>
</moak>
</models>
<events>
<sales_order_payment_pay>
<observers>
<moak_observer>
<type>singleton</type>
<class>moak/observer</class>
<method>computeExpirationDate</method>
</moak_observer>
</observers>
</sales_order_payment_pay >
</events>
</global>
</config>
Now, your Observer method checkVipCustomer
should receive an event object from which you can retrieve all information about the order, the customer... and perform the modifications you like.
Have a look at Magento model classes in app/code/core/Mage/.../Model/...
to see how to navigate through those objects.
Örnek:
<?php
class Moak_Vip_Model_Observer
{
public function checkVipCustomer($event)
{
$order = $event->getInvoice()->getOrder(); // Mage_Sales_Model_Order
/*
- Check order amount
- Get customer object
- Set Group id
- $customer->save();
*/
return $this;
}
}
Note I've not tested any of the code I wrote here, so handle with care !
Hope it helped, Magento has a hard learning curve...
Good luck !