問(wèn)題描述
我正在嘗試在訂單創(chuàng)建后調(diào)用觀察員,并在付款后被捕獲.到目前為止,我已經(jīng)嘗試過(guò);checkout_submit_all_after,sales_order_payment_place_end,sales_order_place_after,sales_order_payment_pay,sales_order_payment_capture,sales_order_payment_transaction_save_after
Im trying to call an Observer after the order has been created, and AFTER payment has been captured. So far I've tried; checkout_submit_all_after, sales_order_payment_place_end, sales_order_place_after, sales_order_payment_pay, sales_order_payment_capture, sales_order_payment_transaction_save_after
只是列舉主要的.我還在 dispatchEvent() 中記錄了所有事件調(diào)度,但沒(méi)有發(fā)現(xiàn)任何突出的東西,只有在我需要它時(shí)才會(huì)被觸發(fā).我遇到的問(wèn)題是訂單的狀態(tài)始終是付款待處理"或在此之前的狀態(tài);這意味著我不知道訂單會(huì)失敗還是成功.
Just to name the main ones. I've also logged all Event Dispaches inside dispatchEvent() but found nothing that stands out and is only fired when i need it. the issue i'm having is that the status of the order is always ether 'Payment Pending' or something that predated this; meaning that i don't know whether the order will fail or succeed.
我的目標(biāo)是僅在成功的訂單上觸發(fā)一個(gè)函數(shù).謝謝.
My aim, is to fire a function only on successful orders. thanks.
推薦答案
經(jīng)過(guò)多次測(cè)試,我發(fā)現(xiàn)以下 Observer 可以解決問(wèn)題;
after much more testing i found the following Observer to do the trick;
checkout_onepage_controller_success_action
這僅返回訂單 ID,所以;
This returns just the order id, so;
$order_id = $observer->getData('order_ids');
$order = Mage::getModel('sales/order')->load($order_id);
并且您看到訂單狀態(tài)為處理中"并且付款已批準(zhǔn)(或未批準(zhǔn)).
and you see that the order status is 'processing' and the payment is aproved (or not).
這篇關(guān)于在付款捕獲后調(diào)用 Magento 事件觀察器的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!