0

I am struggling to find a way to combine the Shipping Address and Shipping method into a single step on the default Magento Onepage Checkout. I know that there are many 3rd-party OneStepCheckout extensions (some of which I have used in the past), but I prefer the flow of the onepage checkout...I would just like to optimise it.

Ideally, I would like to prompt for Shipping Address and Shipping Method in the first step, followed by prompting the customer for their billing address (if different) and payment information together in a single step as well. We only have 2 shipping methods which are not determined by shipping address, so there will be no need to make any ajax calls to update the available shipping methods.

I know that checkout is difficult to customise in this regard, but I would sincerely appreciate any pointers and/or advice please.

0

Your Solution:

Step: 1

Override Controller: \app\code\local\Htech\Checkout\controllers\OnepageController.php

require_once Mage/Checkout/controllers/OnepageController.php';


class Htech_Checkout_OnepageController extends Mage_Checkout_OnepageController{

/**
 * Save checkout billing address
 */
public function saveBillingAction()
{
    if ($this->_expireAjax()) {
        return;
    }
    if ($this->getRequest()->isPost()) {
        $data = $this->getRequest()->getPost('billing', array());
        $customerAddressId = $this->getRequest()->getPost('billing_address_id', false);

        if (isset($data['email'])) {
            $data['email'] = trim($data['email']);
        }
        $result = $this->getOnepage()->saveBilling($data, $customerAddressId);

        if (!isset($result['error'])) {
            if ($this->getOnepage()->getQuote()->isVirtual()) {
                $result['goto_section'] = 'payment';
                $result['update_section'] = array(
                    'name' => 'payment-method',
                    'html' => $this->_getPaymentMethodsHtml()
                );
            } elseif (isset($data['use_for_shipping']) && $data['use_for_shipping'] == 1) {
                $result['goto_section'] = 'shipping_method';
                $result['update_section'] = array(
                    'name' => 'shipping-method',
                    'html' => $this->_getShippingMethodsHtml()
                );

                //$result['allow_sections'] = array('shipping');
                //$result['duplicateBillingInfo'] = 'true';
            } else {
                $result['goto_section'] = 'shipping_method';
            }
        }

        $this->_prepareDataJSON($result);
    }
}
}

Step: 2

Create Config file:\app\code\local\Htech\Checkout\etc\config.xml

Block: \app\code\local\Mage\Checkout\Block\Onepage\Abstract.php Copy Abstract.php from core and change _getStepCodes() method to following

protected function _getStepCodes()
{
    return array('login', 'billing', 'shipping_method', 'payment', 'review');
}

Step: 3

Change Layout: \app\design\frontend\rwd\default\layout\checkout.xml

Remove/Comment All Block with shipping.phtml file form checkout_onepage_index and checkout_onepage_progress

i.e.

  • <block type="checkout/onepage_progress" name="shipping.progress" template="checkout/onepage/progress/shipping.phtml"></block>

  • <block type="checkout/onepage_shipping" name="checkout.onepage.shipping" as="shipping" template="checkout/onepage/shipping.phtml" />

  • <block type="checkout/onepage_progress" name="shipping.progress" template="checkout/onepage/progress/shipping.phtml"></block>

Step: 4

Template: \app\design\frontend\rwd\default\template\checkout\onepage.phtml

Add This code After <div class="step-title">....</div>

<div id="checkout-step-<?php echo $_stepId ?>" class="step a-item" style="display:none;"> <?php if($_stepId=='shipping_method'){ ?> <?php echo $this->getLayout()->createBlock('checkout/onepage_shipping')->setTemplate('checkout/onepage/shipping.phtml')->toHtml(); ?> <?php } ?> <?php echo $this->getChildHtml($_stepId) ?> </div>

If Some one have short mehtod for this then share.

Output:

Output

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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