/** * [hookToControllerActionPostDispatch description] * @param [type] $observer [description] * @return [type] [description] */ public function hookToControllerActionPostDispatch($observer) { //var_dump($observer->getEvent()->getControllerAction()->getFullActionName() ); exit; // echo '<pre>';print_r($observer->getEvent()->getControllerAction()->getFullActionName());exit; $token = $this->getToken(); // echo '<pre>';print_r($token);exit; //$token =1; if ($token) { $action = $observer->getEvent()->getControllerAction()->getFullActionName(); $request = array('request' => $observer->getControllerAction()->getRequest()); //we compare action name to see if that's action for which we want to add our own event if ('checkout_cart_add' == $action) { //We are dispatching our own event before action ADD is run and sending parameters we need Mage::dispatchEvent("add_to_cart_after", $request); } else { if (in_array($action, array('checkout_cart_updatePost', 'checkout_cart_updateItemOptions'))) { //We are dispatching our own event after action Update is run and sending parameters we need Mage::dispatchEvent("update_cart_after", $request); } else { if ('catalogsearch_result_index' == $action) { //We are dispatching our own event after action Search is run and sending parameters we need Mage::dispatchEvent("search_after", $request); } else { if ('checkout_onepage_savePayment' == $action) { Mage::dispatchEvent("save_payment_after", $request); } else { if ('checkout_cart_couponPost' == $action) { Mage::dispatchEvent("discount_code_after", $request); } else { if ('checkout_onepage_saveShipping' == $action) { Mage::dispatchEvent("save_shipping_after", $request); } else { if ('checkout_onepage_saveBilling' == $action) { Mage::dispatchEvent("save_billing_after", $request); } else { if ('checkout_onepage_controller_success_action' == $action) { Mage::dispatchEvent('checkout_onepage_controller_success_action', array('order_ids' => array($lastOrderId))); } } } } } } } } } }
/** * Save Delivery data to quote after save * * @param [type] $observer [description] * @return [type] [description] */ public function quoteSaveAfter($observer) { $postData = $_POST; if (isset($postData['shipping_method'])) { $shipping_method = $postData['shipping_method']; //dpd_ps $method = Mage::getModel('dpd/carrier')->getMethod($shipping_method); //ps if (Mage::getModel('dpd/carrier')->getModelClass($method) !== false) { $parameters = Mage::getModel('dpd/carrier')->collectParams($method, $postData); $quote = Mage::getModel('sales/quote')->loadByIdWithoutStore($observer->getEvent()->getDataObject()->getData('entity_id')); if ($quote->getDpdDeliveryOptions() != serialize($parameters)) { $quote->setDpdDeliveryOptions(serialize($parameters)); $quote->save(); } } } }
/** * TODO: This method is very incomplete. Needs alternate payment methods. * * @param [type] $observer [description] * @return [type] [description] */ public function payment_save_after_hook($observer) { // See code/core/Mage/Sales/Model/Order/Payment.php for this object's methods. $paymentObject = $observer->getEvent()->getDataObject(); // TODO: This logic is weak; if cc_exp_month isn't set, then it's // Check/Money Order, or something else. if ($paymentObject->getCcExpMonth() == 0) { $this->setPaymentType('$third_party_processor'); } $cardLast4 = $paymentObject->getCcLast4(); if (!empty($cardLast4)) { $this->setCardLast4($cardLast4); $this->setPaymentType('$credit_card'); $cardAvs = $paymentObject->getCcAvsStatus(); if (!empty($cardAvs)) { $this->setCardAvs($cardAvs); } } return $observer; }