3

If a customer has a default billing address I would want to populate the checkout > billing step > new address > form with the those values.

I found all the html and JavaScript files that are used to generate the billing step. I would prefer to do this from php.

Where to start. Any advice?

enter image description here

2
  • do you want to delete New Address from drop down OR remove My billing and shipping address are the same from Review & Payments step?
    – kunj
    Aug 9, 2018 at 11:41
  • 1
    No I do not. I wish to populate the fields with default billing address values Aug 9, 2018 at 11:42

1 Answer 1

3

I guess following mixin for Magento_Checkout/js/view/payment will do what you want (doing this in php won't work in my opinion):

define(
    [
        'Magento_Checkout/js/action/get-payment-information',
        'Magento_Checkout/js/model/quote',
        'Magento_Customer/js/model/customer',
    ], function (
        getPaymentInformation,
        quote,
        customer) {
        'use strict';

        var mixin = {

            initialize: function () {
                getPaymentInformation();

                this._super();

                quote.billingAddress(customer.getBillingAddressList()[0]);

                return this;
            }
        };

        return function (target) {
            return target.extend(mixin);
        };
    }
);

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.