PluginProbe
Subscriptions for WooCommerce with Stripe Recurring Payments / 2.1.0
Subscriptions for WooCommerce with Stripe Recurring Payments v2.1.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 +37 -91 1.10.9 → 2.1.0 View file →
@@ -84,8 +84,17 @@
84 84
85 85 $next_date = sdevs_wp_strtotime( $recurr_timing, time() );
86 86 }
87 87
88 + // Split payment: no next date after the final installment.
89 + if (
90 + in_array( $subscription_history->type, array( 'renew', 'early-renew' ), true )
91 + && function_exists( 'subscrpt_is_max_payments_reached' )
92 + && subscrpt_is_max_payments_reached( $subscription_id )
93 + ) {
94 + return;
95 + }
96 +
88 97 /**
89 98 * Filter the subscription next payment date before it is saved.
90 99 *
91 100 * General-purpose hook (not scoped to split payment) for adjusting the
@@ -190,9 +199,8 @@
190 199 return;
191 200 }
192 201
193 202 $subtotal = '-';
194 - $item_id = $item->get_id();
195 203 $subscription_id = Helper::get_subscription_from_order_item_id( $item->get_id() );
196 204
197 205 if ( ! $subscription_id ) {
198 206 echo "<td class='item_recurring' width='15%'>-</td>";
@@ -199,10 +207,10 @@
199 207 return;
200 208 }
201 209 $subscription_id = $subscription_id->subscription_id;
202 210
203 - $price = get_post_meta( $subscription_id, '_subscrpt_price', true );
204 - $subtotal = Helper::format_price_with_order_item( $price, $item_id );
211 + // Strikes the original amount when a discount carries into renewals.
212 + $subtotal = Helper::get_subscription_recurring_price_html( $subscription_id, $item );
205 213 ?>
206 214 <td class="item_recurring" width="15%">
207 215 <div class="view">
208 216 <?php echo wp_kses_post( $subtotal ); ?>
@@ -264,12 +272,36 @@
264 272
265 273 foreach ( $histories as $history ) {
266 274 if ( 'new' === $history->type || 'renew' === $history->type ) {
267 275 $subscription_id = $history->subscription_id;
276 +
277 + // Renewals ignore the intermediate `processing` state for renewal orders.
278 + if ( 'renew' === $history->type && 'processing' === $order->get_status() ) {
279 + continue;
280 + }
281 +
282 + // Capture the status before the max-payments check below may flip it.
283 + $current_status = get_post_status( $subscription_id );
284 +
285 + // Split payment: complete instead of re-activate after the final installment.
286 + $target_status = $post_status;
287 + if (
288 + 'active' === $target_status
289 + && function_exists( 'subscrpt_is_max_payments_reached' )
290 + && subscrpt_is_max_payments_reached( $subscription_id )
291 + ) {
292 + $target_status = 'completed';
293 + }
294 +
295 + // Skip no-op transitions so the note and side effects don't duplicate.
296 + if ( $current_status === $target_status ) {
297 + continue;
298 + }
299 +
268 300 wp_update_post(
269 301 array(
270 302 'ID' => $subscription_id,
271 - 'post_status' => $post_status,
303 + 'post_status' => $target_status,
272 304 )
273 305 );
274 306
275 307 // If possible change order status to completed if it has a trial subscription.
@@ -284,9 +316,9 @@
284 316
285 317 // Add enhanced split payment activity logging
286 318 $this->add_split_payment_activity_note( $history->subscription_id, $history->type, $post_status, $order );
287 319
288 - Action::write_comment( $post_status, $history->subscription_id );
320 + Action::write_comment( $target_status, $history->subscription_id );
289 321 } else {
290 322 do_action( 'subscrpt_order_status_changed', $order, $history );
291 323 }
292 324 }
@@ -397,94 +429,8 @@
397 429 $max_payments,
398 430 $subscription_id
399 431 );
400 432 $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 433 }
488 434 }
489 435
490 436 /**