1

I've read a number of other questions related to removing steps, and even one about removing the billing step, but all I do is end up with errors. I want to simply remove the Billing Information step altogether.

This is what I've done so far:

app/code/etc/Sneakypixel_Checkout.xml:

<?xml version="1.0"?>
<config>
<modules>
    <Sneakypixel_Checkout>
        <active>true</active>
        <codePool>local</codePool>
        <depends>Mage_Checkout</depends>
    </Sneakypixel_Checkout>
</modules>
</config>

app/code/local/Sneakypixel/Checkout/etc/config.xml:

<config>
<global>
    <blocks>
        <checkout>
            <rewrite>
                <onepage_abstract>Sneakypixel_Checkout_Block_Onepage_Abstract</onepage_abstract>
            </rewrite>
        </checkout>
    </blocks>
</global>
</config>

app/code/local/Sneakypixel/Checkout/controllers/OnepageController.php: Commented out

$result['allow_sections'] = array('shipping');
$result['duplicateBillingInfo'] = 'true';

from

<?php

require_once Mage::getModuleDir('controllers', "Mage_Checkout").DS."OnepageController.php";

class Sneakypixel_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';
        }
    }

    $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
}

app/code/local/Sneakypixel/Checkout/Block/Onepage.php:

<?php

class Sneakypixel_Checkout_Block_Onepage extends Mage_Checkout_Block_Onepage
{
/**
 * Get 'one step checkout' step data
 *
 * @return array
 */
public function getSteps()
{
    $steps = array();
    $stepCodes = $this->_getStepCodes();

    if ($this->isCustomerLoggedIn()) {
        $stepCodes = array_diff($stepCodes, array('login'));
    }

    foreach ($stepCodes as $step) {
        $steps[$step] = $this->getCheckout()->getStepData($step);
    }

    return $steps;
}

/**
 * Get active step
 *
 * @return string
 */
public function getActiveStep()
{
    return $this->isCustomerLoggedIn() ? 'billing' : 'login';
}
}

app/code/local/Sneakypixel/Checkout/Block/Onepage/Abstract.php:

<?php

class Sneakypixel_Checkout_Block_Onepage_Abstract extends Mage_Checkout_Block_Onepage_Abstract
{

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

All I get are errors. I feel as though I'm missing something in my config.xml, or that I've touched too many files. This is my first time dipping into the waters of overwriting core blocks and controllers via custom modules.

  • Still can't figure out why it will not work. – taskle Jul 19 '16 at 15:35
0

Alright, so I've successfully removed Billing. Shipping and Shipping method had already been removed in the past, but this is the module I created to remove Billing from Magento Onepage checkout.

app/code/local/Namespace/RemoveBilling/Block/Checkout/Onepage.php

<?php
class Namespace_RemoveBilling_Block_Checkout_Onepage extends Mage_Checkout_Block_Onepage
{
protected function _getStepCodes()
{
    return array('login', 'shipping', 'shipping_method', 'payment', 'review');
}

public function getSteps()
{
    $steps = array();
    $stepCodes = $this->_getStepCodes();

    if ($this->isCustomerLoggedIn()) {
        $stepCodes = array_diff($stepCodes, array('login'));
    }

    foreach ($stepCodes as $step) {
        $steps[$step] = $this->getCheckout()->getStepData($step);
    }

    if (isset($steps['billing']))
        unset($steps['billing']);

    return $steps;
}

/**
 * Get active step
 *
 * @return string
 */
public function getActiveStep()
{
    return $this->isCustomerLoggedIn() ? 'payment' : 'login';
}

public function isShow()
{
    return false;
}
}

app/code/local/Namespace/RemoveBilling/etc/config.xml

<?xml version="1.0"?>
<config>
  <modules>
   <Namespace_RemoveBilling>
     <version>0.1.0</version>
   </Namespace_RemoveBilling>
  </modules>
  <frontend>
    <routers>
       <removebilling>
         <use>standard</use>
           <args>
             <module>Namespace_RemoveBilling</module>
             <frontName>removebilling</frontName>
           </args>
       </removebilling>
    </routers>  
    <layout>
      <updates>
        <removebilling>
          <file>removebilling.xml</file>
        </removebilling>
      </updates>
    </layout>
  </frontend>  
  <global>
      <helpers>
         <removebilling>
           <class>Namespace_RemoveBilling_Helper</class>
         </removebilling>
      </helpers>
      <blocks>
         <removebilling>
           <class>Namespace_RemoveBilling_Block</class>
         </removebilling>
         <checkout>
            <rewrite>
                   <onepage>Namespace_RemoveBilling_Block_Checkout_Onepage</onepage>
            </rewrite>
         </checkout>
      </blocks>
   </global>
</config> 

app/code/local/Namespace/RemoveBilling/Helper/Data.php

<?php
class Infinity_RemoveBilling_Helper_Data extends Mage_Core_Helper_Abstract
{
}

app/code/etc/modules/Namespace_RemoveBilling.xml

<?xml version="1.0"?>
<config>
  <modules>
    <Namespace_RemoveBilling>
      <active>true</active>
      <codePool>local</codePool>
      <version>0.1.0</version>
    </Namespace_RemoveBilling>
  </modules>
</config>

skin/frontend/base/default/js/opcheckout.js

Removed 'billing' from line 39:

this.steps = ['login', 'shipping', 'shipping_method', 'payment', 'review'];

Changed line 41, which was originally:

this.currentStep = 'billing';

to this:

this.currentStep = $('opc-login') !== null ? 'login' : 'payment';

    this.gotoSection(this.currentStep);

I had also completely removed the progress bar on the right since I only have two steps now. Otherwise it looks tacky.

This will remove Billing step from Magento 1.8

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.