Skip to content

Commit

Permalink
Free Trials: Check that the cart contained a plan before refreshing t…
Browse files Browse the repository at this point in the history
…he site plans
  • Loading branch information
Tug committed Dec 29, 2015
1 parent c9cb97e commit ec48c4c
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions client/my-sites/upgrades/checkout/thank-you.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,23 @@ var CheckoutThankYou = React.createClass( {
},

componentDidMount: function() {
var selectedSite = this.props.lastTransaction.selectedSite;
this.props.refreshSitePlans( selectedSite.ID );
var lastTransaction = this.props.lastTransaction,
selectedSite;

// refresh the list of sites to update the `site.plan` property.
Dispatcher.handleViewAction( {
type: 'FETCH_SITES'
} );
if ( lastTransaction ) {
selectedSite = lastTransaction.selectedSite;

// Refresh selected site plans if the user just purchased a plan
if ( cartItems.hasPlan( lastTransaction.cart ) ) {
this.props.refreshSitePlans( selectedSite.ID );
}

// Refresh the list of sites to update the `site.plan` property
// needed to display the plan name on the right of the `Plans` menu item
Dispatcher.handleViewAction( {
type: 'FETCH_SITES'
} );
}

analytics.tracks.recordEvent( 'calypso_checkout_thank_you_view' );
},
Expand Down

0 comments on commit ec48c4c

Please sign in to comment.