Skip to content

Commit f029042

Browse files
author
Jeff Mataya
authored
Merge pull request #2281 from FoxComm/bug/shipping-address-after-billing-set-up
Can't select the newly added billing address in shipping block right away
2 parents 99ccbbb + 26cb0bb commit f029042

2 files changed

Lines changed: 57 additions & 51 deletions

File tree

demo/peacock/src/pages/checkout/billing/edit-billing.jsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ type Props = CheckoutActions & {
5555
creditCards: Array<CreditCardType>,
5656
creditCardsLoading: boolean,
5757
chooseCreditCard: () => Promise<*>,
58+
fetchAddresses: () => Promise<*>,
5859
};
5960

6061
type State = {
@@ -95,13 +96,17 @@ class EditBilling extends Component {
9596
}
9697

9798
const coupon = this.props.coupon;
99+
let newState = {};
100+
98101
if (!_.isEmpty(coupon)) {
99-
this.setState({ couponCode: coupon.code });
102+
newState = { couponCode: coupon.code };
100103
}
101104

102-
if (this.props.data.address) {
103-
this.state.billingAddressIsSame = false;
105+
if (this.props.shippingAddress) {
106+
newState = {...newState, billingAddressIsSame: false };
104107
}
108+
109+
this.setState(newState);
105110
}
106111

107112
// Credit Card Handling
@@ -216,6 +221,7 @@ class EditBilling extends Component {
216221

217222
return operation.then((card) => {
218223
this.props.fetchCreditCards();
224+
this.props.fetchAddresses();
219225
this.props.resetBillingData();
220226
this.setState({ addingNew: false, cardAdded: (id === undefined) });
221227
return card;
@@ -462,6 +468,7 @@ class EditBilling extends Component {
462468
checked={this.state.billingAddressIsSame}
463469
onChange={this.toggleSeparateBillingAddress}
464470
styleName="same-address-checkbox"
471+
disabled={_.isEmpty(this.props.shippingAddress)}
465472
>
466473
{t('Billing address is same as shipping')}
467474
</Checkbox>

demo/peacock/src/pages/checkout/checkout.jsx

Lines changed: 47 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -219,63 +219,62 @@ class Checkout extends Component {
219219
const isGuestMode = isGuest(_.get(props.auth, 'user'));
220220
const cartFetched = props.fetchCartState.finished;
221221

222-
if (cartFetched) {
223-
const shippingAddress = _.get(this.props.cart, 'shippingAddress', {});
224-
225-
return (
226-
<div styleName="wrapper">
227-
<div styleName="main-container">
228-
<div styleName="row">
229-
<div styleName="column">
230-
<div styleName="shipping">
231-
<Shipping
232-
isEditing={props.editStage}
233-
onComplete={this.setShipping}
234-
addresses={this.props.addresses}
235-
fetchAddresses={this.props.fetchAddresses}
236-
shippingAddress={shippingAddress}
237-
auth={this.props.auth}
238-
isGuestMode={isGuestMode}
239-
/>
240-
</div>
241-
<div styleName="delivery">
242-
<Delivery
243-
isEditing={props.editStage}
244-
onComplete={this.setDelivery}
245-
shippingMethods={props.shippingMethods}
246-
cart={this.props.cart}
247-
fetchShippingMethods={props.fetchShippingMethods}
248-
shippingAddressEmpty={_.isEmpty(shippingAddress)}
249-
/>
250-
</div>
251-
</div>
252-
<div styleName="payment">
253-
<Billing
222+
if (!cartFetched) {
223+
return <Loader />;
224+
}
225+
226+
const shippingAddress = _.get(this.props.cart, 'shippingAddress', {});
227+
228+
return (
229+
<div styleName="wrapper">
230+
<div styleName="main-container">
231+
<div styleName="row">
232+
<div styleName="column">
233+
<div styleName="shipping">
234+
<Shipping
235+
isEditing={props.editStage}
236+
onComplete={this.setShipping}
237+
addresses={this.props.addresses}
238+
fetchAddresses={this.props.fetchAddresses}
239+
shippingAddress={shippingAddress}
240+
auth={this.props.auth}
254241
isGuestMode={isGuestMode}
255-
paymentMethods={_.get(props.cart, 'paymentMethods', [])}
256-
chooseCreditCard={this.props.chooseCreditCard}
257-
onComplete={this.setBilling}
242+
/>
243+
</div>
244+
<div styleName="delivery">
245+
<Delivery
246+
isEditing={props.editStage}
247+
onComplete={this.setDelivery}
248+
shippingMethods={props.shippingMethods}
249+
cart={this.props.cart}
250+
fetchShippingMethods={props.fetchShippingMethods}
251+
shippingAddressEmpty={_.isEmpty(shippingAddress)}
258252
/>
259253
</div>
260254
</div>
261-
<div styleName="order-summary">
262-
{this.orderContent}
255+
<div styleName="payment">
256+
<Billing
257+
isGuestMode={isGuestMode}
258+
paymentMethods={_.get(props.cart, 'paymentMethods', [])}
259+
chooseCreditCard={this.props.chooseCreditCard}
260+
onComplete={this.setBilling}
261+
fetchAddresses={this.props.fetchAddresses}
262+
/>
263263
</div>
264264
</div>
265-
<div styleName="side-container">
266-
{this.orderTotals}
265+
<div styleName="order-summary">
266+
{this.orderContent}
267267
</div>
268-
269-
<GuestAuth
270-
isEditing={!this.isEmailSetForCheckout()}
271-
location={this.props.location}
272-
/>
273268
</div>
274-
);
275-
}
269+
<div styleName="side-container">
270+
{this.orderTotals}
271+
</div>
276272

277-
return (
278-
<Loader />
273+
<GuestAuth
274+
isEditing={!this.isEmailSetForCheckout()}
275+
location={this.props.location}
276+
/>
277+
</div>
279278
);
280279
}
281280

0 commit comments

Comments
 (0)