I don't know any module, however you could find a way to include or reorder the checkout process as explained below. It could help you to develop a solution.
I wanted one day add a step in the middle of the checkout process. At the moment, there is no official way to do it, I mean you don't have any events which allows to change the behavior.
The solution I found consist to modify the class Mage_Checkout_Block_Onepage_Abstract
. Attention, it's not a classic model, it's an abstract, you can't overwrite it by using the tag <rewrite>
in config.xml
file.
So, you have to copy the file app/code/core/Mage/Checkout/Block/Onepage/Abstract.php
to app/code/local/Mage/Checkout/Block/Onepage/Abstract.php
, edit the file by adding (if you use Magento 1.5) or editing (if you use Magento >= 1.6), the method _getStepCodes
as showned below. In this case, you can change the order of the steps, add your own or remove steps. Take care of the consequences of such changes.
abstract class Mage_Checkout_Block_Onepage_Abstract extends Mage_Core_Block_Template {
...
/**
* Get checkout steps codes
* diglin - method took from Magento 1.6 but add a dispatch and $transport to allow to hook the code
*
* @return array
*/
protected function _getStepCodes()
{
$data = new Varien_Object();
$data->setStepCodes(array('login', 'billing', 'shipping', 'shipping_method', 'payment', 'review'));
Mage::dispatchEvent('checkout_onepage_stepcodes', array('transport' => $data));
return $data->getStepCodes();
}
}
EDIT
The code I provide here was a code proposed to Magento core team to allow customized steps, that's one of the reason why the Mage namespace and the Abstract are used.
The block checkout/onepage
class is also rewritten:
class Mage_Checkout_Block_Onepage extends Mage_Checkout_Block_Onepage_Abstract
{
/**
* 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;
}
public function getActiveStep()
{
// diglin - add the $stepCodes to provide custom step
$stepCodes = $this->_getStepCodes();
return $this->isCustomerLoggedIn() ? $stepCodes[1] : $stepCodes[0]; //custom / billing Step or Login Step
}
Tested on 2.1.6
and 2.1.8
works just fine. I injected the helper into a footer copyright plugin for proof of concept.
File Structure
app/code/Supravat/
└── Customer
├── Helper
│ └── Customer.php
├── Plugin
│ └── Magento
│ └── Theme
│ └── Block
│ └── Html
│ └── Footer.php
├── etc
│ ├── di.xml
│ └── module.xml
└── registration.php
registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Supravat_Customer',
__DIR__
);
module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Supravat_Customer" setup_version="0.0.1"/>
</config>
di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Theme\Block\Html\Footer">
<plugin name="supravat_customer_magento_theme_block_html_footer" type="Supravat\Customer\Plugin\Magento\Theme\Block\Html\Footer"/>
</type>
</config>
Customer.php
<?php
namespace Supravat\Customer\Helper;
class Customer extends \Magento\Framework\App\Helper\AbstractHelper
{
protected $customerRepositoryInterface;
public function __construct(
\Magento\Framework\App\Helper\Context $context,
\Magento\Customer\Api\CustomerRepositoryInterface $customerRepositoryInterface
) {
parent::__construct($context);
$this->customerRepositoryInterface = $customerRepositoryInterface;
}
public function getCustomerById($customerId)
{
$customer = $this->customerRepositoryInterface->getById($customerId);
return var_export($customer->__toArray(), true);
}
}
Footer.php
<?php
namespace Supravat\Customer\Plugin\Magento\Theme\Block\Html;
use Supravat\Customer\Helper\Customer as Helper;
class Footer
{
protected $helper;
public function __construct(Helper $helper)
{
$this->helper = $helper;
}
public function afterGetCopyright(
\Magento\Theme\Block\Html\Footer $subject,
$result
) {
return $this->helper->getCustomerById(1);
}
}
Once all files are in place:
./bin/magento --clear-static-content module:enable Supravat_Customer
./bin/magento setup:upgrade
./bin/magento setup:di:compile
Refresh the home page and you should see the customer's information in the footer.
This is obviously just a proof of concept, there isn't any good reason why you'd want the customer's information dumped in the footer copyright, but it shows you that it works out of the box.
Best Answer
You can do this by calling the
Magento\Quote\Api\Data\ShippingMethodInterface
. Add it to your constructor and get it by using this code :