Show terms and conditions on static page
-
06-01-2021 - |
Question
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.
Solution
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">
<body>
<referenceContainer name="content">
<block class="Magento\CheckoutAgreements\Block\Agreements" name="terms_condition" template="test/test.phtml"/>
</referenceContainer>
</body>
</page>
Step:2 Add below code in your .phtm file
<?php
/**
* @var $block \Magento\CheckoutAgreements\Block\Agreements
*/
?>
<?php if (!$block->getAgreements()) {
return;
} ?>
<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; ?>
</li>
<?php endforeach ?>
</ol>
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
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange