Customizing Onepage Checkout - Remove shipping_method
This is an old revision of the document!
How to remove shipping_method block from OnepageCheckout.
Tested on Magento ver. 1.3.1
You will need to modify two core files in these locations:
- app/code/core/Mage/Checkout/controllers/OnepageController.php
- app/code/core/Mage/Checkout/Block/Onepage.php
1.) Onepage.php:
function getSteps()
replace:
- $stepCodes = array('billing', 'shipping', 'shipping_method', 'payment', 'review');
with:
- $stepCodes = array('billing', 'shipping', 'payment', 'review');
2.) OnepageController.php:
function saveBillingAction()
- public function saveBillingAction()
- {
- $this->_expireAjax();
- if ($this->getRequest()->isPost()) {
- $data = $this->getRequest()->getPost('billing', array());
- $customerAddressId = $this->getRequest()->getPost('billing_address_id', false);
- $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'] = 'payment';
- $result['update_section'] = array(
- 'name' => 'payment-method',
- 'html' => $this->_getPaymentMethodsHtml()
- );
- }
- else {
- $result['goto_section'] = 'shipping';
- }
- }
- $this->getResponse()->setBody(Zend_Json::encode($result));
- }
- }
function saveShippingAction()
- public function saveShippingAction()
- {
- $this->_expireAjax();
- if ($this->getRequest()->isPost()) {
- $this->saveShippingMethodAction();
- $data = $this->getRequest()->getPost('shipping', array());
- $customerAddressId = $this->getRequest()->getPost('shipping_address_id', false);
- $result = $this->getOnepage()->saveShipping($data, $customerAddressId);
- if (!isset($result['error'])) {
- $result['goto_section'] = 'payment';
- $result['update_section'] = array(
- 'name' => 'payment-method',
- 'html' => $this->_getPaymentMethodsHtml()
- );
- }
- // $this->loadLayout('checkout_onepage_shippingMethod');
- // $result['shipping_methods_html'] = $this->getLayout()->getBlock('root')->toHtml();
- // $result['shipping_methods_html'] = $this->_getShippingMethodsHtml();
- $this->getResponse()->setBody(Zend_Json::encode($result));
- }
- }
function saveShippingMethodAction() (shipping method “Free Shipping” must be enabled in backend/admin)
- public function saveShippingMethodAction()
- {
- $this->_expireAjax();
- if ($this->getRequest()->isPost()) {
- $data = $this->getRequest()->getPost('shipping_method', 'freeshipping_freeshipping');
- $result = $this->getOnepage()->saveShippingMethod($data);
- /*
- $result will have erro data if shipping method is empty
- */
- if(!$result) {
- Mage::dispatchEvent('checkout_controller_onepage_save_shipping_method', array('request'=>$this->getRequest(), 'quote'=>$this->getOnepage()->getQuote()));
- $this->getResponse()->setBody(Zend_Json::encode($result));
- $result['goto_section'] = 'payment';
- $result['update_section'] = array(
- 'name' => 'payment-method',
- 'html' => $this->_getPaymentMethodsHtml()
- );
- //$result['payment_methods_html'] = $this->_getPaymentMethodsHtml();
- }
- $this->getResponse()->setBody(Zend_Json::encode($result));
- }
- }
function saveOrderAction() (needs only a function call for saveShippingMethodAction())
- public function saveOrderAction()
- {
- $this->_expireAjax();
- $this->saveShippingMethodAction();
- ...
- }


