I have a custom attribute that is placed in the Billing Address section. Now there's a condition that I only need to save the first 200 character of my custom attribute text box. Is there an event or observer that will intercept this request before proceeding to save/place order? So basically on the checkout page after inputting the text in my custom attribute when user click the Place Order
button I want to check this input first if it's beyond the limit then I will trim the text. How do I do this?
Update:
When I tried to intercept the request under Magento\Checkout\Api\GuestPaymentInformationManagementInterface
I was able to view the personal_message
custom attribute that I'm looking at. But when I try to save or change the value it didn't allow me. How can I override it?
<type name="Magento\Checkout\Api\GuestPaymentInformationManagementInterface">
<plugin name="validate-billing-information" type="Vendor\Module\Plugin\Checkout\BillingValidation"/>
</type>
And this is the code I was trying to overwrite
public function beforeSavePaymentInformationAndPlaceOrder(
\Magento\Checkout\Api\GuestPaymentInformationManagementInterface $subject,
$cartId,
$email,
\Magento\Quote\Api\Data\PaymentInterface $paymentMethod,
\Magento\Quote\Api\Data\AddressInterface $billingAddress = null
) {
$billingAddress->setPersonalMessage("This is an overwritten message");
$billingAddress->save();
}
But doing this throws an error of
webapi-5f6f60228b3a3; Message: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`homestead_goodgifts`.`quote_address`, CONSTRAINT `QUOTE_ADDRESS_QUOTE_ID_QUOTE_ENTITY_ID` FOREIGN KEY (`quote_id`) REFERENCES