You can add shipping address programmatically by following code..!
=> event.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="sales_quote_save_after">
<observer name="sales_quote_save_after_event" instance="Test\Module\Observer\SalesQuoteSaveAfter" />
</event>
</config>
=> Test/Module/Observer/SalesQuoteSaveAfter.php
<?php
namespace Test\Module\Observer;
use Magento\Framework\Event\ObserverInterface;
class SalesQuoteSaveAfter implements ObserverInterface
{
protected $addressFactory;
public function __construct(\Magento\Quote\Api\Data\AddressInterface $address)
{
$this->address = $address;
}
public function execute(\Magento\Framework\Event\Observer $observer)
{
$quote = $observer->getEvent()->getQuote();
if (!$quote->hasItems())
{
$quote->setBillingAddress($this->getEmptyAddress())->setShippingAddress($this->getEmptyAddress());
}
}
private function getEmptyAddress()
{
$this->address->setRegionId(0);
$this->address->setRegion("");
$this->address->setRegionCode("");
$this->address->setCountryId("");
$this->address->setStreet([""]);
$this->address->setCompany("");
$this->address->setTelephone("");
$this->address->setFax("");
$this->address->setPostcode("");
$this->address->setCity("");
$this->address->setFirstname("");
$this->address->setLastname("");
$this->address->setMiddlename("");
$this->address->setEmail("");
$this->address->setSameAsBilling(1);
$this->address->setSaveInAddressBook(0);
return $this->address;
}
}