2

When shipping address and billing address are the same , I need to copy my current shipping address to the billing address , not the default case .

Which function checks shipping address and billing address are the same ? and where it copies the billing address to the shipping address ? Need to replace the default method. Instead need to copy current billing address to shipping address

6
  • Check out this file - /vendor/magento/module-checkout/view/frontend/web/js/view/billing-address.js Apr 22, 2019 at 4:54
  • Hello @Arun have found the solution for above? Apr 22, 2019 at 10:46
  • Hi @Aaditya , am trying to customize the code and trying to change the function .Beginner in magento can you help how i can customize this section ?
    – Arun
    Apr 22, 2019 at 13:24
  • Yes, absolutely. Happy to help! Apr 22, 2019 at 13:25
  • Hello @Arun Have you tried that function and the url - magenticians.com/override-model-magento-2 to customize one page checkout ? Apr 24, 2019 at 5:54

1 Answer 1

0

Which function checks shipping address and billing address are the same ? and where it copies the billing address to the shipping address ?

Magento's default function for check same address

/vendor/magento/module-quote/Model/Quote/Address.php

public function getSameAsBilling()
    {
        return $this->getData(self::SAME_AS_BILLING);
    }

Magento uses this function in OneStep Checkout page

/vendor/magento/module-checkout/Model/Type/Onepage.php

if (!$shipping->getSameAsBilling()) {
    $customerShippingData = $shipping->exportCustomerAddress();
    $customerShippingData->setIsDefaultShipping(true);
    $shipping->setCustomerAddressData($customerShippingData);
    // Add shipping address to quote since customer Data Object does not hold address information
    $quote->addCustomerAddress($customerShippingData);
} else {
    $shipping->setCustomerAddressData($customerBillingData);
    $customerBillingData->setIsDefaultShipping(true);
}

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.