問題描述
我正在嘗試在訂單創建后調用觀察員,并在付款后被捕獲.到目前為止,我已經嘗試過;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() 中記錄了所有事件調度,但沒有發現任何突出的東西,只有在我需要它時才會被觸發.我遇到的問題是訂單的狀態始終是付款待處理"或在此之前的狀態;這意味著我不知道訂單會失敗還是成功.
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.
我的目標是僅在成功的訂單上觸發一個函數.謝謝.
My aim, is to fire a function only on successful orders. thanks.
推薦答案
經過多次測試,我發現以下 Observer 可以解決問題;
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);
并且您看到訂單狀態為處理中"并且付款已批準(或未批準).
and you see that the order status is 'processing' and the payment is aproved (or not).
這篇關于在付款捕獲后調用 Magento 事件觀察器的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!