1

I'm trying to add the header and footer to a template in an extension called iwd one page checkout.

Please note the solution posted here does not seem to have any effect:

Magento 2.2 IWD Onepage Checkout Issue

I've identified the layout file as:

magento\app\code\IWD\Opc\view\frontend\layout\onepage_index_index.xml

which contains

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      layout="checkout"
      xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <update handle="checkout_index_index"/>
    <head>
        <css src="//fonts.googleapis.com/css?family=Open+Sans:400,400italic,700italic,700" src_type="url"/>
        <css src="//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" src_type="url"/>
    </head>
    <body>
        <referenceBlock name="page.main.title" remove="true"/>
        <referenceBlock name="iwd_opc_ga_ab" remove="true"/>
        <referenceBlock name="checkout.root">
            <action method="setTemplate">
                <argument name="template" xsi:type="string">IWD_Opc::onepage.phtml</argument>
            </action>
            <block class="Magento\GiftMessage\Block\Cart\GiftOptions"
                   name="checkout.gift_options"
                   template="IWD_Opc::gift_options.phtml"
                   cacheable="false">
            </block>
        </referenceBlock>
        <referenceContainer name="before.body.end">
            <block class="Magento\Framework\View\Element\Template"
                   name="iwd.opc.popup"
                   template="IWD_Opc::popup.phtml">
            </block>
        </referenceContainer>
    </body>
</page>

What I did was try to add the following line

<block class="Redgiant\Xstore\Block\Template" name="xstore_header" template="Magento_Theme::html/xstore_header.phtml" before="main.content"/>

from:

magento\app\design\frontend\Redgiant\xstore\Magento_Theme\page_layout\override\base\1column.xml

However, that has had no effect. I know editing the file onepage_index_index.xml does work as altering the includes in the head carry through.

I think it may be something to do with the class and template references but I'm not sure.

Any help would be really appreciated.

Many Thanks

10
  • You want to add header and footer section to your checkout page, right?
    – Sumit
    Commented Aug 29, 2019 at 15:40
  • Hi Sumit, many thanks for your reply. Yes that's right
    – R14523
    Commented Aug 29, 2019 at 15:56
  • Are you using any third party theme for your website?
    – Sumit
    Commented Aug 29, 2019 at 15:59
  • Yes, it's this one here: themeforest.net/item/xstore-responsive-magento-2-theme/23392534
    – R14523
    Commented Aug 29, 2019 at 16:00
  • Is it porto theme??
    – Sumit
    Commented Aug 29, 2019 at 16:00

1 Answer 1

0

You can achieve this by following the below steps.

Copy app/code/IWD/Opc/view/frontend/layout/onepage_index_index.xml and place it under app/design/frontend/[vendor]/[your_theme]/IWD_Opc/layout/onepage_index_index.xml with below content

<?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">
    <update handle="checkout_index_index"/>
    <head>
        <css src="//fonts.googleapis.com/css?family=Open+Sans:400,400italic,700italic,700" src_type="url"/>
        <css src="//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" src_type="url"/>
    </head>
    <body>
        <referenceBlock name="page.main.title" remove="true"/>
        <referenceBlock name="iwd_opc_ga_ab" remove="true"/>
        <referenceBlock name="checkout.root">
            <action method="setTemplate">
                <argument name="template" xsi:type="string">IWD_Opc::onepage.phtml</argument>
            </action>
            <block class="Magento\GiftMessage\Block\Cart\GiftOptions"
                   name="checkout.gift_options"
                   template="IWD_Opc::gift_options.phtml"
                   cacheable="false">
            </block>
        </referenceBlock>
        <referenceContainer name="before.body.end">
            <block class="Magento\Framework\View\Element\Template"
                   name="iwd.opc.popup"
                   template="IWD_Opc::popup.phtml">
            </block>
        </referenceContainer>
    </body>
</page>

Also, create checkout_index_index.xml under app/design/frontend/[vendor]/[your_theme]/Magento_Checkout/layout/checkout_index_index.xml with below content.

<?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="minicart" remove="false" />
        <referenceBlock name="top.search" remove="false" />
        <referenceBlock name="catalog.compare.link" remove="false" />
        <referenceBlock name="nav-sections" remove="false"/>
        <referenceBlock name="footer_block" remove="false"/>
        <referenceContainer name="header.panel" remove="false" />
    </body>
</page>

Run below commands

php bin/magento s:up
php bin/magento s:s:d -f
php bin/magento c:f

Hope it helps!!!

2
  • Absolutely perfect Sumit, that work perfectly. Thank you so much for your help!
    – R14523
    Commented Aug 30, 2019 at 13:10
  • You're welcome :)
    – Sumit
    Commented Aug 30, 2019 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.