0

We have implemented a custom payment method, but when anyone update the billing address in payment page of checkout , updated billing address is not reflecting after order got placed.

we used $order = $this->quoteManagement->submit($quote); to place an order and before placing an order we are updating the billing address as below.

 if (isset($billingAddress['firstname'])) {
            $quote->getBillingAddress()->setFirstname($billingAddress['firstname']);
            $quote->getBillingAddress()->setLastname($billingAddress['lastname']);
            $quote->getBillingAddress()->setStreet($billingAddress['street']);
            $quote->getBillingAddress()->setCity($billingAddress['city']);
            $quote->getBillingAddress()->setTelephone($billingAddress['telephone']);
            $quote->getBillingAddress()->setPostcode($billingAddress['postcode']);
            if(!empty($billingAddress['region'])){
                $quote->getBillingAddress()->setRegion($billingAddress['region']);
            }else{
                $billingAddress['region'] = '';
                $quote->getBillingAddress()->setRegion($billingAddress['region']);

            }
            if (array_key_exists("regionId",$billingAddress))
            {
                $quote->getBillingAddress()->setRegionId($billingAddress['regionId']);
            }else{
                $billingAddress['regionId'] = 'NULL';
                $quote->getBillingAddress()->setRegionId($billingAddress['regionId']);

            }
            if (array_key_exists("saveInAddressBook",$billingAddress)){
                $quote->getBillingAddress()->setSaveInAddressBook($billingAddress['saveInAddressBook']);
            }else{
                $billingAddress['saveInAddressBook'] = '0';
                $quote->getBillingAddress()->setSaveInAddressBook($billingAddress['saveInAddressBook']);
            }
            $quote->getBillingAddress()->setCountryId($billingAddress['countryId']);
            $quote->save();
           
        }

Can anyone help me with this?

1 Answer 1

0

Currently, you have just updated the new address in quote. You need to catch the event when the payment is successful to update the new address on the order.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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