Skip to content

Commit f367944

Browse files
authored
Merge pull request #264 from pronamic/263-hide-next-payment-date-cancelled-subscription
Hide next payment date in update meta box for cancelled subscriptions.
2 parents a72ae8b + 461ec64 commit f367944

1 file changed

Lines changed: 66 additions & 62 deletions

File tree

views/meta-box-subscription-update.php

Lines changed: 66 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -125,91 +125,95 @@
125125
<?php endif; ?>
126126
</div>
127127

128-
<div class="misc-pub-section curtime">
129-
<?php
128+
<?php if ( SubscriptionStatus::CANCELLED !== $subscription->get_status() ) : ?>
130129

131-
$next_payment_date = $subscription->get_next_payment_date();
130+
<div class="misc-pub-section curtime">
131+
<?php
132132

133-
?>
133+
$next_payment_date = $subscription->get_next_payment_date();
134134

135-
<span id="timestamp">
136-
<?php echo esc_html( __( 'Next payment:', 'pronamic_ideal' ) ); ?>
137-
</span>
135+
?>
138136

139-
<span id="pronamic-pay-next-payment-date-display"><?php echo esc_html( null === $next_payment_date ? '' : $next_payment_date->format_i18n( \__( 'D j M Y', 'pronamic_ideal' ) ) ); ?></span>
137+
<span id="timestamp">
138+
<?php echo esc_html( __( 'Next payment:', 'pronamic_ideal' ) ); ?>
139+
</span>
140140

141-
<?php if ( 'woocommerce' !== $subscription->get_source() ) : ?>
141+
<span id="pronamic-pay-next-payment-date-display"><?php echo esc_html( null === $next_payment_date ? '' : $next_payment_date->format_i18n( \__( 'D j M Y', 'pronamic_ideal' ) ) ); ?></span>
142142

143-
<a href="#pronamic-pay-next-payment-date" class="edit-pronamic-pay-next-payment-date hide-if-no-js" role="button">
144-
<span aria-hidden="true"><?php esc_html_e( 'Edit', 'pronamic_ideal' ); ?></span>
145-
<span class="screen-reader-text"><?php esc_html_e( 'Edit next payment date', 'pronamic_ideal' ); ?></span>
146-
</a>
143+
<?php if ( 'woocommerce' !== $subscription->get_source() ) : ?>
147144

148-
<?php endif; ?>
145+
<a href="#pronamic-pay-next-payment-date" class="edit-pronamic-pay-next-payment-date hide-if-no-js" role="button">
146+
<span aria-hidden="true"><?php esc_html_e( 'Edit', 'pronamic_ideal' ); ?></span>
147+
<span class="screen-reader-text"><?php esc_html_e( 'Edit next payment date', 'pronamic_ideal' ); ?></span>
148+
</a>
149149

150-
<div id="pronamic-pay-next-payment-date-input" class="hide-if-js">
151-
<input type="hidden" name="hidden_pronamic_pay_next_payment_date" id="hidden_pronamic_pay_next_payment_date" value="<?php echo \esc_attr( null === $next_payment_date ? '' : $next_payment_date->format( 'Y-m-d' ) ); ?>" />
152-
<label for="pronamic-pay-next-payment-date" class="screen-reader-text"><?php esc_html_e( 'Set date', 'pronamic_ideal' ); ?></label>
150+
<?php endif; ?>
153151

154-
<?php
152+
<div id="pronamic-pay-next-payment-date-input" class="hide-if-js">
153+
<input type="hidden" name="hidden_pronamic_pay_next_payment_date" id="hidden_pronamic_pay_next_payment_date" value="<?php echo \esc_attr( null === $next_payment_date ? '' : $next_payment_date->format( 'Y-m-d' ) ); ?>" />
154+
<label for="pronamic-pay-next-payment-date" class="screen-reader-text"><?php esc_html_e( 'Set date', 'pronamic_ideal' ); ?></label>
155155

156-
$element = new Element(
157-
'input',
158-
[
159-
'id' => 'pronamic-pay-next-payment-date',
160-
'name' => 'pronamic_subscription_next_payment_date',
161-
'type' => 'date',
162-
'value' => null === $next_payment_date ? '' : $next_payment_date->format( 'Y-m-d' ),
163-
'data-min' => ( new DateTimeImmutable( 'tomorrow' ) )->format( 'Y-m-d' ),
164-
]
165-
);
156+
<?php
166157

