Is there a way to show the terms and conditions on a page via .phtml? I have made a page via a module and now want to show the terms and conditions on that page.

  • Have you created terms and condition page via Content > Page and you want to display content of CMS page to your .phtml file? Commented Mar 30, 2018 at 12:27
  • Have you needed terms & condition content on your custom page right?
    – Abdul
    Commented Mar 30, 2018 at 12:30
  • @HitarthPattani Yes, I have created terms and conditions. Also they are visible via the check out. Furthermore, I have created a front end page on which I want to show the terms and conditions via a .phtml file which I included within the .xml file of the page I created (termsconditions_index_index.xml)
    – Condor
    Commented Mar 30, 2018 at 12:34
  • @Abdul Yes indeed, I want the terms and conditions to show on my custom page.
    – Condor
    Commented Mar 30, 2018 at 12:34
  • add your terms and condition in a static block and then add your static block to the phtml file, you can refer this answer
    – Piyush
    Commented Mar 30, 2018 at 12:37

1 Answer 1


Step:1 First add below code in your termsconditions_index_index.xml file.

<?xml version="1.0"?>

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <referenceContainer name="content">
            <block class="Magento\CheckoutAgreements\Block\Agreements" name="terms_condition"  template="test/test.phtml"/>

Step:2 Add below code in your .phtm file

 * @var $block \Magento\CheckoutAgreements\Block\Agreements
<?php if (!$block->getAgreements()) {
} ?>
<ol class="agreements items">
<?php foreach ($block->getAgreements() as $agreement): ?>
    <li class="item">
        <?php if ($agreement->getIsHtml()):?>
            <?php /* @escapeNotVerified */ echo $agreement->getContent() ?>
        <?php else:?>
            <?php echo nl2br($block->escapeHtml($agreement->getContent())) ?>
        <?php endif; ?>
<?php endforeach ?>

Note: Please add your .phtml file path in termsconditions_index_index.xml

I have putted currently template="test/test.phtml"

After run below command:

php setup:di:compile
  • 1
    Wow you're amazing dude! I don't doubt that more people will need this in the future! Thanks man!
    – Condor
    Commented Mar 30, 2018 at 13:01
  • @bramulous Welcome :D
    – Abdul
    Commented Mar 30, 2018 at 13:03
  • @Abdul, in which path the file termsconditions_index_index.xml should be? Commented Dec 6, 2018 at 10:07
  • @jafarpinjar termsconditions_index_index is a custom module file for eg. app/code/AR/Termsconditions/view/frontend/layout/termsconditions_index_index.xml
    – Abdul
    Commented Dec 7, 2018 at 5:15
  • @Abdul, can you please share your module please? Commented Dec 7, 2018 at 6:17

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.