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

  • Check out this file - /vendor/magento/module-checkout/view/frontend/web/js/view/billing-address.js – Aditya Shah Apr 22 at 4:54
  • Hello @Arun have found the solution for above? – Aditya Shah Apr 22 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 at 13:24
  • Yes, absolutely. Happy to help! – Aditya Shah Apr 22 at 13:25
  • Hello @Arun Have you tried that function and the url - magenticians.com/override-model-magento-2 to customize one page checkout ? – Aditya Shah Apr 24 at 5:54
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, privacy policy and cookie policy

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