我检查订单时,某些订单有问题。当我看到订单的详细信息订单和订单历史记录之间的时间不同。
公共函数savePostAction() {
$helper = Mage::helper('checkout'); $quote = Mage::getSingleton('checkout/session')->getQuote(); $updateItems = array(); $previousData = $this->getRequest()->getPost(); if (!Mage::helper('customer')->isLoggedIn()) { if ($helper->isAllowedGuestCheckout($quote)) { $quote->setCheckoutMethod(Mage_Checkout_Model_Type_Onepage::METHOD_GUEST); } if (!empty($_POST["billing"]["create_new_account"]) || !$helper->isAllowedGuestCheckout($quote)) { $quote->setCheckoutMethod(Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER); } } $results = $this->process(array( 'billing' => array(), 'shipping' => array(), 'shipping_method' => array(), 'payment_method' => array() ), true ); $isHasErrors = false; foreach ($results as $stepIdx => $stepResult){ if (!empty($stepResult['error'])){ $isHasErrors = true; switch ($stepIdx){ case 'shipping_method': $updateItems[] = 'shipping_partial'; break; case 'payment': $updateItems[] = 'payment_partial'; break; case 'billing': $updateItems[] = 'billing_partial'; break; case 'shipping_address': $updateItems[] = 'shipping_address_partial'; break; } } } if (!$isHasErrors){ if (!empty($results['payment']['redirect'])) { //do not save order if ($data = $this->getRequest()->getPost('payment', false)) { $this->getOnepage()->getQuote()->getPayment()->importData($data); } $this->_updateQuote(true); }else{ $saveOrderResult = $this->_saveOrder(); $results['save_order'] = $saveOrderResult; if ($saveOrderResult['success'] == false) { $updateItems[] = "review_partial"; } } }else{ $this->_updateQuote(); } $return = array( 'results' => $results, 'previous_data' => $previousData, 'update_items' => $updateItems, 'success' => !empty($saveOrderResult['success']) ? $saveOrderResult['success'] : false, 'error' => !empty($saveOrderResult['error']) ? $saveOrderResult['error'] : false, ); if (count($updateItems)) { foreach ($updateItems as $updateItem) { $return['htmlUpdates'][$updateItem] = $this->_getUpdateItem($updateItem); } } $this->getResponse() ->clearHeaders() ->setHeader('Content-Type', 'application/json') ->setBody(Mage::helper('core')->jsonEncode($return)); } protected function _getUpdateItem($itemName = null) { switch ($itemName) { case 'shipping_partial': return $this->_getShippingMehodHtml(); case 'payment_partial': return $this->_getPaymentHtml(); case 'review_partial': return $this->_getReviewHtml(); default: return ''; } } protected function _saveOrder() { try { $data = $this->getRequest()->getPost('payment', array()); $this->_saveShippingAddress(); if ($data) { $data['checks'] = Mage_Payment_Model_Method_Abstract::CHECK_USE_CHECKOUT | Mage_Payment_Model_Method_Abstract::CHECK_USE_FOR_COUNTRY | Mage_Payment_Model_Method_Abstract::CHECK_USE_FOR_CURRENCY | Mage_Payment_Model_Method_Abstract::CHECK_ORDER_TOTAL_MIN_MAX | Mage_Payment_Model_Method_Abstract::CHECK_ZERO_TOTAL; $this->getOnepage()->getQuote()->getPayment()->importData($data); } //save comment if (Mage::getStoreConfig('typostores_onestepcheckout/general/allowcomment'))
{ 法师:: getSingleton('customer / session')-> setOrderCustomerComment($ this-> getRequest()-> getPost('order_comment'));
} $this->_subscribeNewsletter(); $this->getOnepage()->saveOrder(); file_put_contents('eee.txt', "save order ".Date('Y/m/d H:i')." \r\n", FILE_APPEND|LOCK_EX); $redirectUrl = $this->getOnepage()->getCheckout()->getRedirectUrl(); $result['success'] = true; $result['error'] = false; } catch (Mage_Payment_Model_Info_Exception $e) { $message = $e->getMessage(); $result['success'] = false; $result['error'] = true; if (!empty($message)) { $result['error_messages'] = $message; } } catch (Mage_Core_Exception $e) { Mage::logException($e); Mage::helper('checkout')->sendPaymentFailedEmail($this->getOnepage()->getQuote(),
$ e-> getMessage()); $ result ['success'] = false; $ result ['error'] = true; $ result ['error_messages'] = $ e-> getMessage();
if ($gotoSection = $this->getOnepage()->getCheckout()->getGotoSection()) { $result['goto_section'] = $gotoSection; $this->getOnepage()->getCheckout()->setGotoSection(null); } } catch (Exception $e) { Mage::logException($e); //echo $e->getMessage(); Mage::helper('checkout')->sendPaymentFailedEmail($this->getOnepage()->getQuote(),
$ e-> getMessage()); $ result ['success'] = false; $ result ['error'] = true; $ result ['error_messages'] = $ this-> __(“处理您的订单时出错。请与我们联系,或稍后再试。”); } $ this-> getOnepage()-> getQuote()-> save(); / ** *当重定向到第三方时,我们还不想保存订单。 *我们将保存订单以退货。 * / 如果(isset($ redirectUrl)){ $ result ['redirect'] = $ redirectUrl; } 返回$ result; // $ this-> getResponse()-> setBody(Mage :: helper('core')-> jsonEncode($ result)); }