0

My guest checkout page looks ugly. enter image description here

How can I customize just the guest checkout and add these fields? Image below.

enter image description here

I have found tutorials here at https://www.mageplaza.com/devdocs/custom-checkout-component-magento-2.html. But I am still kind of confused how to edit certain fields.

1

In your custom module, create checkout_index_index.xml in frontend/layout:

<?xml version="1.0"?>
<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="checkout" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="content">
            <block class="Vendor\Module\Block\Notice" name="checkout.notice" template="Vendor_Module::notice.phtml" />
        </referenceContainer>
    </body>
</page>

In the block file, you can create a function to check if a customer is logged in or not, for example: isLoggedin() and then in .phtml file, you can write something like below:

<?php if($block->isLoggedin()): ?>
    <div class="notice-content"> <!--Apply css and other formating as per your need -->
    Please verify your billding and shipping address before placing order, you can edit address details from my account

    Avoid Shipping Delays!- Age Verification Notice -

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    </div>
<?php endif; ?>
3
  • Thank you for this. What/Where should the template .phtml file be placed and be called? Also, how do I move the sign in and make it a button? Just curious. Thank you for this help. I will give this a try tomorrow. I may have some more questions this weekend on this. Thank you!
    – Jonathan
    Dec 10 '20 at 5:56
  • Sure, feel free to ask. Will update answer with more details later. Dec 10 '20 at 5:58
  • Hi, sorry to respond late. I got distracted and had to move to another project for a bit. However, will be coming back to this project in a week or two to finish it up for work. I probably will have more questions in the next couple of weeks. I am not sure how to write the Block logic of how to tell if a customer is log in or not and display that proper checkout page with the CSS fixes I want.
    – Jonathan
    Dec 18 '20 at 1:13

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.