Skip to content

Commit

Permalink
Recurring Payments: Keep custom text on plan change (#16148)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmtr authored Jun 15, 2020
1 parent efa31a1 commit f7874f3
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions extensions/blocks/recurring-payments/edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,20 @@ class MembershipsButtonEdit extends Component {
return formatCurrency( parseFloat( product.price ), product.currency );
};

setMembershipAmount = id =>
setMembershipAmount = id => {
const currentPlanId = this.props.attributes.planId;
const currentText = this.props.attributes.submitButtonText;
const defaultTextForNewPlan =
this.getFormattedPriceByProductId( id ) + __( ' Contribution', 'jetpack' );
const defaultTextForCurrentPlan = currentPlanId
? this.getFormattedPriceByProductId( currentPlanId ) + __( ' Contribution', 'jetpack' )
: undefined;
const text = currentText === defaultTextForCurrentPlan ? defaultTextForNewPlan : currentText;
this.props.setAttributes( {
planId: id,
submitButtonText: this.getFormattedPriceByProductId( id ) + __( ' Contribution', 'jetpack' ),
submitButtonText: text,
} );
};

renderMembershipAmounts = () => (
<div>
Expand Down

0 comments on commit f7874f3

Please sign in to comment.