{"id":132280,"date":"2018-08-22T00:07:44","date_gmt":"2018-08-22T00:07:44","guid":{"rendered":"http:\/\/inchoo.net\/?p=31722"},"modified":"2018-08-22T00:07:44","modified_gmt":"2018-08-22T00:07:44","slug":"how-to-display-cms-block-in-magento-2-checkout","status":"publish","type":"post","link":"https:\/\/www.sushilkumar.ind.in\/blog\/magento-2\/how-to-display-cms-block-in-magento-2-checkout\/","title":{"rendered":"How to display CMS block in Magento 2 Checkout"},"content":{"rendered":"<p>Working with CMS blocks was one of the reasons Magento was and is so popular. Using CMS blocks, site administrator can easily manipulate content of the store. CMS blocks can be used to display promotional banners, sale blocks, return policies, important information message on some sections of the store etc. CMS blocks can carry plain text or chunks of HTML\/JS\/CSS code which means they can be used for even more complex content delivery like sliders, product carousels etc.<\/p>\n<p>I personally like to use CMS blocks whenever I can so that content of the store becomes more \u201cmodular\u201d and easily manageable.<span id=\"more-31722\"><\/span><\/p>\n<p>CMS blocks at checkout can have many usages like displaying some information for specific shipping method of some promotional content in order to convince the user to spend more before he checks out.<\/p>\n<p>Adding CMS block to some specific position\/page is not such a hassle, we just need to \u201cregister\u201d our CMS block in layouts and define order\/position of our CMS block. We then need to call it in templates and that\u2019s it. CMS block is now part of the content and will be rendered\/delivered when needed.<\/p>\n<p>Adding CMS block to Magento 2 Checkout is a bit more complex task since the whole checkout is built up from a series of <strong>KnockoutJS<\/strong> components which are then rendered using the knockout.js templating system. Magento 2 defines these components and their mutual relationship in a large XML file. To pull the data from the server, Magento uses global Javascript variable <strong>window.checkoutConfig<\/strong> which is then used by Knockout.js to compute and display information on the frontend.<\/p>\n<p>In short, the whole checkout is dynamically loaded and we can&#8217;t put anything \u201cstatic\u201d inside.<\/p>\n<p>Hopefully, there is a way to insert CMS block inside checkout flow.<\/p>\n<p>Since the whole checkout is bundled from various JS components, approaches on this task will vary depending on the CMS block position. However, each approach has the same initial step.<\/p>\n<p>Idea is to take content from CMS block and put it in JS object which will then be outputted to frontend via Knockout Bindings. That way, our CMS content becomes part of the checkout flow and it is loaded alongside with other components. If you want to hang out with components, act as a component!<\/p>\n<h2>Creating a module<\/h2>\n<p>If you don\u2019t know how to create Magento 2 module, follow steps in <a href=\"https:\/\/inchoo.net\/magento-2\/how-to-create-a-basic-module-in-magento-2\/\" target=\"_blank\" rel=\"noopener\">this article<\/a> by my colleague <a href=\"http:\/\/inchoo.net\/author\/hrvoje-ivancic\/profile\/\">Hrvoje Ivancic<\/a>.<\/p>\n<p>I would suggest that you use <a href=\"https:\/\/github.com\/netz98\/n98-magerun\" target=\"_blank\" rel=\"noopener\">netz98 magerun CLI<\/a> tools extension which is a helpful asset during development. For example, you can create a module with all necessary files with just one command.<\/p>\n<p>Name the module as you wish. I will use Vendor for <strong>vendor<\/strong> and <strong>ModuleName<\/strong> for module name.<\/p>\n<p>After you have created module with all necessary files, we will add\/edit few of them to achieve our goals.<br \/>\nPlease, don&#8217;t forget to do setup:upgrade after you have created your module.<\/p>\n<h2>Adding CMS block in Checkout sidebar<\/h2>\n<p>Edit <em>Vendor\/ModuleName\/etc\/frontend\/di.xml<\/em> file:<\/p>\n<pre class=\"ish\"><code class=\"language-text\">&lt;?xml version=&quot;1.0&quot;?&gt;\n&lt;config xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:ObjectManager\/etc\/config.xsd&quot;&gt; &lt;type name=&quot;Magento\\Checkout\\Model\\CompositeConfigProvider&quot;&gt; &lt;arguments&gt; &lt;argument name=&quot;configProviders&quot; xsi:type=&quot;array&quot;&gt; &lt;item name=&quot;cms_block_config_provider&quot; xsi:type=&quot;object&quot;&gt;Vendor\\ModuleName\\Model\\ConfigProvider&lt;\/item&gt; &lt;\/argument&gt; &lt;\/arguments&gt; &lt;\/type&gt; &lt;type name=&quot;Vendor\\ModuleName\\Model\\ConfigProvider&quot;&gt; &lt;arguments&gt; &lt;argument name=&quot;blockId&quot; xsi:type=&quot;string&quot;&gt;checkout_cms_block&lt;\/argument&gt; &lt;\/arguments&gt; &lt;\/type&gt;\n&lt;\/config&gt;<\/code><\/pre>\n<p>With this code, we are adding new entry to <strong>ConfigProvider<\/strong> and we are also declaring CMS block which will be used to parse data from.<br \/>\nIn the above example, a block is named \u201ccheckout_cms_block\u201d (it works with id or identifier of the block).<\/p>\n<p>Please make sure that and paths match the name of your block. In above example, path is <em>Vendor\\ModuleName\\Model\\ConfigProvider<\/em>.<\/p>\n<p>Next, we will create new entry for Config Provider by creating or editing <em>Vendor\/ModuleName\/Model\/ConfigProvider.php<\/em>:<\/p>\n<pre class=\"ish\"><code class=\"language-php\"><span class=\"kw2\">&lt;?php<\/span> <span class=\"kw2\">namespace<\/span> Vendor\\ModuleName\\Model<span class=\"sy0\">;<\/span>\n&nbsp;\n<span class=\"kw2\">use<\/span> Magento\\Checkout\\Model\\ConfigProviderInterface<span class=\"sy0\">;<\/span>\n<span class=\"kw2\">use<\/span> Magento\\Framework\\View\\LayoutInterface<span class=\"sy0\">;<\/span>\n&nbsp;\n<span class=\"kw2\">class<\/span> ConfigProvider implements ConfigProviderInterface\n<span class=\"br0\">&#123;<\/span> <span class=\"co4\">\/** @var LayoutInterface *\/<\/span> <span class=\"kw2\">protected<\/span> <span class=\"re0\">$_layout<\/span><span class=\"sy0\">;<\/span> <span class=\"kw2\">protected<\/span> <span class=\"re0\">$cmsBlock<\/span><span class=\"sy0\">;<\/span>\n&nbsp; <span class=\"kw2\">public<\/span> <span class=\"kw2\">function<\/span> __construct<span class=\"br0\">&#40;<\/span>LayoutInterface <span class=\"re0\">$layout<\/span><span class=\"sy0\">,<\/span> <span class=\"re0\">$blockId<\/span><span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span> <span class=\"re0\">$this<\/span><span class=\"sy0\">-&gt;<\/span>_layout <span class=\"sy0\">=<\/span> <span class=\"re0\">$layout<\/span><span class=\"sy0\">;<\/span> <span class=\"re0\">$this<\/span><span class=\"sy0\">-&gt;<\/span><span class=\"me1\">cmsBlock<\/span> <span class=\"sy0\">=<\/span> <span class=\"re0\">$this<\/span><span class=\"sy0\">-&gt;<\/span><span class=\"me1\">constructBlock<\/span><span class=\"br0\">&#40;<\/span><span class=\"re0\">$blockId<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span> <span class=\"br0\">&#125;<\/span>\n&nbsp; <span class=\"kw2\">public<\/span> <span class=\"kw2\">function<\/span> constructBlock<span class=\"br0\">&#40;<\/span><span class=\"re0\">$blockId<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#123;<\/span> <span class=\"re0\">$block<\/span> <span class=\"sy0\">=<\/span> <span class=\"re0\">$this<\/span><span class=\"sy0\">-&gt;<\/span>_layout<span class=\"sy0\">-&gt;<\/span><span class=\"me1\">createBlock<\/span><span class=\"br0\">&#40;<\/span><span class=\"st_h\">'Magento\\Cms\\Block\\Block'<\/span><span class=\"br0\">&#41;<\/span> <span class=\"sy0\">-&gt;<\/span><span class=\"me1\">setBlockId<\/span><span class=\"br0\">&#40;<\/span><span class=\"re0\">$blockId<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">-&gt;<\/span><span class=\"me1\">toHtml<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span> <span class=\"kw1\">return<\/span> <span class=\"re0\">$block<\/span><span class=\"sy0\">;<\/span> <span class=\"br0\">&#125;<\/span>\n&nbsp; <span class=\"kw2\">public<\/span> <span class=\"kw2\">function<\/span> getConfig<span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span> <span class=\"kw1\">return<\/span> <span class=\"br0\">[<\/span> <span class=\"st_h\">'cms_block'<\/span> <span class=\"sy0\">=&gt;<\/span> <span class=\"re0\">$this<\/span><span class=\"sy0\">-&gt;<\/span><span class=\"me1\">cmsBlock<\/span> <span class=\"br0\">]<\/span><span class=\"sy0\">;<\/span> <span class=\"br0\">&#125;<\/span>\n<span class=\"br0\">&#125;<\/span><\/code><\/pre>\n<p>Since we have added our own variable to global <strong>window.checkoutConfig<\/strong> variable, we can now call that content using <strong>window.checkoutConfig.cms_block<\/strong> variable.<\/p>\n<p>Now we just need to bind that variable to some HTML element and Knockout.JS will do the rest.<\/p>\n<p>Here is <em>app\/design\/frontend\/Vendor\/ThemeName\/Magento_Checkout\/web\/template\/sidebar.html<\/em><\/p>\n<pre class=\"ish\"><code class=\"language-html\"> &lt;div id=&quot;opc-sidebar&quot; data-bind=&quot;afterRender:setModalElement, mageInit: { 'Magento_Ui\/js\/modal\/modal':{ 'type': 'custom', 'modalClass': 'opc-sidebar opc-summary-wrapper', 'wrapperClass': 'checkout-container', 'parentModalClass': '_has-modal-custom', 'responsive': true, 'responsiveClass': 'custom-slide', 'overlayClass': 'modal-custom-overlay', 'buttons': [] }}&quot;&gt; &nbsp; &lt;!-- ko foreach: getRegion('summary') --&gt; &lt;!-- ko template: getTemplate() --&gt;&lt;!-- \/ko --&gt; &lt;!--\/ko--&gt; &nbsp; &lt;div data-bind=&quot;html: window.checkoutConfig.cms_block&quot;&gt;&lt;\/div&gt; &nbsp; &lt;div class=&quot;opc-block-shipping-information&quot;&gt; &lt;!-- ko foreach: getRegion('shipping-information') --&gt; &lt;!-- ko template: getTemplate() --&gt;&lt;!-- \/ko --&gt; &lt;!--\/ko--&gt; &lt;\/div&gt; &lt;\/div&gt;<\/code><\/pre>\n<p>And that\u2019s it. <\/p>\n<p>If you did everything right, you should see your CMS block displayed in the sidebar.<\/p>\n<p>Please, note that I&#8217;ve created sidebar.html template in my package\/theme. Never edit files directly in vendor\/magento\/* folder.<\/p>\n<h2>Adding CMS block to address form<\/h2>\n<p>For this task, we will use a bit different approach.<br \/>\nWe will change the content of <em>app\/code\/Vendor\/ModuleName\/Model\/ConfigProvider.php<\/em><br \/>\nto this:<\/p>\n<pre class=\"ish\"><code class=\"language-php\"><span class=\"kw2\">&lt;?php<\/span>\n&nbsp;\n<span class=\"kw2\">namespace<\/span> Vendor\\ModuleName\\Model<span class=\"sy0\">;<\/span>\n&nbsp;\n&nbsp;\n<span class=\"kw2\">use<\/span> Magento\\Checkout\\Model\\ConfigProviderInterface<span class=\"sy0\">;<\/span>\n<span class=\"kw2\">use<\/span> Magento\\Cms\\Block\\Widget\\Block<span class=\"sy0\">;<\/span>\n&nbsp;\n<span class=\"kw2\">class<\/span> ConfigProvider implements ConfigProviderInterface\n<span class=\"br0\">&#123;<\/span> <span class=\"kw2\">protected<\/span> <span class=\"re0\">$cmsBlockWidget<\/span><span class=\"sy0\">;<\/span>\n&nbsp; <span class=\"kw2\">public<\/span> <span class=\"kw2\">function<\/span> __construct<span class=\"br0\">&#40;<\/span>Block <span class=\"re0\">$block<\/span><span class=\"sy0\">,<\/span> <span class=\"re0\">$blockId<\/span><span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span> <span class=\"re0\">$this<\/span><span class=\"sy0\">-&gt;<\/span><span class=\"me1\">cmsBlockWidget<\/span> <span class=\"sy0\">=<\/span> <span class=\"re0\">$block<\/span><span class=\"sy0\">;<\/span> <span class=\"re0\">$block<\/span><span class=\"sy0\">-&gt;<\/span><span class=\"me1\">setData<\/span><span class=\"br0\">&#40;<\/span><span class=\"st_h\">'block_id'<\/span><span class=\"sy0\">,<\/span> <span class=\"re0\">$blockId<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span> <span class=\"re0\">$block<\/span><span class=\"sy0\">-&gt;<\/span><span class=\"me1\">setTemplate<\/span><span class=\"br0\">&#40;<\/span><span class=\"st_h\">'Magento_Cms::widget\/static_block\/default.phtml'<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span> <span class=\"br0\">&#125;<\/span>\n&nbsp; <span class=\"kw2\">public<\/span> <span class=\"kw2\">function<\/span> getConfig<span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span> <span class=\"kw1\">return<\/span> <span class=\"br0\">[<\/span> <span class=\"st_h\">'cms_block'<\/span> <span class=\"sy0\">=&gt;<\/span> <span class=\"re0\">$this<\/span><span class=\"sy0\">-&gt;<\/span><span class=\"me1\">cmsBlockWidget<\/span><span class=\"sy0\">-&gt;<\/span><span class=\"me1\">toHtml<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span> <span class=\"br0\">]<\/span><span class=\"sy0\">;<\/span> <span class=\"br0\">&#125;<\/span>\n<span class=\"br0\">&#125;<\/span><\/code><\/pre>\n<p>Then, create <em>app\/code\/Vendor\/ModuleName\/view\/frontend\/layout\/checkout_index_index.xml<\/em><br \/>\nwith this content:<\/p>\n<pre class=\"ish\"><code class=\"language-xml\"><span class=\"sc3\"><span class=\"re1\">&lt;?xml<\/span> <span class=\"re0\">version<\/span>=<span class=\"st0\">&quot;1.0&quot;<\/span><span class=\"re2\">?&gt;<\/span><\/span>\n&nbsp;\n<span class=\"sc3\"><span class=\"re1\">&lt;page<\/span> <span class=\"re0\">xmlns:xsi<\/span>=<span class=\"st0\">&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot;<\/span> <span class=\"re0\">layout<\/span>=<span class=\"st0\">&quot;checkout&quot;<\/span> <span class=\"re0\">xsi:noNamespaceSchemaLocation<\/span>=<span class=\"st0\">&quot;urn:magento:framework:View\/Layout\/etc\/page_configuration.xsd&quot;<\/span><span class=\"re2\">&gt;<\/span><\/span> <span class=\"sc3\"><span class=\"re1\">&lt;body<span class=\"re2\">&gt;<\/span><\/span><\/span> <span class=\"sc3\"><span class=\"re1\">&lt;referenceBlock<\/span> <span class=\"re0\">name<\/span>=<span class=\"st0\">&quot;checkout.root&quot;<\/span><span class=\"re2\">&gt;<\/span><\/span> <span class=\"sc3\"><span class=\"re1\">&lt;arguments<span class=\"re2\">&gt;<\/span><\/span><\/span> <span class=\"sc3\"><span class=\"re1\">&lt;argument<\/span> <span class=\"re0\">name<\/span>=<span class=\"st0\">&quot;jsLayout&quot;<\/span> <span class=\"re0\">xsi:type<\/span>=<span class=\"st0\">&quot;array&quot;<\/span><span class=\"re2\">&gt;<\/span><\/span> <span class=\"sc3\"><span class=\"re1\">&lt;item<\/span> <span class=\"re0\">name<\/span>=<span class=\"st0\">&quot;components&quot;<\/span> <span class=\"re0\">xsi:type<\/span>=<span class=\"st0\">&quot;array&quot;<\/span><span class=\"re2\">&gt;<\/span><\/span> <span class=\"sc3\"><span class=\"re1\">&lt;item<\/span> <span class=\"re0\">name<\/span>=<span class=\"st0\">&quot;checkout&quot;<\/span> <span class=\"re0\">xsi:type<\/span>=<span class=\"st0\">&quot;array&quot;<\/span><span class=\"re2\">&gt;<\/span><\/span> <span class=\"sc3\"><span class=\"re1\">&lt;item<\/span> <span class=\"re0\">name<\/span>=<span class=\"st0\">&quot;children&quot;<\/span> <span class=\"re0\">xsi:type<\/span>=<span class=\"st0\">&quot;array&quot;<\/span><span class=\"re2\">&gt;<\/span><\/span> <span class=\"sc3\"><span class=\"re1\">&lt;item<\/span> <span class=\"re0\">name<\/span>=<span class=\"st0\">&quot;steps&quot;<\/span> <span class=\"re0\">xsi:type<\/span>=<span class=\"st0\">&quot;array&quot;<\/span><span class=\"re2\">&gt;<\/span><\/span> <span class=\"sc3\"><span class=\"re1\">&lt;item<\/span> <span class=\"re0\">name<\/span>=<span class=\"st0\">&quot;children&quot;<\/span> <span class=\"re0\">xsi:type<\/span>=<span class=\"st0\">&quot;array&quot;<\/span><span class=\"re2\">&gt;<\/span><\/span> <span class=\"sc3\"><span class=\"re1\">&lt;item<\/span> <span class=\"re0\">name<\/span>=<span class=\"st0\">&quot;shipping-step&quot;<\/span> <span class=\"re0\">xsi:type<\/span>=<span class=\"st0\">&quot;array&quot;<\/span><span class=\"re2\">&gt;<\/span><\/span> <span class=\"sc3\"><span class=\"re1\">&lt;item<\/span> <span class=\"re0\">name<\/span>=<span class=\"st0\">&quot;children&quot;<\/span> <span class=\"re0\">xsi:type<\/span>=<span class=\"st0\">&quot;array&quot;<\/span><span class=\"re2\">&gt;<\/span><\/span> <span class=\"sc3\"><span class=\"re1\">&lt;item<\/span> <span class=\"re0\">name<\/span>=<span class=\"st0\">&quot;shippingAddress&quot;<\/span> <span class=\"re0\">xsi:type<\/span>=<span class=\"st0\">&quot;array&quot;<\/span><span class=\"re2\">&gt;<\/span><\/span> <span class=\"sc3\"><span class=\"re1\">&lt;item<\/span> <span class=\"re0\">name<\/span>=<span class=\"st0\">&quot;children&quot;<\/span> <span class=\"re0\">xsi:type<\/span>=<span class=\"st0\">&quot;array&quot;<\/span><span class=\"re2\">&gt;<\/span><\/span> <span class=\"sc3\"><span class=\"re1\">&lt;item<\/span> <span class=\"re0\">name<\/span>=<span class=\"st0\">&quot;shipping-address-fieldset&quot;<\/span> <span class=\"re0\">xsi:type<\/span>=<span class=\"st0\">&quot;array&quot;<\/span><span class=\"re2\">&gt;<\/span><\/span> <span class=\"sc3\"><span class=\"re1\">&lt;item<\/span> <span class=\"re0\">name<\/span>=<span class=\"st0\">&quot;children&quot;<\/span> <span class=\"re0\">xsi:type<\/span>=<span class=\"st0\">&quot;array&quot;<\/span><span class=\"re2\">&gt;<\/span><\/span> <span class=\"sc3\"><span class=\"re1\">&lt;item<\/span> <span class=\"re0\">name<\/span>=<span class=\"st0\">&quot;cms-block&quot;<\/span> <span class=\"re0\">xsi:type<\/span>=<span class=\"st0\">&quot;array&quot;<\/span><span class=\"re2\">&gt;<\/span><\/span> <span class=\"sc3\"><span class=\"re1\">&lt;item<\/span> <span class=\"re0\">name<\/span>=<span class=\"st0\">&quot;component&quot;<\/span> <span class=\"re0\">xsi:type<\/span>=<span class=\"st0\">&quot;string&quot;<\/span><span class=\"re2\">&gt;<\/span><\/span>uiComponent<span class=\"sc3\"><span class=\"re1\">&lt;\/item<span class=\"re2\">&gt;<\/span><\/span><\/span> <span class=\"sc3\"><span class=\"re1\">&lt;item<\/span> <span class=\"re0\">name<\/span>=<span class=\"st0\">&quot;config&quot;<\/span> <span class=\"re0\">xsi:type<\/span>=<span class=\"st0\">&quot;array&quot;<\/span><span class=\"re2\">&gt;<\/span><\/span> <span class=\"sc3\"><span class=\"re1\">&lt;item<\/span> <span class=\"re0\">name<\/span>=<span class=\"st0\">&quot;template&quot;<\/span> <span class=\"re0\">xsi:type<\/span>=<span class=\"st0\">&quot;string&quot;<\/span><span class=\"re2\">&gt;<\/span><\/span>Vendor_ModuleName\/cms-block<span class=\"sc3\"><span class=\"re1\">&lt;\/item<span class=\"re2\">&gt;<\/span><\/span><\/span> <span class=\"sc3\"><span class=\"re1\">&lt;\/item<span class=\"re2\">&gt;<\/span><\/span><\/span> <span class=\"sc3\"><span class=\"re1\">&lt;item<\/span> <span class=\"re0\">name<\/span>=<span class=\"st0\">&quot;sortOrder&quot;<\/span> <span class=\"re0\">xsi:type<\/span>=<span class=\"st0\">&quot;string&quot;<\/span><span class=\"re2\">&gt;<\/span><\/span>1<span class=\"sc3\"><span class=\"re1\">&lt;\/item<span class=\"re2\">&gt;<\/span><\/span><\/span> <span class=\"sc3\"><span class=\"re1\">&lt;\/item<span class=\"re2\">&gt;<\/span><\/span><\/span> <span class=\"sc3\"><span class=\"re1\">&lt;\/item<span class=\"re2\">&gt;<\/span><\/span><\/span> <span class=\"sc3\"><span class=\"re1\">&lt;\/item<span class=\"re2\">&gt;<\/span><\/span><\/span> <span class=\"sc3\"><span class=\"re1\">&lt;\/item<span class=\"re2\">&gt;<\/span><\/span><\/span> <span class=\"sc3\"><span class=\"re1\">&lt;\/item<span class=\"re2\">&gt;<\/span><\/span><\/span> <span class=\"sc3\"><span class=\"re1\">&lt;\/item<span class=\"re2\">&gt;<\/span><\/span><\/span> <span class=\"sc3\"><span class=\"re1\">&lt;\/item<span class=\"re2\">&gt;<\/span><\/span><\/span> <span class=\"sc3\"><span class=\"re1\">&lt;\/item<span class=\"re2\">&gt;<\/span><\/span><\/span> <span class=\"sc3\"><span class=\"re1\">&lt;\/item<span class=\"re2\">&gt;<\/span><\/span><\/span> <span class=\"sc3\"><span class=\"re1\">&lt;\/item<span class=\"re2\">&gt;<\/span><\/span><\/span> <span class=\"sc3\"><span class=\"re1\">&lt;\/item<span class=\"re2\">&gt;<\/span><\/span><\/span> <span class=\"sc3\"><span class=\"re1\">&lt;\/item<span class=\"re2\">&gt;<\/span><\/span><\/span> <span class=\"sc3\"><span class=\"re1\">&lt;\/argument<span class=\"re2\">&gt;<\/span><\/span><\/span> <span class=\"sc3\"><span class=\"re1\">&lt;\/arguments<span class=\"re2\">&gt;<\/span><\/span><\/span> <span class=\"sc3\"><span class=\"re1\">&lt;\/referenceBlock<span class=\"re2\">&gt;<\/span><\/span><\/span> <span class=\"sc3\"><span class=\"re1\">&lt;\/body<span class=\"re2\">&gt;<\/span><\/span><\/span>\n<span class=\"sc3\"><span class=\"re1\">&lt;\/page<span class=\"re2\">&gt;<\/span><\/span><\/span><\/code><\/pre>\n<p>We have now added new UIcomponent to the address form. That component will hold the content of our CMS block. As I mentioned above, components load order is managed inside XML files. As you can see, I have set 1 for sortOrder with means my component will be loaded first inside address form.<br \/>\nWatch for this line <strong><item name=\"template\" xsi:type=\"string\">Vendor_ModuleName\/cms-block<\/item><\/strong> and change it.<br \/>\nNow that we have everything set, we just need a knockout template to output the CMS block data.<\/p>\n<p>Create <em>app\/code\/Vendor\/ModuleName\/view\/frontend\/web\/template\/cms-block.html<\/em><br \/>\nwith this content:<\/p>\n<pre class=\"ish\"><code class=\"language-html\">&lt;div data-bind=&quot;html: window.checkoutConfig.cms_block&quot;&gt;&lt;\/div&gt;<\/code><\/pre>\n<p>And that\u2019s it. Now your CMS block should be displayed in address form and rendered first.<br \/>\nGiven examples work with clean Magento 2.2 installation. Luma theme was used for testing purposes.<\/p>\n<p>If something is not working, please check:<\/p>\n<ul>\n<li>is your module properly created and consist all config files with proper values inside?<\/li>\n<li>did you run php bin\/magento setup:upgrade after creating module?<\/li>\n<li>check if you have properly changed code from this article by replacing Vendor\/ModuleName with proper vendor and name of your module!<\/li>\n<\/ul>\n<p>Thanks for reading! \ud83d\ude42<\/p>\n<p>The post <a rel=\"nofollow\" href=\"https:\/\/inchoo.net\/magento-2\/display-cms-block-magento-2-checkout\/\">How to display CMS block in Magento 2 Checkout<\/a> appeared first on <a rel=\"nofollow\" href=\"https:\/\/inchoo.net\">Inchoo<\/a>.<\/p>\n<h1><a target=\"_blank\" href=\"http:\/\/www.circulatetechnology.com\/\">Click here for more informations about top website development services <\/a><\/h1>\n","protected":false},"excerpt":{"rendered":"<p>Working with CMS blocks was one of the reasons Magento was and is so popular. Using CMS blocks, site administrator can easily manipulate content of the store. CMS blocks can be used to display promotional banners, sale blocks, return policies, important information message on some sections of the store etc. CMS blocks can carry plain &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[361,1149,20],"tags":[],"class_list":["post-132280","post","type-post","status-publish","format-standard","","category-checkout","category-cms-block","category-magento-2"],"jetpack_publicize_connections":[],"acf":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p99pkJ-ypy","_links":{"self":[{"href":"https:\/\/www.sushilkumar.ind.in\/blog\/wp-json\/wp\/v2\/posts\/132280"}],"collection":[{"href":"https:\/\/www.sushilkumar.ind.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sushilkumar.ind.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sushilkumar.ind.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sushilkumar.ind.in\/blog\/wp-json\/wp\/v2\/comments?post=132280"}],"version-history":[{"count":0,"href":"https:\/\/www.sushilkumar.ind.in\/blog\/wp-json\/wp\/v2\/posts\/132280\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sushilkumar.ind.in\/blog\/wp-json\/wp\/v2\/media?parent=132280"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sushilkumar.ind.in\/blog\/wp-json\/wp\/v2\/categories?post=132280"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sushilkumar.ind.in\/blog\/wp-json\/wp\/v2\/tags?post=132280"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}