0

I'm working on the OneStepCheckout and my problem is when I clicked on the place order button and the My billing and shipping address are the same checkbox is not changed (after filling the shipping address) then it gives me error for required billing address fields.

I'm trying to update/reload the billing address (if the My billing and shipping address are the same checkbox is clicked) when all the fields are filled in the shipping address form on the checkout page.

Can anyone help me with this.

Thanks in advance!!!

-1

Thank you all for this great support of yours. I'm able to fix this on my OWN.

define([
    'ko',
    'jquery',
    'Magento_Checkout/js/model/quote'
], function (ko, $, quote) {
    'use strict';

    /**
     * Update Billing Address
     */
    function updateBillingAddress(element) {
        if (quote.shippingAddress() && quote.billingAddress() && $("input[name='billing-address-same-as-shipping']:checked").val() !== undefined) {
            quote.billingAddress(quote.shippingAddress()); //this will set the billing address same as shipping address.
        }
    }

});

Hope it'll help someone having same issue :)

3
  • Hello @Sumit, I just wanted to know that the, which js file I need to override for above solution. Can you please tell me? – Mahesh Dave Oct 6 '20 at 5:29
  • Hi @Rohit, I've done this on my custom JS file. However, you can add this function in your checkout shipping js file where quote is available and call the function where the shipping method is updating. – Sumit Oct 6 '20 at 6:35
  • Thanks for the reply @Sumit, let me add custom JS on checkout. – Mahesh Dave Oct 6 '20 at 6:50

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.