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)
empty
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
<?php
/**
* @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; ?>
</li>
<?php endforeach ?>
</ol>