0

I need to add a notification message below the proceed to checkout button without moving it from the existing place

note the notification message should be there in both the existing place and below the proceed to checkout button

1 Answer 1

0

First, create a new module or go to an existing module where you can define a new template file for the checkout page.

Copy the "checkout_index_index.xml" layout file from "vendor/magento/module-checkout/view/frontend/layout/" to your theme's layout directory.

Open the copied "checkout_index_index.xml" layout file and add the following code snippet to the file:

<referenceContainer name="checkout.container">
<block class="Magento\Framework\View\Element\Template" name="checkout.notification.message" template="Vendor_Module::notification_message.phtml" /> </referenceContainer>

This will add a new block named checkout.notification.message to the checkout page container.

Create a new template file named notification_message.phtml in your module's template directory.

In the notification_message.phtml file, add the HTML code for the notification message that you want to display.

To make sure the notification message is also displayed below the proceed to checkout button, you can add the following code to your checkout_index_index.xml layout file:

<referenceBlock name="checkout.cart.methods.onepage.bottom">
<block class="Magento\Framework\View\Element\Template" name="checkout.notification.message.bottom" template="Vendor_Module::notification_message.phtml" /></referenceBlock>

This will add another block named checkout.notification.message.bottom below the proceed to checkout button, which will display the same notification message as the block added earlier.

Finally, flush the cache to see the changes take effect. With these steps, you should now see the notification message both in its original location and below the proceed to checkout button.

Your Answer

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

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