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 ShahApr 22, 2019 at 4:54
-
Hello @Arun have found the solution for above?– Aditya ShahApr 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 ?– ArunApr 22, 2019 at 13:24
-
Yes, absolutely. Happy to help!– Aditya ShahApr 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 ?– Aditya ShahApr 24, 2019 at 5:54
1 Answer
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);
}