久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何觸發(fā)在 magento 中收到的付款事件?

How to trigger an event on payment received in magento?(如何觸發(fā)在 magento 中收到的付款事件?)
本文介紹了如何觸發(fā)在 magento 中收到的付款事件?的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

您好,在 Magento 中,一旦訂單被設(shè)置為處理(通過(guò)網(wǎng)關(guān)確認(rèn)或手動(dòng)),我想觸發(fā)一個(gè)事件,例如:如果普通客戶(id 1)花費(fèi)超過(guò) 100 美元并且付款已被確認(rèn),將他的組ID設(shè)置為4(銀VIP,根據(jù)促銷規(guī)則在全球獲得2%的折扣)我會(huì)為此懸賞,但我希望在 2 天前得到答案 O_o

Greetings, in Magento I want to trigger an event, once an order has been set to processing (by gateway confirmation or manually) that, example: If a general customer (id 1) spends over 100$ and the payment has been confirmed, set his group id to 4 (silver VIP, which by promotion rule gets 2% discount globally) I would give a bounty to this, but I'd like the answer before 2 days O_o

編輯:到目前為止我收到的答案只是部分答案,而且我發(fā)現(xiàn)鏈接非常混亂,我不清楚什么是最小設(shè)置,我必須配置什么創(chuàng)建等...我還試圖找出如何獲得付費(fèi)客戶的 ID/型號(hào).

EDIT: the answer I received so far is only a partial answer, also I find the links very confusing, I'm not clear on what is the minimal setup, what do i have to configure create etc... Also I'm trying to find out how to get the paying customers id/model.

推薦答案

你應(yīng)該從在 app/code/local 中創(chuàng)建你自己的模塊開(kāi)始.例如創(chuàng)建目錄 Moak/Vip.它將成為您模塊的根目錄.

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 知道它存在,在 etc/modules 中創(chuàng)建一個(gè)名為 Moak_Vip.xml 的文件,內(nèi)容如下:

In order for Magento to know it exists, create a file named Moak_Vip.xml in etc/modules, with the following content :

<?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>

然后,在您的模塊目錄中,您需要以下結(jié)構(gòu)和文件:

Then, in your module directory, you need the following structure and files :

  • etc/config.xml
  • 模型/觀察者.php

config.xml 定義您的模塊并聲明給定事件的事件偵聽(tīng)器(checkout_onepage_controller_success_action 在單頁(yè)結(jié)帳過(guò)程完成時(shí)發(fā)送,sales_order_payment_pay 在付款時(shí)發(fā)送已確認(rèn)).

The config.xml defines your module and declares your event listener for a given event (checkout_onepage_controller_success_action is sent when onepage checkout process is complete, sales_order_payment_pay is sent when the payment has been confirmed).

您不需要任何數(shù)據(jù)庫(kù)設(shè)置,因?yàn)槟粫?huì)保存任何新實(shí)體.因此,您的配置文件應(yīng)如下所示:

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>checkVipCustomer</method>
                    </moak_observer>
                </observers>
            </sales_order_payment_pay >     
        </events>
     </global>
</config>

現(xiàn)在,您的觀察者方法 checkVipCustomer 應(yīng)該接收一個(gè)事件對(duì)象,您可以從中檢索有關(guān)訂單、客戶...的所有信息,并執(zhí)行您喜歡的修改.查看 app/code/core/Mage/.../Model/... 中的 Magento 模型類了解如何瀏覽這些對(duì)象.

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.

示例:

<?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;
    }

}

注意我沒(méi)有測(cè)試我在這里寫的任何代碼,所以小心處理!希望它有所幫助,Magento 有一個(gè)艱難的學(xué)習(xí)曲線......祝你好運(yùn)!

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 !

這篇關(guān)于如何觸發(fā)在 magento 中收到的付款事件?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Override Magento Config(覆蓋 Magento 配置)
What would cause a print_r and/or a var_dump to fail debugging a variable?(什么會(huì)導(dǎo)致 print_r 和/或 var_dump 調(diào)試變量失敗?)
How to update custom options programatically in magento?(如何在 magento 中以編程方式更新自定義選項(xiàng)?)
Magento 404 on Admin Page(管理頁(yè)面上的 Magento 404)
Magento - get price rules from order(Magento - 從訂單中獲取價(jià)格規(guī)則)
Magento Change Product Page Titles to Include Attributes(Magento 更改產(chǎn)品頁(yè)面標(biāo)題以包含屬性)
主站蜘蛛池模板: 91精品国产91久久综合桃花 | 81精品国产乱码久久久久久 | 日韩一区在线播放 | 视频在线h | 久久精品二区亚洲w码 | 国产欧美精品区一区二区三区 | 国产成人在线看 | 国产区精品在线观看 | 国产成人av一区二区三区 | 免费在线国产视频 | 日韩av成人在线 | 国产欧美日韩精品一区 | 黄篇网址| 成人在线免费观看视频 | 91久久精品国产91久久性色tv | 精品不卡| 盗摄精品av一区二区三区 | 福利社午夜影院 | 日日艹夜夜艹 | 亚洲一区二区中文字幕 | 国产黄色在线 | 欧美一区视频 | 成人妇女免费播放久久久 | 请别相信他免费喜剧电影在线观看 | 国产免费av在线 | 国产日产精品一区二区三区四区 | 精品影院 | 亚洲一区二区免费 | 亚洲天堂网站 | 五月花丁香婷婷 | 国产美女精品视频 | 色综合激情| 久久高清国产视频 | 亚洲a视频 | 国产免费一区二区三区免费视频 | 中文字幕一区二区三区在线观看 | 久久久久久国产精品免费 | 婷婷综合久久 | 成人影视网址 | 国产一区二区三区免费观看视频 | 久久久久久高潮国产精品视 |