Skip to main content
Rollback to Revision 1 - Edit approval overridden by post owner or moderator
Source Link
Khoa TruongDinh
  • 32.3k
  • 11
  • 90
  • 156

There are many ways to achieve your goal.

For example, you can try with Plugin:

app/code/Vendor/Checkout/etc/di.xml

app/code/Vendor/Checkout/etc/di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    
    <type name="Magento\Checkout\Api\PaymentInformationManagementInterface">
        <plugin name="verify_phone_validation" type="Vendor\Checkout\Plugin\Payment\VerifyPhoneValidation"/>
    </type>
</config>

Your Plugin: Your Plugin:

public function beforeSavePaymentInformationAndPlaceOrder(
    PaymentInformationManagementInterface $subject,
    $cartId,
    PaymentInterface $paymentMethod,
    AddressInterface $billingAddress = null
) {
    //Your custom logic

    if ($customer->isVerifiedPhone()) {
                throw new CouldNotSaveException(
                    __(
                        "The order wasn't placed. "
                        . "You need to verify the phone number before placing order"
                    )
                );
    }
}

There are many ways to achieve your goal.

For example, you can try with Plugin:

app/code/Vendor/Checkout/etc/di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    
    <type name="Magento\Checkout\Api\PaymentInformationManagementInterface">
        <plugin name="verify_phone_validation" type="Vendor\Checkout\Plugin\Payment\VerifyPhoneValidation"/>
    </type>
</config>

Your Plugin:

public function beforeSavePaymentInformationAndPlaceOrder(
    PaymentInformationManagementInterface $subject,
    $cartId,
    PaymentInterface $paymentMethod,
    AddressInterface $billingAddress = null
) {
    //Your custom logic

    if ($customer->isVerifiedPhone()) {
                throw new CouldNotSaveException(
                    __(
                        "The order wasn't placed. "
                        . "You need to verify the phone number before placing order"
                    )
                );
    }
}

There are many ways to achieve your goal.

For example, you can try with Plugin:

app/code/Vendor/Checkout/etc/di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    
    <type name="Magento\Checkout\Api\PaymentInformationManagementInterface">
        <plugin name="verify_phone_validation" type="Vendor\Checkout\Plugin\Payment\VerifyPhoneValidation"/>
    </type>
</config>

Your Plugin:

public function beforeSavePaymentInformationAndPlaceOrder(
    PaymentInformationManagementInterface $subject,
    $cartId,
    PaymentInterface $paymentMethod,
    AddressInterface $billingAddress = null
) {
    //Your custom logic

    if ($customer->isVerifiedPhone()) {
                throw new CouldNotSaveException(
                    __(
                        "The order wasn't placed. "
                        . "You need to verify the phone number before placing order"
                    )
                );
    }
}
Formatted text. Highlighted the needful. Fixed grammatical mistakes
Source Link

There are many ways to achieve your goal.

For example, you can try with Plugin:

app/code/Vendor/Checkout/etc/di.xml

app/code/Vendor/Checkout/etc/di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    
    <type name="Magento\Checkout\Api\PaymentInformationManagementInterface">
        <plugin name="verify_phone_validation" type="Vendor\Checkout\Plugin\Payment\VerifyPhoneValidation"/>
    </type>
</config>

Your Plugin:Your Plugin:

public function beforeSavePaymentInformationAndPlaceOrder(
    PaymentInformationManagementInterface $subject,
    $cartId,
    PaymentInterface $paymentMethod,
    AddressInterface $billingAddress = null
) {
    //Your custom logic

    if ($customer->isVerifiedPhone()) {
                throw new CouldNotSaveException(
                    __(
                        "The order wasn't placed. "
                        . "You need to verify the phone number before placing order"
                    )
                );
    }
}

There are many ways to achieve your goal.

For example, you can try with Plugin:

app/code/Vendor/Checkout/etc/di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    
    <type name="Magento\Checkout\Api\PaymentInformationManagementInterface">
        <plugin name="verify_phone_validation" type="Vendor\Checkout\Plugin\Payment\VerifyPhoneValidation"/>
    </type>
</config>

Your Plugin:

public function beforeSavePaymentInformationAndPlaceOrder(
    PaymentInformationManagementInterface $subject,
    $cartId,
    PaymentInterface $paymentMethod,
    AddressInterface $billingAddress = null
) {
    //Your custom logic

    if ($customer->isVerifiedPhone()) {
                throw new CouldNotSaveException(
                    __(
                        "The order wasn't placed. "
                        . "You need to verify the phone number before placing order"
                    )
                );
    }
}

There are many ways to achieve your goal.

For example, you can try with Plugin:

app/code/Vendor/Checkout/etc/di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    
    <type name="Magento\Checkout\Api\PaymentInformationManagementInterface">
        <plugin name="verify_phone_validation" type="Vendor\Checkout\Plugin\Payment\VerifyPhoneValidation"/>
    </type>
</config>

Your Plugin:

public function beforeSavePaymentInformationAndPlaceOrder(
    PaymentInformationManagementInterface $subject,
    $cartId,
    PaymentInterface $paymentMethod,
    AddressInterface $billingAddress = null
) {
    //Your custom logic

    if ($customer->isVerifiedPhone()) {
                throw new CouldNotSaveException(
                    __(
                        "The order wasn't placed. "
                        . "You need to verify the phone number before placing order"
                    )
                );
    }
}
Source Link
Khoa TruongDinh
  • 32.3k
  • 11
  • 90
  • 156

There are many ways to achieve your goal.

For example, you can try with Plugin:

app/code/Vendor/Checkout/etc/di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    
    <type name="Magento\Checkout\Api\PaymentInformationManagementInterface">
        <plugin name="verify_phone_validation" type="Vendor\Checkout\Plugin\Payment\VerifyPhoneValidation"/>
    </type>
</config>

Your Plugin:

public function beforeSavePaymentInformationAndPlaceOrder(
    PaymentInformationManagementInterface $subject,
    $cartId,
    PaymentInterface $paymentMethod,
    AddressInterface $billingAddress = null
) {
    //Your custom logic

    if ($customer->isVerifiedPhone()) {
                throw new CouldNotSaveException(
                    __(
                        "The order wasn't placed. "
                        . "You need to verify the phone number before placing order"
                    )
                );
    }
}