0

I have a block that display in shipping-address-fieldset and i have try to move it using layout but i'm failing. i want it to be displayed below Shipping Methods. please help

Below is the layout file

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="checkout.root">
           <arguments>
               <argument name="jsLayout" xsi:type="array">
                   <item name="components" xsi:type="array">
                       <item name="checkout" xsi:type="array">
                           <item name="children" xsi:type="array">
                               <item name="steps" xsi:type="array">
                                   <item name="children" xsi:type="array">
                                       <item name="shipping-step" xsi:type="array">
                                           <item name="children" xsi:type="array">
                                               <item name="shippingAddress" xsi:type="array">
                                                   <item name="children" xsi:type="array">
                                                       <item name="shipping-address-fieldset" xsi:type="array">
                                                           <item name="children" xsi:type="array">
                                                               <item name="cms-block" xsi:type="array">
                                                                   <item name="component" xsi:type="string">uiComponent</item>
                                                                   <item name="config" xsi:type="array">
                                                                       <item name="template" xsi:type="string">ShipMethod_CarrierDisplay/cms-block</item>
                                                                   </item>
                                                               </item>
                                                           </item>
                                                       </item>
                                                   </item>
                                               </item>
                                           </item>
                                       </item>
                                   </item>
                               </item>
                           </item>
                       </item>
                   </item>
               </argument>
           </arguments>
       </referenceBlock>

    </body>
</page>

Below is the method file

<?php
namespace ShipMethod\CarrierDisplay\Model;

use Magento\Checkout\Model\ConfigProviderInterface;
use Magento\Cms\Block\Widget\Block;
 
class ConfigProvider implements ConfigProviderInterface
{
   protected $cmsBlockWidget;
 
   public function __construct(
    Block $block, $blockId)
   {
       $this->cmsBlockWidget = $block;
       $block->setData('block_id', $blockId);
       $block->setTemplate('ShipMethod_CarrierDisplay::default.phtml');
   }
   public function getConfig()
   {
       return [
           'cms_block' => $this->cmsBlockWidget->toHtml()
       ];
   }
}

template file

<?php
    $_product = $block->getProduct();
    $ObjectManager = \Magento\Framework\App\ObjectManager::getInstance();
    $storeManager = $ObjectManager->get('\Magento\Store\Model\StoreManagerInterface');
?>

<label class="label" style="color:red;">This is a test</label>

HTML file

<div data-bind="html: window.checkoutConfig.cms_block"> </div>

1 Answer 1

0

Overwrite the file vendor/magento/module-checkout/view/frontend/web/template/shipping.html and at the bottom of the file call your custom block

eg.

app/design/frontend/[Theme_Vendor]/[Theme]/Magento_Checkout/web/template/shipping.html
1
  • thank you for response but what i need is to move the layout to be below shipping methods
    – Bayzel
    Jun 24 at 13:11

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.