If you want to show some text or message using CMS block below Order Summary section on Checkout Page, then follow below steps.
Step 1 : Create file like app/code/Magemonkeys/Belowordersummary/registration.php
1 2 3 4 5 6 7 |
<?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, 'Magemonkeys_Belowordersummary', __DIR__ ); |
Step 2 : Create file like app/code/Magemonkeys/Belowordersummary/etc/frontend/di.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<?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\Checkout\Model\CompositeConfigProvider"> <arguments> <argument name="configProviders" xsi:type="array"> <item name="cms_block_config_provider" xsi:type="object">Magemonkeys\Belowordersummary\Model\CmsConfigProvider</item> </argument> </arguments> </type> <type name="Magemonkeys\Belowordersummary\Model\CmsConfigProvider"> <arguments> <argument name="blockId" xsi:type="string">checkout-cms-block</argument> </arguments> </type> </config> |
Step 3 : Create file like app/code/Magemonkeys/Belowordersummary/etc/module.xml
1 2 3 4 |
<?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="Magemonkeys_Belowordersummary" setup_version="1.0.0"></module> </config> |
Step 4 : Create file like app/code/Magemonkeys/Belowordersummary/Model/CmsConfigProvider.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
<?php namespace Magemonkeys\Belowordersummary\Model; use \Magento\Checkout\Model\ConfigProviderInterface; use Magento\Framework\View\LayoutInterface; use \Magento\Store\Model\StoreManagerInterface; /** * Class ConfigProvider * @codeCoverageIgnore */ final class CmsConfigProvider implements ConfigProviderInterface { private $layout; private $storeManager; private $cmsBlock; public function __construct(LayoutInterface $layout, StoreManagerInterface $storeManager, $blockId) { $this->layout = $layout; $this->storeManager = $storeManager; $this->cmsBlock = $blockId; } public function getStoreId() { return $this->storeManager->getStore()->getId(); } public function constructBlock($blockId) { $storeId = $this->getStoreId(); $block = $this->layout->createBlock('Magento\Cms\Block\Block')->setBlockId($blockId)->setStoreId($storeId)->toHtml(); return $block; } public function getConfig() { $cmsBlock = ''; $blockId = $this->cmsBlock; if (isset($blockId) && $blockId != '') { $cmsBlock = $this->constructBlock($blockId); } return ['cms_block' => $cmsBlock]; } } |
Step 5 : Copy file sidebar.html in your theme from vendor/magento/module-checkout/view/frontend/web/template/sidebar.html
Add this code in your sidebar.html
1 2 3 |
<div class="opc-block-shipping-information"> <div data-bind="html: window.checkoutConfig.cms_block"></div> </div> |
That’s it…
Now, you can check your Checkout Page. It will show your text or message which is set in static block as displaying below Order Summery section.
[crayon-63e0980fd6f19460030917/] Using above fucntion Images can be imported directly from...
Override view block using di.xml and add the below code...
You can check a list of called layout XML for...
Follow the below steps to install and set up PWA...
If you want to remove all leading zero's from order,...
Let our Magento expert connect to discuss your requirement.
We offer Magento
certified developers.
Our Magento clientele
is 500+.
We sign NDA for the
security of your projects.
We’ve performed 100+
Magento migration projects.
Free quotation
on your project.
Three months warranty on
code developed by us.