Removed shipping address and shipping method from onepage checkout in magento

June 2, 2012 | In: Magento

Here I can show you how to remove shipping address from onepage checkout and remove shipping method from onepage checkout in magento. Based on different shop and requirement we need to magento customize onepage checkout method. When site give user only product information or accept only quote request based on product then no need to show shipping address and shipping method tab from onepage checkout in magento.

If you want to removed shipping address and shipping method from onepage checkout in magento then foloe below step.

Step 1: GO to /public_html/app/code/core/Mage/Checkout/Block/Onepage/abstract.php

Replace this code

<?php
protected function _getStepCodes()
{
	return array('login', 'billing', 'shipping', 'shipping_method', 'payment', 'review');
}
?>

With

<?php 
protected function _getStepCodes()
{
	//return array('login', 'billing', 'shipping', 'shipping_method', 'payment', 'review');
	return array('login', 'billing', 'payment', 'review');
}
?>

Step 2: Then edit onepage controllers file that available in app\code\core\Mage\Checkout\controllers\OnepageController.php

<?php
protected $_sectionUpdateFunctions = array(
	'payment-method'? => '_getPaymentMethodsHtml',
	// 'shipping-method' => '_getShippingMethodsHtml',
	'review' => '_getReviewHtml',
);
?>

Also edit in saveBillingAction()

<?php
public function saveBillingAction()
{
	if ($this->_expireAjax()) {
		return;
	}
	if ($this->getRequest()->isPost()) {
		//$postData = $this->getRequest()->getPost('billing', array());
		//$data = $this->_filterPostData($postData);
		$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'])) {
			/* check quote for virtual */
			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';
				$result['goto_section'] = 'payment';
			}
		}
		$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
	}
} 
?>

Step 3: Go to \app\code\core\Mage\Sales\Model\Service\Quote.php

<?php
protected function _validate()
{
	$helper = Mage::helper('sales');
	if (!$this->getQuote()->isVirtual()) {
		$address = $this->getQuote()->getShippingAddress();
		$addressValidation = $address->validate();
		
		/*if ($addressValidation !== true) {
			Mage::throwException(
			$helper->__('Please check shipping address information. %s', implode(' ', $addressValidation))
			);
		}
		$method= $address->getShippingMethod();
		$rate? = $address->getShippingRateByCode($method);
		if (!$this->getQuote()->isVirtual() && (!$method || !$rate)) {
			Mage::throwException($helper->__('Please specify a shipping method.'));
		}*/
	}
}
?>

Step 4: Billing information tab you see radio button for shipping address as billing address ,just hidden it or remove it from app\design\frontend\default\yourtemplate\persistent\checkout\onepage\billing.phtml

We can also help you for Magento Development want to know more just click on Contact Us.

Step 5: Also remove shipping detail from order success email template from your local folde just like app\locale\en_US\template\email\sales\order_new.html
And remove this code

From

{{var order.getShippingAddress().format('html')}}

To

{{var order.getBillingAddress().format('html')}}

And

{{var order.getShippingDescription()}}

Now remove or refresh your magento cache and check whole order process.

Comments

comments

Powered by Facebook Comments

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

*


*

 

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>