Try this,
Add di.xml in your module
<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Checkout\Block\Checkout\LayoutProcessor" type="vendor\module\Block\Checkout\LayoutProcessor" />
Create a LayoutProcessor.php in this path vendor\module\Block\Checkout\LayoutProcessor.php
Copy the file from
Vendor/magento/module-checkout/Block/Checkout/LayoutProcessor.php
To
app/code/vendor/module/Block/Checkout/LayoutProcessor.php
and change the below params to make the company as required field
'company' => [
'validation' => [
'required-entry' => true,
'min_text_length' => 0,
],
],
Existing Billing Address of company field validation.
Add this file in app/code/vendor/module/etc/di.xml
add the following code,
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Checkout\Model\PaymentInformationManagement" type="Vendor\Module\Model\PaymentInformationManagement" />
Add the file in app/code/Vendor\Module\Model\PaymentInformationManagement.php
add the following code to validate empty company in billing address is not allowed.
<?php
namespace Vendor\Module\Model;
use Magento\Framework\Exception\CouldNotSaveException;
class PaymentInformationManagement extends \Magento\Checkout\Model\PaymentInformationManagement
{
public function savePaymentInformationAndPlaceOrder(
$cartId,
\Magento\Quote\Api\Data\PaymentInterface $paymentMethod,
\Magento\Quote\Api\Data\AddressInterface $billingAddress = null
) {
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$cart = $objectManager->get('\Magento\Checkout\Model\Cart');
$billingAddress = $cart->getQuote()->getBillingAddress();
if (!$billingAddress->getCompany()) {
throw new CouldNotSaveException(__('Company should not be empty in billing address'));
return false;
} else {
$this->savePaymentInformation($cartId, $paymentMethod, $billingAddress);
try {
$orderId = $this->cartManagement->placeOrder($cartId);
} catch (\Exception $e) {
throw new CouldNotSaveException(
__('An error occurred on the server. Please try to place the order again.'),
$e
);
}
return $orderId;
}
}}
Hope this helps.
Peace :)