Skip to content

In magento 2.4 How to override the Checkout Agreement Config Provider for Change the terms and condition login

I need to overwrite the config provider of checkout agreement in di.xml

<type name="MagentoCheckoutModelCompositeConfigProvider">
    <arguments>
        <argument name="configProviders" xsi:type="array">
            <item name="checkout_agreements_config_provider" xsi:type="object">MagentoCheckoutAgreementsModelAgreementsConfigProvider</item>
        </argument>
    </arguments>
</type>

For this class vendormagentomodule-checkout-agreementsModelAgreementsConfigProvider.php

protected function getAgreementsConfig()
{

    $agreementConfiguration = [];
    $isAgreementsEnabled = $this->scopeConfiguration->isSetFlag(
        AgreementsProvider::PATH_ENABLED,
        ScopeInterface::SCOPE_STORE
    );

    $agreementsList = $this->checkoutAgreementsList->getList(
        $this->activeStoreAgreementsFilter->buildSearchCriteria()
    );
    $agreementConfiguration['isEnabled'] = (bool)($isAgreementsEnabled && count($agreementsList) > 0);

    foreach ($agreementsList as $agreement) {
        $agreementConfiguration['agreements'][] = [
            'content' => $agreement->getIsHtml()
                ? $agreement->getContent()
                : nl2br($this->escaper->escapeHtml($agreement->getContent())),
            'checkboxText' => $this->escaper->escapeHtml($agreement->getCheckboxText()),
            'mode' => $agreement->getMode(),
            'agreementId' => $agreement->getAgreementId(),
            'contentHeight' => $agreement->getContentHeight()
        ];
    }

    return $agreementConfiguration;
}