167-
$element->output();
158+
$element = new Element(
159+
'input',
160+
[
161+
'id' => 'pronamic-pay-next-payment-date',
162+
'name' => 'pronamic_subscription_next_payment_date',
163+
'type' => 'date',
164+
'value' => null === $next_payment_date ? '' : $next_payment_date->format( 'Y-m-d' ),
165+
'data-min' => ( new DateTimeImmutable( 'tomorrow' ) )->format( 'Y-m-d' ),
166+
]
167+
);
168168

169-
?>
169+
$element->output();
170170

171-
<a href="#pronamic-pay-next-payment-date" class="save-pronamic-pay-next-payment-date hide-if-no-js button"><?php esc_html_e( 'OK', 'pronamic_ideal' ); ?></a>
172-
<a href="#pronamic-pay-next-payment-date" class="cancel-pronamic-pay-next-payment-date hide-if-no-js button-cancel"><?php esc_html_e( 'Cancel', 'pronamic_ideal' ); ?></a>
173-
</div>
171+
?>
174172

175-
<?php
173+
<a href="#pronamic-pay-next-payment-date" class="save-pronamic-pay-next-payment-date hide-if-no-js button"><?php esc_html_e( 'OK', 'pronamic_ideal' ); ?></a>
174+
<a href="#pronamic-pay-next-payment-date" class="cancel-pronamic-pay-next-payment-date hide-if-no-js button-cancel"><?php esc_html_e( 'Cancel', 'pronamic_ideal' ); ?></a>
175+
</div>
176+
177+
<?php
176178

177-
$today = new DateTimeImmutable( 'today midnight', new DateTimeZone( Plugin::TIMEZONE ) );
179+
$today = new DateTimeImmutable( 'today midnight', new DateTimeZone( Plugin::TIMEZONE ) );
178180

179-
if ( SubscriptionStatus::ACTIVE === $subscription->get_status() && null !== $next_payment_date && $next_payment_date < $today ) :
180-
?>
181+
if ( SubscriptionStatus::ACTIVE === $subscription->get_status() && null !== $next_payment_date && $next_payment_date < $today ) :
182+
?>
181183

182-
<div id="pronamic-pay-next-payment-date-error" class="error inline">
183-
<p><?php echo esc_html( __( 'Set the next payment date to a future date to continue payments for this subscription.', 'pronamic_ideal' ) ); ?></p>
184-
</div>
184+
<div id="pronamic-pay-next-payment-date-error" class="error inline">
185+
<p><?php echo esc_html( __( 'Set the next payment date to a future date to continue payments for this subscription.', 'pronamic_ideal' ) ); ?></p>
186+
</div>
185187

186-
<?php endif; ?>
188+
<?php endif; ?>
187189

188-
<div id="pronamic-pay-next-payment-date-min-error" class="hidden error inline">
189-
<p><?php echo esc_html( __( 'Please select a future date.', 'pronamic_ideal' ) ); ?></p>
190-
</div>
190+
<div id="pronamic-pay-next-payment-date-min-error" class="hidden error inline">
191+
<p><?php echo esc_html( __( 'Please select a future date.', 'pronamic_ideal' ) ); ?></p>
192+
</div>
191193

192-
<div id="pronamic-pay-next-payment-date-notice" class="hidden notice inline">
193-
<p>
194-
<?php
194+
<div id="pronamic-pay-next-payment-date-notice" class="hidden notice inline">
195+
<p>
196+
<?php
195197

196-
\printf(
197-
/* translators: %s subscription source description */
198-
\esc_html( \__( 'Editing the next payment date does not affect the current status or validity of %s.', 'pronamic_ideal' ) ),
199-
\wp_kses(
200-
$subscription->get_source_text(),
201-
[
202-
'a' => [
203-
'href' => true,
204-
],
205-
]
206-
)
207-
);
198+
\printf(
199+
/* translators: %s subscription source description */
200+
\esc_html( \__( 'Editing the next payment date does not affect the current status or validity of %s.', 'pronamic_ideal' ) ),
201+
\wp_kses(
202+
$subscription->get_source_text(),
203+
[
204+
'a' => [
205+
'href' => true,
206+
],
207+
]
208+
)
209+
);
208210

209-
?>
210-
</p>
211+
?>
212+
</p>
213+
</div>
211214
</div>
212-
</div>
215+
216+
<?php endif; ?>
213217
</div>
214218
</div>
215219

0 commit comments

Comments
 (0)