18

Are there any extensions, open-source Magento modules, or tutorials that make adding a step to the one page checkout any easier? I've poked at the core code for this a few times and it seems like there's a lot of hard coded step information.

  • 5
    Unfortunately the Checkout code doesn't seem to be very flexible, a lot of the information is hardcoded from templates to the javascript accordion files. – Allan MacGregor Apr 4 '14 at 0:42
  • 1
    I've followed this tutorial and was able to add a new step in onepage checkout. Anyway lots of core files need to be override to achieve this step. Hope this will helpful excellencemagentoblog.com/magento-onestep-checkout-add-step – Sukeshini Apr 4 '14 at 9:49
6

The short answer to this question ended up being "No". From a high level, adding a new checkout step meant

  1. Adding a new Block to the one step checkout page

  2. Having that block register itself as a step

  3. Connect that block with a prototype object that handled all interactions

  4. Rewriting several core Magento methods to insert the block as a step

  5. Some ajax trickery to get the progress stuff working.

Covering this in total is beyond the scope of a single Stack Overflow question. The tutorial linked in another question has a lot of what you'll need, and I also created a new commercial extension to make all this easier.

4

By default magento gives some checkout steps. But Sometime you need to add extra information from the customer for future reference. A common requested customization is to add the Custom Form in default checkout process. This is not good practice to touch core files. You can do this via overriding Modules. In this example Comapnyname is Ipragmatech and Module name is Checkoutstep.

Step1: Add Custom step in the checkout process

Open the Ipragmatech > Checkoutstep > Block > Onepage> Checkoutstep.php file and write the following code

    class Ipragmatech_Checkoutstep_Block_Onepage_Checkoutstep extends Mage_Checkout_Block_Onepage_Abstract
    {
       protected function _construct()
       {     
          $this->getCheckout()->setStepData('checkoutstep', array(
          'label'     => Mage::helper('checkout')->__('Invitation to participation'),
          'is_show'   => true
        ));
        parent::_construct();
       }
     }

Step2: Add steps which and where you want in the checkout process

Open the Ipragmatech > Checkoutstep > Block > Onepage> Checkoutstep.php file and write the following code

    class Ipragmatech_Checkoutstep_Block_Onepage extends Mage_Checkout_Block_Onepage
    {
      public function getSteps()
      {
             $steps = array();

             if (!$this->isCustomerLoggedIn()) {
                $steps['login'] = $this->getCheckout()->getStepData('login');
             }

            $stepCodes = array('billing', 'shipping', 'shipping_method', 'payment', 'checkoutstep', 'review');
         foreach ($stepCodes as $step) {
             $steps[$step] = $this->getCheckout()->getStepData($step);
          }

    return $steps;
   }
}

Step3: Grab the submitted value of custom form and set the values of Custom form

Open the ipragmatech > Checkoutstep > controllers > OnepageController.php and write the following fucntion

    public function saveCheckoutstepAction()
    {
      $this->_expireAjax();
      if ($this->getRequest()->isPost()) {

     //Grab the submited value 
     $_entrant_name = $this->getRequest()->getPost('entrant_name',"");
     $_entrant_phone = $this->getRequest()->getPost('entrant_phone',"");
     $_entrant_email = $this->getRequest()->getPost('entrant_email',"");
     $_permanent_address = $this->getRequest() ->getPost('permanent_address',"");
     $_address = $this->getRequest()->getPost('local_address',"");

     Mage::getSingleton('core/session') ->setIpragmatechCheckoutstep(serialize(array(
    'entrant_name' =>$_entrant_name,
    'entrant_phone' =>$_entrant_phone,
    'entrant_email' =>$_entrant_email,
    'permanent_address' =>$_permanent_address,
    'address' =>$_address
     )));

    $result = array();
    $redirectUrl = $this->getOnePage()->getQuote()->getPayment() ->getCheckoutRedirectUrl();
        if (!$redirectUrl) {
            $this->loadLayout('checkout_onepage_review');
            $result['goto_section'] = 'review';
            $result['update_section'] = array(
                'name' => 'review',
                'html' => $this->_getReviewHtml()
            );

        }

        if ($redirectUrl) {
            $result['redirect'] = $redirectUrl;
        }

        $this->getResponse()->setBody(Zend_Json::encode($result));
    }
}

Step4: Save Custom Form information

When checkout_onepage_controller_success_action event hook is called. Open the Ipragmatech > Checkoutstep > Model >Observer.php and write the following

    class Ipragmatech_Checkoutstep_Model_Observer {
      const ORDER_ATTRIBUTE_FHC_ID = 'checkoutstep';
      public function hookToOrderSaveEvent() {
      if (Mage::helper('checkoutstep')->isEnabled()) {
         $order = new Mage_Sales_Model_Order ();
         $incrementId = Mage::getSingleton ( 'checkout/session' )->getLastRealOrderId ();
         $order->loadByIncrementId ( $incrementId );

       // Fetch the data 
       $_checkoutstep_data = null;
       $_checkoutstep_data = Mage::getSingleton ( 'core/session' )->getIpragmatechCheckoutstep ();
       $model = Mage::getModel ( 'checkoutstep/customerdata' )->setData ( unserialize ( $_checkoutstep_data ) );
       $model->setData ( "order_id",$order["entity_id"] );
       try {
           $insertId = $model->save ()->getId ();
             Mage::log ( "Data successfully inserted. Insert ID: " . $insertId, null, 'mylog.log');
        } catch ( Exception $e ) {
            Mage::log ( "EXCEPTION " . $e->getMessage (), null, 'mylog.log' );
          }
        }
    }

}

Magento – Add Custom Form in Checkout Extension is a complete solution to add extra step in Checkout process for your ecommerce website. It allow admin to export data from custom table in CSV format.

Visit the link to get this free extension http://www.magentocommerce.com/magento-connect/custom-form-in-checkout.html

0

yes there is a good tutorial about this here "http://excellencemagentoblog.com/magento-onestep-checkout-add-step"

protected by Community Dec 16 '14 at 16:23

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.