File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed
dashboard/me/billing-monetize-subscriptions
me/purchases/membership-item Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,16 @@ export const MonetizeSubscriptionTerms = ( {
2020 return < > { __ ( 'Never expires' ) } </ > ;
2121 }
2222
23+ // Check if end_date is in the past
24+ const endDate = new Date ( subscription . end_date ) ;
25+ const isExpired = endDate < new Date ( ) ;
26+
27+ // Show "Expired" for past dates
28+ if ( isExpired ) {
29+ return < > { __ ( 'Expired' ) } </ > ;
30+ }
31+
32+ // Show renewal or expiry for future dates
2333 return (
2434 < >
2535 { subscription . renew_interval === null
@@ -29,7 +39,7 @@ export const MonetizeSubscriptionTerms = ( {
2939 dateStyle : 'long' ,
3040 } ) ,
3141 } )
32- : // translators: %(siteUrl )s is the URL of the site. %(date)s is the date the subscription renews. . Format is LL (e.g. January 1, 2020).
42+ : // translators: %(amount )s is the renewal price, %(date)s is the date the subscription renews. Format is LL (e.g. January 1, 2020).
3343 sprintf ( __ ( 'Renews at %(amount)s on %(date)s' ) , {
3444 amount : formatCurrency ( Number ( subscription . renewal_price ) , subscription . currency ) ,
3545 date : formatDate ( new Date ( Date . parse ( subscription ?. end_date ?? '' ) ) , locale , {
Original file line number Diff line number Diff line change @@ -16,18 +16,26 @@ export const MembershipTerms = ( { subscription }: { subscription: MembershipSub
1616 return < > { translate ( 'Never expires' ) } </ > ;
1717 }
1818
19+ // Check if expired
20+ const endDate = moment ( subscription . end_date ) ;
21+ const isExpired = endDate . isBefore ( moment ( ) ) ;
22+
23+ if ( isExpired ) {
24+ return < > { translate ( 'Expired' ) } </ > ;
25+ }
26+
1927 return (
2028 < >
2129 { subscription . renew_interval === null
2230 ? translate ( 'Expires on %(date)s' , {
2331 args : {
24- date : moment ( subscription . end_date ) . format ( 'LL' ) ,
32+ date : endDate . format ( 'LL' ) ,
2533 } ,
2634 } )
2735 : translate ( 'Renews at %(amount)s on %(date)s' , {
2836 args : {
2937 amount : formatCurrency ( Number ( subscription . renewal_price ) , subscription . currency ) ,
30- date : moment ( subscription . end_date ) . format ( 'LL' ) ,
38+ date : endDate . format ( 'LL' ) ,
3139 } ,
3240 } ) }
3341 </ >
You can’t perform that action at this time.
0 commit comments