2011-03-24 57 views

回答

24

您可以更改/app/code/core/Mage/Checkout/controllers/OnepageController.php文件。修改successAction,看起來像這樣:

public function successAction() 
    { 
     /* 
     $session = $this->getOnepage()->getCheckout(); 
     if (!$session->getLastSuccessQuoteId()) { 
      $this->_redirect('checkout/cart'); 
      return; 
     } 

     $lastQuoteId = $session->getLastQuoteId(); 
     $lastOrderId = $session->getLastOrderId(); 
     $lastRecurringProfiles = $session->getLastRecurringProfileIds(); 
     if (!$lastQuoteId || (!$lastOrderId && empty($lastRecurringProfiles))) { 
      $this->_redirect('checkout/cart'); 
      return; 
     } 

     $session->clear(); 
     */ 


     $this->loadLayout(); 
     $this->_initLayoutMessages('checkout/session'); 
     Mage::dispatchEvent('checkout_onepage_controller_success_action', array('order_ids' => array($lastOrderId))); 
     $this->renderLayout(); 
    } 

記得在完成後刪除註釋!

+0

完美!謝謝M_F! – sulman 2011-03-24 14:11:54

+0

真棒可以幫助很多 – 2014-07-10 13:12:41

0

Firefox會讓你禁用HTTP重定向,但是你可能不得不暫時破解一個控制器讓你留在頁面上。

+0

發現禁用HTTP重定向沒有工作。你知道我需要看什麼控制器嗎? Magento中有一百萬次重定向!謝謝 – sulman 2011-03-24 14:09:34

0

我建議使用此代碼來替換你的successAction:

/** 
* Order success action 
*/ 
public function successAction() 
{ 

    $session = $this->getOnepage()->getCheckout();   

    $session->setLastSuccessQuoteId(20); // <<< add your order entity ID 
    $session->setLastQuoteId(20); // <<< add your order entity ID 
    $session->setLastOrderId(20); // <<< add your order entity ID 

    if (!$session->getLastSuccessQuoteId()) { 
     $this->_redirect('checkout/cart'); 
     return; 
    } 

    $lastQuoteId = $session->getLastQuoteId(); 
    $lastOrderId = $session->getLastOrderId(); 
    $lastRecurringProfiles = $session->getLastRecurringProfileIds(); 
    if (!$lastQuoteId || (!$lastOrderId && empty($lastRecurringProfiles))) { 
     $this->_redirect('checkout/cart'); 
     return; 
    } 

    #$session->clear(); // <<< comment it 

    $this->loadLayout(); 
    $this->_initLayoutMessages('checkout/session'); 
    Mage::dispatchEvent('checkout_onepage_controller_success_action', array('order_ids' => array($lastOrderId))); 
    $this->renderLayout(); 
} 

問候

0

雖然代碼的修改可能是渴望,還有一個擴展,專門爲這個:

https://www.yireo.com/blog/1672-testing-the-magento-checkout-success-page

披露:我絕不是編碼員/開發人員,所以擴展路線吸引我(儘管我很樂意進行這些更改)。

+0

雖然這個鏈接可能會回答這個問題,但最好在這裏包含答案的重要部分,並提供供參考的鏈接。 如果鏈接頁面更改,則僅鏈接答案可能會失效。 – Ghost 2015-01-14 03:57:53

0

如果任何人都將是搜索同一個解決方案Magento的2停止重新加載頁面後從成功頁面重定向 - 那就是:

快速和調試髒解決方案:

  1. 開放/vendor/magento/module-checkout/Controller/Onepage/Success.php
  2. 評論輸出代碼

/* if (!$this->_objectManager->get('Magento\Checkout\Model\Session\SuccessValidator')->isValid()) { return $this->resultRedirectFactory->create()->setPath('checkout/cart'); } $session->clearQuote(); */

正確的解決方案使用模塊都可以在這裏https://gielberkers.com/style-checkoutonepagesuccess-page-magento-2/