PluginProbe
Subscriptions for WooCommerce with Stripe Recurring Payments / 2.2.0
Subscriptions for WooCommerce with Stripe Recurring Payments v2.2.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/Helper.php +22 -6 1.11.2 → 2.2.0 View file →
@@ -1,5 +1,10 @@
1 1 <?php
2 +/**
3 + * Subscription helper utilities.
4 + *
5 + * @package SpringDevs\Subscription\Illuminate
6 + */
2 7
3 8 namespace SpringDevs\Subscription\Illuminate;
4 9
5 10 use SpringDevs\Subscription\Illuminate\Gateways\Stripe\Stripe;
@@ -68,8 +73,9 @@
68 73 'pending' => __( 'Pending', 'subscription' ),
69 74 'active' => __( 'Active', 'subscription' ),
70 75 'on-hold' => __( 'On Hold', 'subscription' ),
71 76 'expired' => __( 'Expired', 'subscription' ),
77 + 'completed' => __( 'Completed', 'subscription' ),
72 78 'pe_cancelled' => __( 'Pending Cancellation', 'subscription' ),
73 79 'cancelled' => __( 'Cancelled', 'subscription' ),
74 80 'draft' => __( 'Draft', 'subscription' ),
75 81 'trash' => __( 'Trash', 'subscription' ),
@@ -514,9 +520,10 @@
514 520 'post_title' => "Subscription #{$subscription_id}",
515 521 )
516 522 );
517 523 // Check if this is a split payment subscription
518 - $payment_type = $product->get_meta( '_subscrpt_payment_type' ) ?: 'recurring';
524 + $payment_type = $product->get_meta( '_subscrpt_payment_type' );
525 + $payment_type = $payment_type ? $payment_type : 'recurring';
519 526 $max_payments = $product->get_meta( '_subscrpt_max_no_payment' );
520 527
521 528 $comment_content = '';
522 529 $activity_type = '';
@@ -979,10 +986,13 @@
979 986 foreach ( $cart_items as $key => $cart_item ) {
980 987 $product = $cart_item['data'];
981 988 if ( $product->is_type( 'simple' ) && isset( $cart_item['subscription'] ) ) {
982 989 $cart_subscription = $cart_item['subscription'];
983 - $type = ucfirst( $cart_subscription['type'] );
984 - $price_data = self::build_cart_recurring_price_data( $cart_item, $key, $type );
990 + // Cadence word must respect the frequency (plan items store the raw
991 + // plural interval, e.g. "months"): singular for 1, plural + count above.
992 + $sub_time = max( 1, (int) ( $cart_subscription['time'] ?? 1 ) );
993 + $type = ( 1 === $sub_time ? '' : $sub_time . ' ' ) . ucfirst( self::get_typos( $sub_time, $cart_subscription['type'] ) );
994 + $price_data = self::build_cart_recurring_price_data( $cart_item, $key, $type );
985 995
986 996 $recurrs[ $key ] = array_merge(
987 997 $price_data,
988 998 array(
@@ -989,9 +999,14 @@
989 999 'trial_status' => ! is_null( $cart_subscription['trial'] ),
990 1000 'start_date' => self::start_date( $cart_subscription['trial'] ),
991 1001 'next_date' => self::next_date( ( $cart_subscription['time'] ?? 1 ) . ' ' . $cart_subscription['type'], $cart_subscription['trial'] ),
992 1002 'can_user_cancel' => $cart_item['data']->get_meta( '_subscrpt_user_cancel' ),
993 - 'max_no_payment' => $cart_item['data']->get_meta( '_subscrpt_max_no_payment' ),
1003 + 'max_no_payment' => ! empty( $cart_item['subscrpt_max_no_payment'] )
1004 + ? (int) $cart_item['subscrpt_max_no_payment']
1005 + : $cart_item['data']->get_meta( '_subscrpt_max_no_payment' ),
1006 + // Exact plan total for split items (the entered price the split is
1007 + // divided from); null for classic split items which have no plan total.
1008 + 'split_total' => isset( $cart_item['subscrpt_split_total'] ) ? (float) $cart_item['subscrpt_split_total'] : null,
994 1009 'quantity' => (int) $cart_item['quantity'],
995 1010 )
996 1011 );
997 1012 }
@@ -1364,9 +1379,9 @@
1364 1379
1365 1380 $comment_id = wp_insert_comment(
1366 1381 array(
1367 1382 'comment_author' => 'Subscription for WooCommerce',
1368 - 'comment_content' => sprintf( 'Subscription Renewal order successfully created. order is %s', $new_order_id ),
1383 + 'comment_content' => sprintf( 'Subscription Renewal order successfully created. Order #%s', $new_order_id ),
1369 1384 'comment_post_ID' => $subscription_id,
1370 1385 'comment_type' => 'order_note',
1371 1386 )
1372 1387 );
@@ -1465,9 +1480,10 @@
1465 1480 );
1466 1481 }
1467 1482
1468 1483 if (
1469 - ! in_array( strtolower( $status ), array( 'cancelled', 'pending' ), true )
1484 + ! in_array( strtolower( $status ), array( 'cancelled', 'pending', 'completed' ), true )
1485 + && ! empty( $next_date )
1470 1486 && $next_datetime - time() <= 0
1471 1487 && (int) $default_grace_period > 0
1472 1488 ) {
1473 1489 $subscription_data['grace_period'] = array(