I've made a custom module, with the ability to print the terms and conditions on a static page. I've achieved this by posting a question on Stack, which answer worked for me: Show terms and conditions on static page

(I've followed to above exactly)

Now, I've created the module with the intention to be reused in other instances of Magento 2(.2.3). So, I've installed the module on a clean installation of Magento 2:

  • Enabled developer mode
  • Created corresponding vendor folder
  • Uploaded the module to the vendor folder
  • ran php bin/magento setup:upgrade
  • ran php bin/magento setup:di:compile
  • created terms and conditions
  • enabled the function in the backend (I created a Helper for this)
  • ran php bin/magento cache:flush
  • Browsed to http://www.mywebshop.com/termsconditions

The /termsconditions url loads correctly, so this means the module is working. But somehow, the code which gets the agreement content, returns empty?

This all may sound like a stupid question, but as far as I know, there shouldn't be going something wrong.

var_dump of $block->getAgreements() returns

array (size=0)

Whilst I have created terms and conditions via the admin menu and which show up correctly.

Also the terms and conditions show up in the DB.

Someone who knows what I might have forgotten or what is going wrong?

The code in .phtml

 * @var $block \Magento\CheckoutAgreements\Block\Agreements

<ol class="agreements items">
    <?php var_dump($block->getAgreements()) ?>
    <?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 ?>

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">
        <title>Terms and Conditions</title>
        <referenceBlock name="page.main.title" remove="true" />
        <referenceContainer name="content">
            <block class="Magento\CheckoutAgreements\Block\Agreements" name="terms_conditions"  template="Vendor_TCRender::terms.phtml"/>

  • add your layout file too. Apr 10, 2018 at 13:07
  • I've added the layout file
    – Condor
    Apr 10, 2018 at 13:09
  • enabled the function in the backend (I created a Helper for this) means?
    – Keyur Shah
    Apr 10, 2018 at 13:26
  • I've have made a tab under Stores -> Configuration, with a Yes/No selector which enables me to disable or enable the /termsconditions page. When turned off, /termsconditions will redirect to /404
    – Condor
    Apr 10, 2018 at 13:28

1 Answer 1


I think Enable Terms and Conditions option is "No" in your webshop. make sure that it is enabled from Store > Configuration > Checkout > Checkout Options > Enable Terms and Conditions

After saving configuration clear the cache php bin/magento c:f

  • 1
    Wow. The moment you think you finally get a finger around Magento, I discover I still have a lot to learn. Thank you man, was too focused on the code to forget such a simple setting...
    – Condor
    Apr 10, 2018 at 13:51
  • Glad that it helps you :)
    – Keyur Shah
    Apr 10, 2018 at 13:53

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.