Removed shipping method from onepage checkout in magento
This December, I have been working on magento onepage checkout customization for a client. They want to remove from shipping address step and shipping method as per their strategy.
Magento onepage checkout consist of six steps-Checkout method, Billing Infomation,Shipping Information ,Shipping Method, Payment method and Order Review
When magento always used billing address as shipping address .then there are not need to shipping address tab in magento checkout onepage. Some ecommerce site give shipping charge zero, so they want to skip this step, go to next step and remove shipping method from checkout process.
Thus make magento onepage checkout to faster and easy for customer.
For this work , first we change in some mage core file.magento checkout initialing from
app\code\core\Mage\Checkout\Block \Onepage.php
edit in public function getSteps() function
Then edit onepage controllers file that available in app\code\core\Mage\Checkout\controllers\ OnepageController.php
Comment there
Also edit in saveBillingAction() function-
Code---
For this work edit in sales quote file in
\app\code\core\Mage\Sales\Model\Service\ Quote.php
And your checkout onepage have four steps-Checkout method, Billing Information,Payment method and Order Review.
In billing information tab you see radio buttom for shipping address as billing address ,just hidden it or remove it .the file located at - app\design\frontend\default\your template\yourtemplate\persistent\checkout\onepage\billing,phtml
Or
app\design\frontend\default\your template\template \checkout\onepage\billing,phtml
Now checkout successfully.
When you get order success email you shipping address is missing in email so edit /remove some
In app\locale\en_US\template\email\sales\ order_new.html
From
{{var order.getShippingAddress().format('html')}}
To
{{var order.getBillingAddress().format('html')}}
And
{{var order.getShippingDescription()}}
Remove it.
Now redefine the checkout onepage process . It will lot of help to you.
This December, I have been working on magento onepage checkout customization for a client. They want to remove from shipping address step and shipping method as per their strategy.
Magento onepage checkout consist of six steps-Checkout method, Billing Infomation,Shipping Information ,Shipping Method, Payment method and Order Review
When magento always used billing address as shipping address .then there are not need to shipping address tab in magento checkout onepage. Some ecommerce site give shipping charge zero, so they want to skip this step, go to next step and remove shipping method from checkout process.
Thus make magento onepage checkout to faster and easy for customer.
For this work , first we change in some mage core file.magento checkout initialing from
app\code\core\Mage\Checkout\Block \Onepage.php
edit in public function getSteps() function
public function getSteps()
{
$steps = array();
if (!$this->isCustomerLoggedIn()) {
$steps['login'] = $this->getCheckout()->getStepData('login');
}
//$stepCodes = array('billing', 'shipping', 'shipping_method', 'payment', 'review');
//Comment By Abhay Khatariya and add by Abhay Khatariya
$stepCodes = array('billing', 'payment', 'review');
//end of Abhay Khatariya
foreach ($stepCodes as $step) {
$steps[$step] = $this->getCheckout()->getStepData($step);
}
return $steps;
}
{
$steps = array();
if (!$this->isCustomerLoggedIn()) {
$steps['login'] = $this->getCheckout()->getStepData('login');
}
//$stepCodes = array('billing', 'shipping', 'shipping_method', 'payment', 'review');
//Comment By Abhay Khatariya and add by Abhay Khatariya
$stepCodes = array('billing', 'payment', 'review');
//end of Abhay Khatariya
foreach ($stepCodes as $step) {
$steps[$step] = $this->getCheckout()->getStepData($step);
}
return $steps;
}
Then edit onepage controllers file that available in app\code\core\Mage\Checkout\controllers\ OnepageController.php
Comment there
protected $_sectionUpdateFunctions = array(
'payment-method' => '_getPaymentMethodsHtml',
// 'shipping-method' => '_getShippingMethodsHtml',
//Comment by Abhay Khatariya
'review' => '_getReviewHtml',
);
'payment-method' => '_getPaymentMethodsHtml',
// 'shipping-method' => '_getShippingMethodsHtml',
//Comment by Abhay Khatariya
'review' => '_getReviewHtml',
);
Also edit in saveBillingAction() function-
Code---
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()
);
}
//Comment by Abhay Khatariya
/*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';
}*/
//End of Comment by Abhay Khatariya
else {
//Comment by Abhay Khatariya
//$result['goto_section'] = 'shipping';
$result['goto_section'] = 'payment';
}
}
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
}
{
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()
);
}
//Comment by Abhay Khatariya
/*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';
}*/
//End of Comment by Abhay Khatariya
else {
//Comment by Abhay Khatariya
//$result['goto_section'] = 'shipping';
$result['goto_section'] = 'payment';
}
}
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
}
For this work edit in sales quote file in
\app\code\core\Mage\Sales\Model\Service\ Quote.php
protected function _validate()
{
$helper = Mage::helper('sales');
if (!$this->getQuote()->isVirtual()) {
$address = $this->getQuote()->getShippingAddress();
$addressValidation = $address->validate();
// Comment By Abhay Khatariya
// 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.'));
//}
// end of Comment By Abhay Khatariya
}
{
$helper = Mage::helper('sales');
if (!$this->getQuote()->isVirtual()) {
$address = $this->getQuote()->getShippingAddress();
$addressValidation = $address->validate();
// Comment By Abhay Khatariya
// 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.'));
//}
// end of Comment By Abhay Khatariya
}
And your checkout onepage have four steps-Checkout method, Billing Information,Payment method and Order Review.
In billing information tab you see radio buttom for shipping address as billing address ,just hidden it or remove it .the file located at - app\design\frontend\default\your template\yourtemplate\persistent\checkout\onepage\billing,phtml
Or
app\design\frontend\default\your template\template \checkout\onepage\billing,phtml
Now checkout successfully.
When you get order success email you shipping address is missing in email so edit /remove some
In app\locale\en_US\template\email\sales\ order_new.html
From
{{var order.getShippingAddress().format('html')}}
To
{{var order.getBillingAddress().format('html')}}
And
{{var order.getShippingDescription()}}
Remove it.
Now redefine the checkout onepage process . It will lot of help to you.
can u help me
ReplyDeletei have a problem in magento malti domain site.
there r three front end
2 site check out process completely work.
in 1 site when i click check out process button.
page is refresh.
can't select shipping method.
all site one page check out file same.
please check your back-end settings go to system->configuration->shipping method then select your website which is not shown shipping method. and check there are shipping method set with yes option or not and if not then let me know i will give you other solution
DeleteThanks