Monday , December 11 2017
Home >> All tutorial >> Remove shipping method from the magento checkout one page

Remove shipping method from the magento checkout one page

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 consists 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, there are no need to have shipping address tab  in magento  checkout  onepage. Some ecommerce sites give shipping charge zero, so they want to skip this step, go to the next step and remove shipping method from checkout process.

Thus make magento onepage checkout 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

  1. public function getSteps()
  2. {
  3. $steps = array();
  4. if (!$this->isCustomerLoggedIn()) {
  5. $steps[‘login’] = $this->getCheckout()->getStepData(‘login’);
  6. }
  7. //$stepCodes = array(‘billing’, ‘shipping’, ‘shipping_method’, ‘payment’, ‘review’);
  8. //Comment By Abhay Khatariya and add by  Abhay Khatariya
  9. $stepCodes = array(‘billing’, ‘payment’, ‘review’);
  10. //end of  Abhay Khatariya
  11. foreach ($stepCodes as $step) {
  12. $steps[$step] = $this->getCheckout()->getStepData($step);
  13. }
  14. return $steps;
  15. }

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

Comment there:

  1. protected $_sectionUpdateFunctions = array(
  2. ‘payment-method’  => ‘_getPaymentMethodsHtml’,
  3. // ‘shipping-method’ => ‘_getShippingMethodsHtml’,
  4. //Comment by  Abhay Khatariya
  5. ‘review’ => ‘_getReviewHtml’,
  6. );

Also edit  in saveBillingAction() function-
Code—

  1. protected $_sectionUpdateFunctions = array(
  2. ‘payment-method’  => ‘_getPaymentMethodsHtml’,
  3. // ‘shipping-method’ => ‘_getShippingMethodsHtml’,
  4. //Comment by  Abhay Khatariya
  5. ‘review’ => ‘_getReviewHtml’,
  6. );
  7.  
  8. Also edit  in saveBillingAction() function
  9. Code
  10. public function saveBillingAction()
  11. {
  12. if ($this->_expireAjax()) {
  13. return;
  14. }
  15. if ($this->getRequest()->isPost()) {
  16. //$postData = $this->getRequest()->getPost(‘billing’, array());
  17. //$data = $this->_filterPostData($postData);
  18. $data = $this->getRequest()->getPost(‘billing’, array());
  19. $customerAddressId = $this->getRequest()->getPost(‘billing_address_id’, false);
  20. if (isset($data[’email’])) {
  21. $data[’email’] = trim($data[’email’]);
  22. }
  23. $result = $this->getOnepage()->saveBilling($data, $customerAddressId);
  24. if (!isset($result[‘error’])) {
  25. /* check quote for virtual */
  26. if ($this->getOnepage()->getQuote()->isVirtual()) {
  27. $result[‘goto_section’] = ‘payment’;
  28. $result[‘update_section’] = array(
  29. ‘name’ => ‘payment-method’,
  30. ‘html’ => $this->_getPaymentMethodsHtml()
  31. );
  32. }
  33. //Comment by Abhay Khatariya
  34. /*elseif (isset($data[‘use_for_shipping’]) >> $data[‘use_for_shipping’] == 1) {
  35. $result[‘goto_section’] = ‘shipping_method’;
  36. $result[‘update_section’] = array(
  37. ‘name’ => ‘shipping-method’,
  38. ‘html’ => $this->_getShippingMethodsHtml()
  39. );
  40. $result[‘allow_sections’] = array(‘shipping’);
  41. $result[‘duplicateBillingInfo’] = ‘true’;
  42. }*/
  43. //End of Comment by  Abhay Khatariya
  44. else {
  45. //Comment by Abhay Khatariya
  46. //$result[‘goto_section’] = ‘shipping’;
  47. $result[‘goto_section’] = ‘payment’;
  48. }
  49. }
  50. $this->getResponse()->setBody(Mage::helper(‘core’)->jsonEncode($result));
  51. }
  52. }

For this work, edit in sales quote file in
\app\code\core\Mage\Sales\Model\Service\ Quote.php

  1. protected function _validate()
  2. {
  3. $helper = Mage::helper(‘sales’);
  4. if (!$this->getQuote()->isVirtual()) {
  5. $address = $this->getQuote()->getShippingAddress();
  6. $addressValidation = $address->validate();
  7. // Comment By  Abhay Khatariya
  8. // if ($addressValidation !== true) {
  9. // Mage::throwException(
  10. //$helper->__(‘Please check shipping address information. %s’, implode(‘ ‘, $addressValidation))
  11. //);
  12. //}
  13. // $method= $address->getShippingMethod();
  14. //$rate  = $address->getShippingRateByCode($method);
  15. //if (!$this->getQuote()->isVirtual() >> (!$method || !$rate)) {
  16. //Mage::throwException($helper->__(‘Please specify a shipping method.’));
  17. //}
  18. // end of Comment By Abhay Khatariya
  19. }

And your checkout onepage has 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 . Hope it helpful to you.

Source: http://abhaykhatariya.blogspot.in/

We also contribute great content of Magento Download for FREE (all versions)

DON'T MISS THE CHANCE!

magento download

About Champ

One comment

  1. One of the most required tips for the ecommerce store owners to make the shipping process much easier.

Leave a Reply

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

Heap | Mobile and Web Analytics