Skip to content

Commit

Permalink
Merge pull request scandipwa#5269 from AleksandrsKondratjevs/issue-5240
Browse files Browse the repository at this point in the history
issue-5240 - Fix on first checkout load shipping estimates
  • Loading branch information
AleksandrsKondratjevs authored Nov 2, 2022
2 parents 27d480f + 9867de2 commit 0e02a91
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,26 @@ export class CheckoutAddressFormComponent extends MyAccountAddressForm<CheckoutA
this.onAddressChange = this.onAddressChange.bind(this);
}

componentDidMount() {
const {
currentCity: city,
currentRegionId: region_id,
currentRegion: region,
currentZipcode: postcode,
countryId,
onShippingEstimationFieldsChange,
defaultCountry,
} = this.props;

onShippingEstimationFieldsChange({
country_id: countryId || defaultCountry,
region_id,
region,
city,
postcode,
});
}

fieldMap(): (Partial<FieldContainerProps> | FormSection)[] {
const {
address,
Expand Down Expand Up @@ -97,8 +117,6 @@ export class CheckoutAddressFormComponent extends MyAccountAddressForm<CheckoutA
addressGroup.events = {
// Updates shipping methods on address blurt
onBlur: this.onAddressChange,
// Updates shipping methods on start
onLoad: this.onAddressChange,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
FocusEventHandler,
FormHTMLAttributes,
MutableRefObject,
ReactEventHandler,
RefObject,
SyntheticEvent,
} from 'react';
Expand Down Expand Up @@ -77,7 +76,6 @@ DOMAttributes<HTMLDivElement>,
>
& {
onBlur: (event: FocusEventHandler, fields: FieldGroupEventData) => void;
onLoad: (event: ReactEventHandler, fields: FieldGroupEventData) => void;
};

export interface FieldGroupEventData {
Expand Down

0 comments on commit 0e02a91

Please sign in to comment.