Magento – How to stop Billing Address being set as shipping by default

checkoutknockoutjsmagento2

I just want the My billing and shipping address are the same checkbox to be unchecked by default and let the customer see the form to enter a new billing address.

I think the answer lies within this file:
Magento_Checkout/web/js/view/billing-address.js

But I've tried an awful lot of things with no success.

I need to set isAddressSameAsShipping to false?

I mean I can just uncheck it using JavaScript, but that just seems like cheating..

Thanks

Best Answer

Override ..vendor/magento/module-payment/view/frontend/web/transparent.js and add this code :

var paymentMethodId = jQuery(".payment-methods input[type='radio']:checked").attr('id');

jQuery("#billing-address-same-as-shipping-"+paymentMethodId).trigger('click');
jQuery(".payment-method").find('select[name="billing_address_id"]  option:last-child').attr('selected','selected');
jQuery(".payment-method").find('.billing-address-form').show();

Override ../magento/module-checkout/view/frontend/web/js/action/set-billing-address.js: (Add code)

jQuery(document).on("click",".payment-method",function(){
         console.log(   jQuery(this).find('input[name="billing-address-same-as-shipping"]').is(":checked") );             
         console.log(jQuery(this).find('select[name="billing_address_id"]  option:last-child'));
         jQuery(this).find('input[name="billing-address-same-as-shipping"]').trigger('click');
         jQuery(this).find('select[name="billing_address_id"]  option:last-child').attr('selected','selected');
         jQuery(this).find('.billing-address-form').show();
    })
Related Topic