PluginProbe
Subscriptions for WooCommerce with Stripe Recurring Payments / 2.4.0
Subscriptions for WooCommerce with Stripe Recurring Payments v2.4.0
2.4.0 2.3.0 2.2.0 2.1.0 2.0.0 1.11.2 1.11.1 1.11.0 1.10.9 1.10.8 1.10.7 1.10.6 1.10.5 1.10.4 1.10.3 1.10.2 1.10.1 1.10.0 1.9.6 1.9.5 trunk 1.3.0 1.3.1 1.3.2 1.4.0 All 65 releases
← All changes | includes/Illuminate/Order.php +39 -92 1.10.9 → 2.4.0 View file →
@@ -81,11 +81,21 @@
81 81 delete_post_meta( $subscription_id, '_subscrpt_trial_started' );
82 82 delete_post_meta( $subscription_id, '_subscrpt_trial_ended' );
83 83 }
84 84
85 - $next_date = sdevs_wp_strtotime( $recurr_timing, time() );
85 + // Extend from the current due date so the days already paid for are kept.
86 + $next_date = $this->get_anchored_next_date( $subscription_id, $recurr_timing, (int) $subscription_history->order_id );
86 87 }
87 88
89 + // Split payment: no next date after the final installment.
90 + if (
91 + in_array( $subscription_history->type, array( 'renew', 'early-renew' ), true )
92 + && function_exists( 'subscrpt_is_max_payments_reached' )
93 + && subscrpt_is_max_payments_reached( $subscription_id )
94 + ) {
95 + return;
96 + }
97 +
88 98 /**
89 99 * Filter the subscription next payment date before it is saved.
90 100 *
91 101 * General-purpose hook (not scoped to split payment) for adjusting the
@@ -190,9 +200,8 @@
190 200 return;
191 201 }
192 202
193 203 $subtotal = '-';
194 - $item_id = $item->get_id();
195 204 $subscription_id = Helper::get_subscription_from_order_item_id( $item->get_id() );
196 205
197 206 if ( ! $subscription_id ) {
198 207 echo "<td class='item_recurring' width='15%'>-</td>";
@@ -199,10 +208,10 @@
199 208 return;
200 209 }
201 210 $subscription_id = $subscription_id->subscription_id;
202 211
203 - $price = get_post_meta( $subscription_id, '_subscrpt_price', true );
204 - $subtotal = Helper::format_price_with_order_item( $price, $item_id );
212 + // Strikes the original amount when a discount carries into renewals.
213 + $subtotal = Helper::get_subscription_recurring_price_html( $subscription_id, $item );
205 214 ?>
206 215 <td class="item_recurring" width="15%">
207 216 <div class="view">
208 217 <?php echo wp_kses_post( $subtotal ); ?>
@@ -264,12 +273,36 @@
264 273
265 274 foreach ( $histories as $history ) {
266 275 if ( 'new' === $history->type || 'renew' === $history->type ) {
267 276 $subscription_id = $history->subscription_id;
277 +
278 + // Renewals ignore the intermediate `processing` state for renewal orders.
279 + if ( 'renew' === $history->type && 'processing' === $order->get_status() ) {
280 + continue;
281 + }
282 +
283 + // Capture the status before the max-payments check below may flip it.
284 + $current_status = get_post_status( $subscription_id );
285 +
286 + // Split payment: complete instead of re-activate after the final installment.
287 + $target_status = $post_status;
288 + if (
289 + 'active' === $target_status
290 + && function_exists( 'subscrpt_is_max_payments_reached' )
291 + && subscrpt_is_max_payments_reached( $subscription_id )
292 + ) {
293 + $target_status = 'completed';
294 + }
295 +
296 + // Skip no-op transitions so the note and side effects don't duplicate.
297 + if ( $current_status === $target_status ) {
298 + continue;
299 + }
300 +
268 301 wp_update_post(
269 302 array(
270 303 'ID' => $subscription_id,
271 - 'post_status' => $post_status,
304 + 'post_status' => $target_status,
272 305 )
273 306 );
274 307
275 308 // If possible change order status to completed if it has a trial subscription.
@@ -284,9 +317,9 @@
284 317
285 318 // Add enhanced split payment activity logging
286 319 $this->add_split_payment_activity_note( $history->subscription_id, $history->type, $post_status, $order );
287 320
288 - Action::write_comment( $post_status, $history->subscription_id );
321 + Action::write_comment( $target_status, $history->subscription_id );
289 322 } else {
290 323 do_action( 'subscrpt_order_status_changed', $order, $history );
291 324 }
292 325 }
@@ -397,94 +430,8 @@
397 430 $max_payments,
398 431 $subscription_id
399 432 );
400 433 $order->add_order_note( $order_note );
401 - }
402 -
403 - // Add payment milestone notes for significant progress
404 - $this->add_payment_milestone_notes( $subscription_id, $payments_made, $max_payments );
405 - }
406 -
407 - /**
408 - * Add payment milestone notes for significant progress (25%, 50%, 75%, 100%).
409 - *
410 - * @param int $subscription_id Subscription ID.
411 - * @param int $payments_made Number of payments made.
412 - * @param int $max_payments Maximum number of payments.
413 - */
414 - private function add_payment_milestone_notes( $subscription_id, $payments_made, $max_payments ) {
415 - if ( ! $max_payments || $max_payments <= 0 ) {
416 - return;
417 - }
418 -
419 - $percentage = round( ( $payments_made / $max_payments ) * 100 );
420 - $milestone_key = '_subscrpt_milestone_' . $percentage . '_logged';
421 -
422 - // Check if this milestone has already been logged
423 - if ( get_post_meta( $subscription_id, $milestone_key, true ) ) {
424 - return;
425 - }
426 -
427 - $milestone_note = '';
428 - $activity_type = '';
429 -
430 - switch ( $percentage ) {
431 - case 25:
432 - $milestone_note = sprintf(
433 - /* translators: %1$d: payments made, %2$d: total payments */
434 - __( 'Payment milestone reached: %1$d of %2$d payments completed (25%%).', 'subscription' ),
435 - $payments_made,
436 - $max_payments
437 - );
438 - $activity_type = __( 'Payment Milestone - 25%', 'subscription' );
439 - break;
440 -
441 - case 50:
442 - $milestone_note = sprintf(
443 - /* translators: %1$d: payments made, %2$d: total payments */
444 - __( 'Payment milestone reached: %1$d of %2$d payments completed (50%%). Halfway there!', 'subscription' ),
445 - $payments_made,
446 - $max_payments
447 - );
448 - $activity_type = __( 'Payment Milestone - 50%', 'subscription' );
449 - break;
450 -
451 - case 75:
452 - $milestone_note = sprintf(
453 - /* translators: %1$d: payments made, %2$d: total payments */
454 - __( 'Payment milestone reached: %1$d of %2$d payments completed (75%%). Almost complete!', 'subscription' ),
455 - $payments_made,
456 - $max_payments
457 - );
458 - $activity_type = __( 'Payment Milestone - 75%', 'subscription' );
459 - break;
460 -
461 - case 100:
462 - $milestone_note = sprintf(
463 - /* translators: %1$d: payments made, %2$d: total payments */
464 - __( 'Payment milestone reached: %1$d of %2$d payments completed (100%%). Split payment plan complete!', 'subscription' ),
465 - $payments_made,
466 - $max_payments
467 - );
468 - $activity_type = __( 'Payment Milestone - 100%', 'subscription' );
469 - break;
470 - }
471 -
472 - // Add milestone note if applicable
473 - if ( $milestone_note ) {
474 - $comment_id = wp_insert_comment(
475 - array(
476 - 'comment_author' => 'Subscription for WooCommerce',
477 - 'comment_content' => $milestone_note,
478 - 'comment_post_ID' => $subscription_id,
479 - 'comment_type' => 'order_note',
480 - )
481 - );
482 - update_comment_meta( $comment_id, '_subscrpt_activity', $activity_type );
483 - update_comment_meta( $comment_id, '_subscrpt_activity_type', 'split_payment' );
484 -
485 - // Mark milestone as logged
486 - update_post_meta( $subscription_id, $milestone_key, current_time( 'timestamp' ) );
487 434 }
488 435 }
489 436
490 437 /**