I need to change the Terms and Conditions HTML. The client wants to add HTML in the middle of the text. For that I need to change the getAgreementsConfig
function (Magento\CheckoutAgreements\Model\AgreementsConfigProvider
).
I build a plugin to change the result of this function. I worked on this for the last 2 days, and no result until now. I don't know what else to do.
My code is:
My di.xml
file is:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
<type name="Magento\CheckoutAgreements\Model\AgreementsConfigProvider">
<plugin name="agreementsHtmlText" type="VendorName\CheckoutAgreements\Model\Plugin\AgreementPlugin" sortOrder="10" disabled="false"/>
</type>
</config>
And my Plugin is (VendorName\CheckoutAgreements\Model\Plugin\AgreementPlugin
):
<?php
namespace VenderName\CheckoutAgreements\Model\Plugin;
use Magento\Checkout\Model\ConfigProviderInterface;
use Magento\Framework\App\ObjectManager;
use Magento\Store\Model\ScopeInterface;
use Magento\CheckoutAgreements\Model\Api\SearchCriteria\ActiveStoreAgreementsFilter;
class AgreementPlugin
{
public function afterGetAgreementsConfig(\Magento\CheckoutAgreements\Model\AgreementsConfigProvider $subject, $result){
foreach ($result['agreements'] as $key => $value) {
$result[$key]['checkboxText'] ='ahahahhah'; // test if result changes
}
return 'qiweoqiwueioqwiueioquw'; //just to test if it changes the resukt
}
}
I tried and change almost everything, and until now, no luck. Can anyone help me?
Thank you
getAgreementsConfig
is a protected method. Plugins only work on public methods.