'Magento 2 - New custom URL for custom checkout page
I need to create new checkout page with new url and need to show my custom address fields in that custom checkout page.
My way is :
Create new custom checkout module ( CustomCheckout )
Create new route ( like custom-checkout )
Copy and paste the checkout_index_index.xm layout in my custom
checkout module
Is that correct way ? pls give a solution ?
/etc/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="Mymodule_CustomCheckout" setup_version="0.0.1">
</module>
</config>
/etc/frontend/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="standard">
<route id="customcheckout" frontName="customcheckout">
<module name="Mymodule_CustomCheckout"/>
</route>
</router>
</config>
Controller/Index/Index.php
namespace Mymodule\CustomCheckout\Controller\Index;
class Index extends \Magento\Framework\App\Action\Action
{
public function execute()
{
$this->_view->loadLayout();
//$this->_view->getLayout()->initMessages();
$this->_view->renderLayout();
}
}
/view/frontend/layout/customcheckout_index_index.xml
//Copy and paste checkout_index_index.xml from magento-checkout module
Solution 1:[1]
You can acheive this by simply add before attribute in module tag.
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="standard">
<route id="checkout" frontName="checkout">
<module name="Mymodule_CustomCheckout" before="Magento_Checkout"/>
</route>
</router>
so magento then call your custom checkout route instead of core checkout controller. so accordingly you can change the layout and all.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Narendra Singh |
