0

I enable T&C configuration in My Magento 2.3.4 , after i upgraded to Magento 2.4.1. I got this checkout payment page

The order wasn't placed. First, agree to the terms and conditions, then try placing your order again.

The error message comes from validateAgreements function from vendor/magento/module-checkout-agreements/Model/Checkout/Plugin/Validation.php file. In Magento 2.3.4 this file does not being called at all in the checkout payment page, but in Magento 2.4.1 this file is being called in the checkout payment page calling the beforeSavePaymentInformation plugin function which use the validateAgreements that triggers the error message

0

Yes, that is super weird thinks. For guest user it's works as expected. Try the following dev:

Step 1: app/code/VendorName/ModuleName/etc/di.xml

<preference for="Magento\CheckoutAgreements\Model\Checkout\Plugin\Validation"
            type="VendorName\ModuleName\Model\CheckoutAgreements\Checkout\Plugin\Validation"/>

Step 2: app/code/VendorName/ModuleName/Model/CheckoutAgreements/Checkout/Plugin/Validation.php

<?php

declare(strict_types=1);

namespace VendorName\ModuleName\Model\CheckoutAgreements\Checkout\Plugin;

use Magento\Checkout\Api\PaymentInformationManagementInterface;
use Magento\CheckoutAgreements\Model\Checkout\Plugin\Validation as BaseValidation;
use Magento\Quote\Api\Data\AddressInterface;
use Magento\Quote\Api\Data\PaymentInterface;

class Validation extends BaseValidation
{
    /**
     * @inheritDoc
     */
    public function beforeSavePaymentInformation(
        PaymentInformationManagementInterface $subject,
        $cartId,
        PaymentInterface $paymentMethod,
        AddressInterface $billingAddress = null
    ) {
        // no need to check Checkout Agreements validation when set payment method from review step
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.