0
votes

I am completely new to Magento and we are using version 1.4 currently. The steps on the OnePage checkout are:

  • Checkout Method (Guest or sign-in)
  • Billing Information
  • Shipping Information
  • Delivery Information
  • Payment Information
  • Order Review

I want to skip Delivery Information. To do this I have done two things: 1. Changed (actually extended) the core Checkout class to not include #4 Delivery Information ('shipping_information'), 2. in the Controller, call the Checkout class method saveShippingMethodAction( ) inside of saveShippingAction( ) (since there is never a submission of shipping method by user), with a data value passed manually.

Everything works as expected, and the step is skipped, however inside Checkout::saveShippingMethodAction( ) there are these two lines:

Mage::dispatchEvent('checkout_controller_onepage_save_shipping_method', array('request'=>$this->getRequest(), 'quote'=>$this->getOnepage()->getQuote()));
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));

The problem is in the usage of 'request'=>$this->getRequest(). The actual request is not shipping_method but rather shipping, so the output (i.e. the HTML form string that should be passed to step #5, Payment information) is not loaded, and so step #5 is blank.

My first instict is how can I simulate a request, but there is probably a "Magento Way" to do this. Can anyone tell me what that might be, or how I can prep getRequest( ) and maybe getResponse( ) as if I'd submitted that specific form? Thanks!

1

1 Answers

0
votes

I understood what you want to do but i didn't understood what you did.

Ok, i will explain you something here.If you are talking about magento default onepage checkout than the thing you are talking about Delivery Information it is actually the shipping method.

You also were asking about something

Mage::dispatchEvent('checkout_controller_onepage_save_shipping_method', array('request'=>$this->getRequest(), 'quote'=>$this->getOnepage()->getQuote()));
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));

It actually don't have anything to do with your code because it is the place to insert your event, Its like a hook.

Now the real problem and its solution.I haven't tried it yet but this should work.

If you see the

app/code/core/Mage/checkout/controllers/OnepageController.php

file.You need to make changes in this file. First override this controller to your own module, this is the preferred way but you can test in core files too.

Now in this file you will see two function

public function saveShippingAction()
    {
//This function saves the shipping information of customer
    }

and

public function saveShippingMethodAction()
    {
//this function saves the shipping method 
    }

In the first function you will see some code like this

if (!isset($result['error'])) {
                $result['goto_section'] = 'shipping_method';
                $result['update_section'] = array(
                    'name' => 'shipping-method',
                    'html' => $this->_getShippingMethodsHtml()
                );
            }

this redirects to shipping method.If you want to by pass the shipping method steps(in your case delivery information) then replace the above code by

    if (!isset($result['error'])) {
 $result['goto_section'] = 'payment';
                $result['update_section'] = array(
                    'name' => 'payment-method',
                    'html' => $this->_getPaymentMethodsHtml()
                );
}

This will complete your redirection part from controller side now remove the block that displays the shipping method block from the layout file. and that's it.

Hope this helps.