'_billing_interval',
- 'class' => 'billing_interval',
- 'label' => __( 'Payment:', 'woocommerce-subscriptions' ),
- 'value' => $the_subscription->get_billing_interval(),
- 'options' => wcs_get_subscription_period_interval_strings(),
- )
- );
+
+ '_billing_interval',
+ 'class' => 'billing_interval',
+ 'label' => __( 'Payment:', 'woocommerce-subscriptions' ),
+ 'value' => $the_subscription->get_billing_interval(),
+ 'options' => wcs_get_subscription_period_interval_strings(),
+ ),
+ $the_subscription
+ );
- // Billing Period
- echo woocommerce_wp_select(
- array(
- 'id' => '_billing_period',
- 'class' => 'billing_period',
- 'label' => __( 'Billing Period', 'woocommerce-subscriptions' ),
- 'value' => $the_subscription->get_billing_period(),
- 'options' => wcs_get_subscription_period_strings(),
- )
- );
+ // Billing Period
+ wcs_woocommerce_wp_select(
+ array(
+ 'id' => '_billing_period',
+ 'class' => 'billing_period',
+ 'label' => __( 'Billing Period', 'woocommerce-subscriptions' ),
+ 'value' => $the_subscription->get_billing_period(),
+ 'options' => wcs_get_subscription_period_strings(),
+ ),
+ $the_subscription
+ );
?>
diff --git a/vendor/woocommerce/subscriptions-core/includes/admin/wcs-admin-functions.php b/vendor/woocommerce/subscriptions-core/includes/admin/wcs-admin-functions.php
index 9244ce2..83e12ff 100644
--- a/vendor/woocommerce/subscriptions-core/includes/admin/wcs-admin-functions.php
+++ b/vendor/woocommerce/subscriptions-core/includes/admin/wcs-admin-functions.php
@@ -5,7 +5,7 @@
* @author Prospress
* @category Core
* @package WooCommerce Subscriptions/Functions
- * @version 2.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -16,7 +16,7 @@ if ( ! defined( 'ABSPATH' ) ) {
* Store a message to display via @see wcs_display_admin_notices().
*
* @param string The message to display
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_add_admin_notice( $message, $notice_type = 'success' ) {
@@ -36,7 +36,7 @@ function wcs_add_admin_notice( $message, $notice_type = 'success' ) {
*
* This method is also hooked to 'admin_notices' to display notices there.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_display_admin_notices( $clear = true ) {
@@ -64,7 +64,7 @@ add_action( 'admin_notices', 'wcs_display_admin_notices' );
/**
* Delete any admin notices we stored for display later.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_clear_admin_notices() {
delete_transient( '_wcs_admin_notices' );
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wc-product-subscription-variation.php b/vendor/woocommerce/subscriptions-core/includes/class-wc-product-subscription-variation.php
index d14ab33..8782936 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wc-product-subscription-variation.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wc-product-subscription-variation.php
@@ -8,7 +8,7 @@
* @class WC_Product_Subscription
* @package WooCommerce Subscriptions
* @category Class
- * @since 1.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.3
*
*/
if ( ! defined( 'ABSPATH' ) ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wc-product-subscription.php b/vendor/woocommerce/subscriptions-core/includes/class-wc-product-subscription.php
index acf0e89..1b4aa5b 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wc-product-subscription.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wc-product-subscription.php
@@ -8,7 +8,7 @@
* @package WooCommerce Subscriptions
* @subpackage WC_Product_Subscription
* @category Class
- * @since 1.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.3
*
*/
if ( ! defined( 'ABSPATH' ) ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wc-product-variable-subscription.php b/vendor/woocommerce/subscriptions-core/includes/class-wc-product-variable-subscription.php
index 1848935..2385d45 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wc-product-variable-subscription.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wc-product-variable-subscription.php
@@ -7,7 +7,7 @@
* @class WC_Product_Variable_Subscription
* @package WooCommerce Subscriptions
* @category Class
- * @since 1.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.3
*
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -183,7 +183,7 @@ class WC_Product_Variable_Subscription extends WC_Product_Variable {
*
* @param array $min_and_max_data The min and max variation data returned by @see wcs_get_min_max_variation_data(). Optional.
* @param array $variation_ids The child variation IDs. Optional. By default this value be generated by @see WC_Product_Variable->get_visible_children().
- * @since 2.3.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.0
*/
public function set_min_and_max_variation_data( $min_and_max_data = array(), $variation_ids = array() ) {
@@ -210,7 +210,7 @@ class WC_Product_Variable_Subscription extends WC_Product_Variable {
*
* @param array $variation_ids An array of variation IDs.
* @return array The variable product's min and max variation data.
- * @since 2.3.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.0
*/
public function get_min_and_max_variation_data( $variation_ids ) {
$variation_ids_hash = $this->get_variation_ids_hash( $variation_ids );
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscription-item-coupon-pending-switch.php b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscription-item-coupon-pending-switch.php
index 6a5dfbf..fa4a8fc 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscription-item-coupon-pending-switch.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscription-item-coupon-pending-switch.php
@@ -7,7 +7,7 @@
* @author Prospress
* @category Class
* @package WooCommerce Subscriptions
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
class WC_Subscription_Item_Coupon_Pending_Switch extends WC_Order_Item_Coupon {
@@ -16,7 +16,7 @@ class WC_Subscription_Item_Coupon_Pending_Switch extends WC_Order_Item_Coupon {
* Get item type.
*
* @return string
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
public function get_type() {
return 'coupon_pending_switch';
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscription-item-fee-pending-switch.php b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscription-item-fee-pending-switch.php
index 71856c4..cb4d054 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscription-item-fee-pending-switch.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscription-item-fee-pending-switch.php
@@ -7,7 +7,7 @@
* @author Prospress
* @category Class
* @package WooCommerce Subscriptions
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
class WC_Subscription_Item_Fee_Pending_Switch extends WC_Order_Item_Fee {
@@ -16,7 +16,7 @@ class WC_Subscription_Item_Fee_Pending_Switch extends WC_Order_Item_Fee {
* Get item type.
*
* @return string
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
public function get_type() {
return 'fee_pending_switch';
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscription-line-item-removed.php b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscription-line-item-removed.php
index 1fa8320..ef6bf9d 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscription-line-item-removed.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscription-line-item-removed.php
@@ -7,7 +7,7 @@
* @author Prospress
* @category Class
* @package WooCommerce Subscriptions
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
class WC_Subscription_Line_Item_Removed extends WC_Order_Item_Product {
@@ -16,7 +16,7 @@ class WC_Subscription_Line_Item_Removed extends WC_Order_Item_Product {
* Get item type.
*
* @return string
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
public function get_type() {
return 'line_item_removed';
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscription-line-item-switched.php b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscription-line-item-switched.php
index 599c257..3483f00 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscription-line-item-switched.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscription-line-item-switched.php
@@ -7,7 +7,7 @@
* @author Prospress
* @category Class
* @package WooCommerce Subscriptions
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
class WC_Subscription_Line_Item_Switched extends WC_Order_Item_Product {
@@ -16,7 +16,7 @@ class WC_Subscription_Line_Item_Switched extends WC_Order_Item_Product {
* Get item type.
*
* @return string
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
public function get_type() {
return 'line_item_switched';
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscription.php b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscription.php
index cf4dfe7..a50ac7f 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscription.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscription.php
@@ -6,7 +6,7 @@
* from WC_Order that don't exist in WC_Abstract_Order (which would seem the more appropriate choice)
*
* @class WC_Subscription
- * @version 2.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
* @package WooCommerce Subscriptions/Classes
* @category Class
* @author Brent Shepherd
@@ -93,11 +93,14 @@ class WC_Subscription extends WC_Order {
);
/**
- * Initialize the subscription object.
+ * Initializes a specific subscription if the ID is passed, otherwise a new and empty instance of a subscription.
*
- * @param int|WC_Subscription $subscription
+ * This class should NOT be instantiated, instead the functions wcs_create_subscription() and wcs_get_subscription()
+ * should be used.
+ *
+ * @param int|WC_Subscription $subscription Subscription to read.
*/
- public function __construct( $subscription ) {
+ public function __construct( $subscription = 0 ) {
// Add subscription date types as extra subscription data.
foreach ( wcs_get_subscription_date_types() as $date_type => $date_name ) {
@@ -253,7 +256,7 @@ class WC_Subscription extends WC_Order {
* @param string $subscription_key A subscription key of the form created by @see self::get_subscription_key()
* @param int $user_id The ID of the user who owns the subscriptions. Although this parameter is optional, if you have the User ID you should pass it to improve performance.
* @return bool True if the subscription has an unpaid renewal order, false if the subscription has no unpaid renewal orders.
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function needs_payment() {
@@ -295,7 +298,7 @@ class WC_Subscription extends WC_Order {
* 'subscription_cancellation'
* 'subscription_date_changes'
* 'subscription_amount_changes'
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function payment_method_supports( $payment_gateway_feature ) {
@@ -631,28 +634,32 @@ class WC_Subscription extends WC_Order {
}
/**
- * Overrides the WC Order get_status function for draft and auto-draft statuses for a subscription
- * so that it will return a pending status instead of draft / auto-draft.
+ * Sets the subscription status.
*
- * @since 2.0
- * @return string Status
+ * Overrides the WC Order set_status() function to handle 'draft' and 'auto-draft' statuses for a subscription.
+ *
+ * 'draft' and 'auto-draft' statuses are WP statuses applied to the post when a subscription is created via admin. When
+ * a subscription is being read from the database, and the status is set to the post's 'draft' or 'auto-draft' status, the
+ * subscription status is treated as the default status - 'pending'.
+ *
+ * @since 5.1.0
+ *
+ * @param string $new_status The new status.
+ * @param string $note Optional. The note to add to the subscription.
+ * @param bool $manual Optional. Is the status change triggered manually? Default is false.
*/
- public function get_status( $context = 'view' ) {
-
- if ( in_array( get_post_status( $this->get_id() ), array( 'draft', 'auto-draft' ) ) ) {
- $this->post_status = 'wc-pending';
- $status = apply_filters( 'woocommerce_order_get_status', 'pending', $this );
- } else {
- $status = parent::get_status();
+ public function set_status( $new_status, $note = '', $manual_update = false ) {
+ if ( ! $this->object_read && in_array( $new_status, [ 'draft', 'auto-draft' ], true ) ) {
+ $new_status = apply_filters( 'woocommerce_default_subscription_status', 'pending' );
}
- return $status;
+ return parent::set_status( $new_status, $note, $manual_update );
}
/**
* Get valid order status keys
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @return array details of change
*/
public function get_valid_statuses() {
@@ -664,7 +671,7 @@ class WC_Subscription extends WC_Order {
* it stores it with the prefix. This makes it hard to use the same filters / status names in both WC's methods AND WP's
* get_posts functions. This function bridges that gap and returns the prefixed versions of completed statuses.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
* @return array By default: wc-processing and wc-completed
*/
public function get_paid_order_statuses() {
@@ -695,7 +702,7 @@ class WC_Subscription extends WC_Order {
* @param string $payment_type Type of count (completed|refunded|net). Optional. Default completed.
* @param string|array $order_types Type of order relation(s) to count. Optional. Default array(parent,renewal).
* @return integer Count.
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
public function get_payment_count( $payment_type = 'completed', $order_types = '' ) {
@@ -785,7 +792,7 @@ class WC_Subscription extends WC_Order {
*
* Failed orders are the number of orders that have wc-failed as the status
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function get_failed_payment_count() {
@@ -807,7 +814,7 @@ class WC_Subscription extends WC_Order {
* otherwise it will be the sum of the sign up fee and price per period.
*
* @return float The total initial amount charged when the subscription product in the order was first purchased, if any.
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function get_total_initial_payment() {
$initial_total = ( $parent_order = $this->get_parent() ) ? $parent_order->get_total() : 0;
@@ -818,7 +825,7 @@ class WC_Subscription extends WC_Order {
* Get billing period.
*
* @return string
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
public function get_billing_period( $context = 'view' ) {
return $this->get_prop( 'billing_period', $context );
@@ -828,7 +835,7 @@ class WC_Subscription extends WC_Order {
* Get billing interval.
*
* @return string
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
public function get_billing_interval( $context = 'view' ) {
return $this->get_prop( 'billing_interval', $context );
@@ -838,7 +845,7 @@ class WC_Subscription extends WC_Order {
* Get trial period.
*
* @return string
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
public function get_trial_period( $context = 'view' ) {
return $this->get_prop( 'trial_period', $context );
@@ -848,7 +855,7 @@ class WC_Subscription extends WC_Order {
* Get suspension count.
*
* @return int
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
public function get_suspension_count( $context = 'view' ) {
return $this->get_prop( 'suspension_count', $context );
@@ -859,7 +866,7 @@ class WC_Subscription extends WC_Order {
*
* @access public
* @return bool
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
public function get_requires_manual_renewal( $context = 'view' ) {
return $this->get_prop( 'requires_manual_renewal', $context );
@@ -868,7 +875,7 @@ class WC_Subscription extends WC_Order {
/**
* Get the switch data.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @return string
*/
public function get_switch_data( $context = 'view' ) {
@@ -889,7 +896,7 @@ class WC_Subscription extends WC_Order {
/**
* Set billing period.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @param string $value
*/
public function set_billing_period( $value ) {
@@ -899,7 +906,7 @@ class WC_Subscription extends WC_Order {
/**
* Set billing interval.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @param int $value
*/
public function set_billing_interval( $value ) {
@@ -910,7 +917,7 @@ class WC_Subscription extends WC_Order {
* Set trial period.
*
* @param string $value
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
public function set_trial_period( $value ) {
$this->set_prop( 'trial_period', $value );
@@ -919,18 +926,33 @@ class WC_Subscription extends WC_Order {
/**
* Set suspension count.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @param int $value
*/
public function set_suspension_count( $value ) {
$this->set_prop( 'suspension_count', absint( $value ) );
}
+ /**
+ * Set schedule start date.
+ *
+ * This function should not be used. It only exists to support setting the start date on subscription creation without
+ * having to call update_dates() which results in a save.
+ *
+ * The more aptly named set_schedule_start() cannot exist because then WC core thinks the _schedule_start meta is an
+ * internal meta key and throws errors.
+ *
+ * @param string $schedule_start
+ */
+ public function set_start_date( $schedule_start ) {
+ $this->set_prop( 'schedule_start', $schedule_start );
+ }
+
/**
* Set parent order ID. We don't use WC_Abstract_Order::set_parent_id() because we want to allow false
* parent IDs, like 0.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @param int $value
*/
public function set_parent_id( $value ) {
@@ -945,7 +967,7 @@ class WC_Subscription extends WC_Order {
* (which means it doesn't require manual renewal), but we want to consistently use it via get/set as a boolean,
* for sanity's sake.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @param bool $value
*/
public function set_requires_manual_renewal( $value ) {
@@ -964,7 +986,7 @@ class WC_Subscription extends WC_Order {
/**
* Set the switch data on the subscription.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
public function set_switch_data( $value ) {
$this->set_prop( 'switch_data', $value );
@@ -973,7 +995,7 @@ class WC_Subscription extends WC_Order {
/**
* Set the flag about whether the cancelled email has been sent or not.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
public function set_cancelled_email_sent( $value ) {
$this->set_prop( 'cancelled_email_sent', $value );
@@ -1130,7 +1152,7 @@ class WC_Subscription extends WC_Order {
* Get a certain date type for the most recent order on the subscription with that date type,
* or the last order, if the order type is specified as 'last'.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @param string $date_type Any valid WC 3.0 date property, including 'date_paid', 'date_completed', 'date_created', or 'date_modified'
* @param string $order_type The type of orders to return, can be 'last', 'parent', 'switch', 'renewal' or 'any'. Default 'any'. Use 'last' to only check the last order.
* @return WC_DateTime|NULL object if the date is set or null if there is no date.
@@ -1159,7 +1181,7 @@ class WC_Subscription extends WC_Order {
/**
* Set a certain date type for the last order on the subscription.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @param string $date_type One of 'date_paid', 'date_completed', 'date_modified', or 'date_created'.
*/
protected function set_last_order_date( $date_type, $date = null ) {
@@ -1505,7 +1527,7 @@ class WC_Subscription extends WC_Order {
* Sometimes it's necessary to only save changes to date properties, for example, when you
* don't want status transitions to be triggered by a full object @see $this->save().
*
- * @since 2.2.6
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.6
*/
public function save_dates() {
if ( $this->data_store && $this->get_id() ) {
@@ -1769,7 +1791,7 @@ class WC_Subscription extends WC_Order {
/**
* When a payment fails, either for the original purchase or a renewal payment, this function processes it.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function payment_failed( $new_status = 'on-hold' ) {
@@ -1806,7 +1828,7 @@ class WC_Subscription extends WC_Order {
/**
* Get order refunds
*
- * @since 2.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2
* @return array
*/
public function get_refunds() {
@@ -1816,7 +1838,7 @@ class WC_Subscription extends WC_Order {
/**
* Get amount already refunded
*
- * @since 2.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2
* @return int|float
*/
public function get_total_refunded() {
@@ -1877,7 +1899,7 @@ class WC_Subscription extends WC_Order {
* Extracting the query from get_related_orders and get_last_order so it can be moved in a cached
* value.
*
- * @deprecated 2.3.0 Moved to WCS_Subscription_Data_Store_CPT::get_related_order_ids() to separate cache logic from subscription instances and to avoid confusion from the misnomer on this method's name - it gets renewal orders, not related orders - and its ambiguity - it runs a query and returns order IDs, it does not return a SQL query string or order objects.
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.0, Moved to WCS_Subscription_Data_Store_CPT::get_related_order_ids() to separate cache logic from subscription instances and to avoid confusion from the misnomer on this method's name - it gets renewal orders, not related orders - and its ambiguity - it runs a query and returns order IDs, it does not return a SQL query string or order objects.
* @return array
*/
public function get_related_orders_query( $subscription_id ) {
@@ -1890,7 +1912,7 @@ class WC_Subscription extends WC_Order {
*
* @param string $return_fields The columns to return, either 'all' or 'ids'
* @param array|string $order_types Can include 'any', 'parent', 'renewal', 'resubscribe' and/or 'switch'. Custom types possible via the 'woocommerce_subscription_related_orders' filter. Defaults to array( 'parent', 'renewal', 'switch' ).
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
* @return array
*/
public function get_related_orders( $return_fields = 'ids', $order_types = array( 'parent', 'renewal', 'switch' ) ) {
@@ -1929,7 +1951,7 @@ class WC_Subscription extends WC_Order {
*
* @param string $order_type Can include 'any', 'parent', 'renewal', 'resubscribe' and/or 'switch'. Defaults to 'any'.
* @return array List of related order IDs.
- * @since 2.3.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.0
*/
protected function get_related_order_ids( $order_type = 'any' ) {
@@ -1956,7 +1978,7 @@ class WC_Subscription extends WC_Order {
*
* @param string $return_fields The columns to return, either 'all' or 'ids'
* @param array $order_types Can include any combination of 'parent', 'renewal', 'switch' or 'any' which will return the latest renewal order of any type. Defaults to 'parent' and 'renewal'.
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function get_last_order( $return_fields = 'ids', $order_types = array( 'parent', 'renewal' ) ) {
@@ -1999,7 +2021,7 @@ class WC_Subscription extends WC_Order {
*
* @param string $context The context the payment method is being displayed in. Can be 'admin' or 'customer'. Default 'admin'.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function get_payment_method_to_display( $context = 'admin' ) {
@@ -2037,7 +2059,7 @@ class WC_Subscription extends WC_Order {
/**
* Save new payment method for a subscription
*
- * @since 2.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.0
*
* @throws InvalidArgumentException An exception is thrown via @see WC_Subscription::set_payment_method_meta() if the payment meta passed is invalid.
* @param WC_Payment_Gateway|string $payment_method
@@ -2092,7 +2114,7 @@ class WC_Subscription extends WC_Order {
/**
* Save payment method meta data for the Subscription
*
- * @since 2.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.0
*
* @throws InvalidArgumentException An exception if the payment meta variable isn't an array.
*
@@ -2115,7 +2137,7 @@ class WC_Subscription extends WC_Order {
/**
* Now uses the URL /my-account/view-subscription/{post-id} when viewing a subscription from the My Account Page.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function get_view_order_url() {
$view_subscription_url = wc_get_endpoint_url( 'view-subscription', $this->get_id(), wc_get_page_permalink( 'myaccount' ) );
@@ -2163,7 +2185,7 @@ class WC_Subscription extends WC_Order {
/**
* Check if the subscription has a payment gateway.
*
- * @since 2.5.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.0
* @return bool
*/
public function has_payment_gateway() {
@@ -2174,7 +2196,7 @@ class WC_Subscription extends WC_Order {
* The total sign-up fee for the subscription if any.
*
* @return int
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function get_sign_up_fee() {
@@ -2200,7 +2222,7 @@ class WC_Subscription extends WC_Order {
* @param array|int Either an order item (in the array format returned by self::get_items()) or the ID of an order item.
* @param string $tax_inclusive_or_exclusive Whether or not to adjust sign up fee if prices inc tax - ensures that the sign up fee paid amount includes the paid tax if inc
* @return bool
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function get_items_sign_up_fee( $line_item, $tax_inclusive_or_exclusive = 'exclusive_of_tax' ) {
@@ -2269,7 +2291,7 @@ class WC_Subscription extends WC_Order {
* Determine if the subscription is for one payment only.
*
* @return bool whether the subscription is for only one payment
- * @since 2.0.17
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.17
*/
public function is_one_payment() {
@@ -2455,7 +2477,7 @@ class WC_Subscription extends WC_Order {
/**
* Add a product line item to the subscription.
*
- * @since 2.1.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1.4
* @param WC_Product product
* @param int line item quantity.
* @param array args
@@ -2477,7 +2499,7 @@ class WC_Subscription extends WC_Order {
*
* The allowed dates includes both subscription date dates, and date types for related orders, like 'last_order_date_created'.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @return array
*/
protected function get_valid_date_types() {
@@ -2505,7 +2527,7 @@ class WC_Subscription extends WC_Order {
* Generates a URL to add or change the subscription's payment method from the my account page.
*
* @return string
- * @since 2.5.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.0
*/
public function get_change_payment_method_url() {
$change_payment_method_url = wc_get_endpoint_url( 'subscription-payment-method', $this->get_id(), wc_get_page_permalink( 'myaccount' ) );
@@ -2514,7 +2536,7 @@ class WC_Subscription extends WC_Order {
/* Get the subscription's payment method meta.
*
- * @since 2.4.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.4.3
* @return array The subscription's payment meta in the format returned by the woocommerce_subscription_payment_meta filter.
*/
public function get_payment_method_meta() {
@@ -2538,7 +2560,7 @@ class WC_Subscription extends WC_Order {
/**
* Avoid running the expensive get_date_paid() query on related orders.
*
- * @since 2.2.19
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.19
*/
public function maybe_set_date_paid() {
return null;
@@ -2547,7 +2569,7 @@ class WC_Subscription extends WC_Order {
/**
* Avoid running the expensive get_date_completed() query on related orders.
*
- * @since 2.2.19
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.19
*/
protected function maybe_set_date_completed() {
return null;
@@ -2596,7 +2618,7 @@ class WC_Subscription extends WC_Order {
* Update the internal tally of suspensions on this subscription since the last payment.
*
* @return int The count of suspensions
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function update_suspension_count( $new_count ) {
wcs_deprecated_function( __METHOD__, '2.2.0', __CLASS__ . '::set_suspension_count(), because WooCommerce 3.0+ now uses setters' );
@@ -2629,8 +2651,8 @@ class WC_Subscription extends WC_Order {
*
* For backward compatibility we have to use the date created here, see: https://github.com/Prospress/woocommerce-subscriptions/issues/1943
*
- * @deprecated 2.2.0
- * @since 2.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
protected function get_last_payment_date() {
wcs_deprecated_function( __METHOD__, '2.2.0', __CLASS__ . '::get_date( "last_order_date_created" )' );
@@ -2640,7 +2662,7 @@ class WC_Subscription extends WC_Order {
/**
* Updated both the _paid_date and post date GMT with the WooCommerce < 3.0 date storage structures.
*
- * @deprecated 2.2.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @param string $datetime A MySQL formatted date/time string in GMT/UTC timezone.
*/
protected function update_last_payment_date( $datetime ) {
@@ -2668,7 +2690,7 @@ class WC_Subscription extends WC_Order {
* subscription was created as a result of a purchase from the front end rather than
* manually by the store manager).
*
- * @deprecated 2.6.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
public function get_completed_payment_count() {
wcs_deprecated_function( __METHOD__, '2.6.0', __CLASS__ . '::get_payment_count()' );
@@ -2684,7 +2706,7 @@ class WC_Subscription extends WC_Order {
*
* @return int
*
- * @deprecated 2.6.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
protected function apply_deprecated_completed_payment_count_filter( $count ) {
$deprecated_filter_hook = 'woocommerce_subscription_payment_completed_count';
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-addresses.php b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-addresses.php
index dd9bc35..24272a4 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-addresses.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-addresses.php
@@ -8,14 +8,14 @@
* @subpackage WC_Subscriptions_Addresses
* @category Class
* @author Brent Shepherd
- * @since 1.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.3
*/
class WC_Subscriptions_Addresses {
/**
* Bootstraps the class and hooks required actions & filters.
*
- * @since 1.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.3
*/
public static function init() {
@@ -39,7 +39,7 @@ class WC_Subscriptions_Addresses {
* @param int|WC_Subscription $subscription Post ID of a 'shop_subscription' post, or instance of a WC_Subscription object.
* @param int $user_id The ID of a user.
* @return bool Whether the user can edit the subscription's address.
- * @since 3.0.15
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.0.15
*/
private static function can_user_edit_subscription_address( $subscription, $user_id = 0 ) {
$subscription = wcs_get_subscription( $subscription );
@@ -52,15 +52,14 @@ class WC_Subscriptions_Addresses {
* Add a "Change Shipping Address" button to the "My Subscriptions" table for those subscriptions
* which require shipping.
*
- * @param array $all_actions The $subscription_id => $actions array with all actions that will be displayed for a subscription on the "My Subscriptions" table
- * @param array $subscriptions All of a given users subscriptions that will be displayed on the "My Subscriptions" table
- * @since 1.3
+ * @param array $actions The $subscription_id => $actions array with all actions that will be displayed for a subscription on the "My Subscriptions" table
+ * @param \WC_Subscription $subscription the Subscription object that is being viewed.
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.3
*/
public static function add_edit_address_subscription_action( $actions, $subscription ) {
-
if ( $subscription->needs_shipping_address() && $subscription->has_status( array( 'active', 'on-hold' ) ) ) {
$actions['change_address'] = array(
- 'url' => add_query_arg( array( 'subscription' => $subscription->get_id() ), wc_get_endpoint_url( 'edit-address', 'shipping' ) ),
+ 'url' => esc_url( add_query_arg( array( 'subscription' => $subscription->get_id() ), wc_get_endpoint_url( 'edit-address', 'shipping' ) ) ),
'name' => __( 'Change address', 'woocommerce-subscriptions' ),
);
}
@@ -71,7 +70,7 @@ class WC_Subscriptions_Addresses {
/**
* Redirects to "My Account" when attempting to edit the address on a subscription that doesn't belong to the user.
*
- * @since 3.0.15
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.0.15
*/
public static function maybe_restrict_edit_address_endpoint() {
if ( ! is_wc_endpoint_url() || 'edit-address' !== WC()->query->get_current_endpoint() || ! isset( $_GET['subscription'] ) ) {
@@ -93,7 +92,7 @@ class WC_Subscriptions_Addresses {
* also update the address on their active subscriptions. If editing a single subscription's address, the
* subscription key is added as a hidden field.
*
- * @since 1.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.3
*/
public static function maybe_add_edit_address_checkbox() {
global $wp;
@@ -140,7 +139,7 @@ class WC_Subscriptions_Addresses {
* the addresses on the initial order for each subscription.
*
* @param int $user_id The ID of a user who own's the subscription (and address)
- * @since 1.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.3
*/
public static function maybe_update_subscription_addresses( $user_id, $address_type ) {
@@ -159,21 +158,21 @@ class WC_Subscriptions_Addresses {
}
if ( isset( $_POST['update_all_subscriptions_addresses'] ) ) {
-
$users_subscriptions = wcs_get_users_subscriptions( $user_id );
foreach ( $users_subscriptions as $subscription ) {
if ( $subscription->has_status( array( 'active', 'on-hold' ) ) ) {
- $subscription->set_address( $address, $address_type );
+ wcs_set_order_address( $subscription, $address, $address_type );
+ $subscription->save();
}
}
} elseif ( isset( $_POST['update_subscription_address'] ) ) {
-
$subscription = wcs_get_subscription( absint( $_POST['update_subscription_address'] ) );
+ // Update the address only if the user actually owns the subscription
if ( $subscription && self::can_user_edit_subscription_address( $subscription->get_id() ) ) {
- // Update the address only if the user actually owns the subscription
- $subscription->set_address( $address, $address_type );
+ wcs_set_order_address( $subscription, $address, $address_type );
+ $subscription->save();
wp_safe_redirect( $subscription->get_view_order_url() );
exit();
@@ -185,7 +184,7 @@ class WC_Subscriptions_Addresses {
* Prepopulate the address fields on a subscription item
*
* @param array $address A WooCommerce address array
- * @since 1.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5
*/
public static function maybe_populate_subscription_addresses( $address ) {
$subscription_id = isset( $_GET['subscription'] ) ? absint( $_GET['subscription'] ) : 0;
@@ -211,7 +210,7 @@ class WC_Subscriptions_Addresses {
*
* @param array $subscription A WooCommerce Subscription array
* @param array $address_fields Locale aware address fields of the form returned by WC_Countries->get_address_fields() for a given country
- * @since 1.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.3
*/
public static function maybe_update_order_address( $subscription, $address_fields ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Order::set_address() or WC_Subscription::set_address()' );
@@ -222,7 +221,7 @@ class WC_Subscriptions_Addresses {
*
* @param array $crumbs
* @return array
- * @since 2.4.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.4.2
*/
public static function change_addresses_breadcrumb( $crumbs ) {
if ( isset( $_GET['subscription'] ) && is_wc_endpoint_url() && 'edit-address' === WC()->query->get_current_endpoint() ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-cart-validator.php b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-cart-validator.php
index f158eff..55a2572 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-cart-validator.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-cart-validator.php
@@ -7,7 +7,7 @@
* @package WooCommerce Subscriptions
* @subpackage WC_Subscriptions_Cart_Validator
* @category Class
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
class WC_Subscriptions_Cart_Validator {
@@ -28,7 +28,7 @@ class WC_Subscriptions_Cart_Validator {
*
* If multiple purchase flag is set, allow them to be added at the same time.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
public static function maybe_empty_cart( $valid, $product_id, $quantity, $variation_id = '', $variations = array() ) {
$is_subscription = WC_Subscriptions_Product::is_subscription( $product_id );
@@ -80,7 +80,7 @@ class WC_Subscriptions_Cart_Validator {
* @param $cart WC_Cart the one we got from session
* @return WC_Cart $cart
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
public static function validate_cart_contents_for_mixed_checkout( $cart ) {
@@ -119,7 +119,7 @@ class WC_Subscriptions_Cart_Validator {
/**
* Don't allow new subscription products to be added to the cart if it contains a subscription renewal already.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
public static function can_add_subscription_product_to_cart( $can_add, $product_id, $quantity, $variation_id = '', $variations = array(), $item_data = array() ) {
@@ -140,7 +140,7 @@ class WC_Subscriptions_Cart_Validator {
* purcahses disabled, the cart already contains products and the customer adds a new item or logs in
* causing a cart merge.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*
* @param array $fragments The add to cart AJAX args.
* @return array $fragments
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-cart.php b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-cart.php
index a2bd0f6..aea97ce 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-cart.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-cart.php
@@ -8,7 +8,7 @@
* @subpackage WC_Subscriptions_Cart
* @category Class
* @author Brent Shepherd
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
class WC_Subscriptions_Cart {
@@ -22,42 +22,35 @@ class WC_Subscriptions_Cart {
* - 'recurring_total' used to calculate the totals for the recurring amount when the recurring amount differs to to 'combined_total' because of coupons or sign-up fees.
* - 'free_trial_total' used to calculate the initial total when there is a free trial period and no sign-up fee. Different to 'combined_total' because shipping is not charged up-front when there is a free trial.
*
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
private static $calculation_type = 'none';
/**
* An internal pointer to the current recurring cart calculation (if any)
*
- * @since 2.0.12
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.12
*/
private static $recurring_cart_key = 'none';
/**
* A cache of the calculated recurring shipping packages
*
- * @since 2.0.13
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.13
*/
private static $recurring_shipping_packages = array();
- /**
- * A cache of the calculated shipping package rates
- *
- * @since 2.0.18
- */
- private static $shipping_rates = array();
-
/**
* A cache of the current recurring cart being calculated
*
- * @since 2.0.20
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.20
*/
private static $cached_recurring_cart = null;
/**
* Bootstraps the class and hooks required actions & filters.
*
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function init() {
// Make sure WC calculates total on sign up fee + price per period, and keep a record of the price per period
@@ -96,9 +89,6 @@ class WC_Subscriptions_Cart {
// Make sure we use our recurring shipping method for recurring shipping calculations not the default method
add_filter( 'woocommerce_shipping_chosen_method', array( __CLASS__, 'set_chosen_shipping_method' ), 10, 2 );
- // Cache package rates. Hook in early to ensure we get a full set of rates.
- add_filter( 'woocommerce_package_rates', __CLASS__ . '::cache_package_rates', 1, 2 );
-
// When WooCommerce calculates rates for a recurring shipping package, make sure there is a different set of rates
add_filter( 'woocommerce_shipping_package_name', __CLASS__ . '::change_initial_shipping_package_name', 1, 3 );
@@ -128,7 +118,7 @@ class WC_Subscriptions_Cart {
/**
* Attach dependant callbacks.
*
- * @since 2.5.6
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.6
*/
public static function attach_dependant_hooks() {
// WooCommerce determines if free shipping is available using the WC->cart total and coupons, we need to recalculate its availability when obtaining shipping methods for a recurring cart
@@ -145,7 +135,7 @@ class WC_Subscriptions_Cart {
* This function is hooked to "woocommerce_before_calculate_totals" so that WC will calculate a subscription
* product's total based on the total of it's price per period and sign up fee (if any).
*
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function add_calculation_price_filter() {
WC()->cart->recurring_carts = array();
@@ -164,7 +154,7 @@ class WC_Subscriptions_Cart {
* Removes the "set_subscription_prices_for_calculation" filter from the WC Product's woocommerce_get_price hook once
* calculations are complete.
*
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function remove_calculation_price_filter() {
remove_filter( 'woocommerce_product_get_price', __CLASS__ . '::set_subscription_prices_for_calculation', 100 );
@@ -201,7 +191,7 @@ class WC_Subscriptions_Cart {
* If there are subscriptions in the cart and the product is not a subscription, then
* set the recurring total to 0.
*
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function set_subscription_prices_for_calculation( $price, $product ) {
@@ -249,8 +239,8 @@ class WC_Subscriptions_Cart {
* product prices to see whether they include sign-up fees and/or free trial periods and then recalculates the
* appropriate totals by using the @see self::$calculation_type flag and cloning the cart to run @see WC_Cart::calculate_totals()
*
- * @since 1.3.5
- * @version 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.3.5
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function calculate_subscription_totals( $total, $cart ) {
if ( ! self::cart_contains_subscription() && ! wcs_cart_contains_resubscribe() ) { // cart doesn't contain subscription
@@ -355,7 +345,7 @@ class WC_Subscriptions_Cart {
/**
* Allow third-parties to override whether the fees will be removed from the initial order cart.
*
- * @since 2.4.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.4.3
* @param bool $remove_fees_from_cart Whether the fees will be removed. By default fees will be removed if there is no signup fee and all cart items have a trial.
* @param WC_Cart $cart The standard WC cart object.
* @param array $recurring_carts All the recurring cart objects.
@@ -402,7 +392,7 @@ class WC_Subscriptions_Cart {
*
* @internal self::all_cart_items_have_free_trial() is false if non-subscription products are in the cart.
*
- * @since 1.5.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5.4
*/
public static function charge_shipping_up_front() {
return apply_filters( 'woocommerce_subscriptions_cart_shipping_up_front', ! self::all_cart_items_have_free_trial() );
@@ -411,7 +401,7 @@ class WC_Subscriptions_Cart {
/**
* The cart needs shipping only if it needs shipping up front and/or for recurring items.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
* @param boolean $needs_shipping True if shipping is needed for the cart.
* @return boolean
*/
@@ -460,7 +450,7 @@ class WC_Subscriptions_Cart {
*
* @param $cart_item_key string The key for a cart item about to be removed from the cart.
* @return null
- * @since 2.0.15
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.15
*/
public static function maybe_reset_chosen_shipping_methods( $cart_item_key ) {
@@ -498,7 +488,7 @@ class WC_Subscriptions_Cart {
*
* @param string $recurring_cart_key a cart key of the form returned by @see self::get_recurring_cart_key()
* @param int $package_index the index of a package
- * @since 2.0.12
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.12
*/
public static function get_recurring_shipping_package_key( $recurring_cart_key, $package_index ) {
return $recurring_cart_key . '_' . $package_index;
@@ -518,7 +508,7 @@ class WC_Subscriptions_Cart {
* set of packages in WC()->shipping->packages so that plugins attempting to get the details of recurring
* packages can get them with WC()->shipping->get_packages() like any other packages.
*
- * @since 2.0.13
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.13
*/
public static function set_global_recurring_shipping_packages() {
foreach ( self::$recurring_shipping_packages as $recurring_cart_key => $packages ) {
@@ -533,7 +523,7 @@ class WC_Subscriptions_Cart {
*
* Useful for determining if certain up-front amounts should be charged.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function all_cart_items_have_free_trial() {
@@ -557,7 +547,7 @@ class WC_Subscriptions_Cart {
/**
* Check if the cart contains a subscription which requires shipping.
*
- * @since 1.5.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5.4
*/
public static function cart_contains_subscriptions_needing_shipping( $cart = null ) {
@@ -594,7 +584,7 @@ class WC_Subscriptions_Cart {
* Filters the cart contents to remove any subscriptions with free trials (or synchronised to a date in the future)
* to make sure no shipping amount is calculated for them.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function set_cart_shipping_packages( $packages ) {
if ( ! self::cart_contains_subscription() ) {
@@ -649,7 +639,7 @@ class WC_Subscriptions_Cart {
/**
* Checks whether or not the COD gateway should be available on checkout when a subscription has a free trial.
*
- * @since 3.0.6
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.0.6
*
* @param array $available_gateways The currently available payment gateways.
* @return array All of the available payment gateways.
@@ -695,7 +685,7 @@ class WC_Subscriptions_Cart {
/**
* Returns the subtotal for a cart item including the subscription period and duration details
*
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function get_formatted_product_subtotal( $product_subtotal, $product, $quantity, $cart ) {
@@ -746,7 +736,7 @@ class WC_Subscriptions_Cart {
/**
* Checks the cart to see if it contains a subscription product.
*
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
* @return boolean
*/
public static function cart_contains_subscription() {
@@ -763,7 +753,7 @@ class WC_Subscriptions_Cart {
/**
* Checks the cart to see if it contains a subscription product with a free trial
*
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function cart_contains_free_trial() {
@@ -784,7 +774,7 @@ class WC_Subscriptions_Cart {
/**
* Gets the cart calculation type flag
*
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function get_calculation_type() {
return self::$calculation_type;
@@ -793,7 +783,7 @@ class WC_Subscriptions_Cart {
/**
* Sets the cart calculation type flag
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function set_calculation_type( $calculation_type ) {
self::$calculation_type = $calculation_type;
@@ -828,7 +818,7 @@ class WC_Subscriptions_Cart {
* Currently short-circuits to return just the sign-up fee of the first subscription, because only
* one subscription can be purchased at a time.
*
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function get_cart_subscription_sign_up_fee() {
@@ -915,7 +905,7 @@ class WC_Subscriptions_Cart {
* the cart page because it triggers the method multiple times for multiple different pricing structures.
* This uses the same logic found in WC_Shortcode_Cart::output() to determine the correct estimate.
*
- * @since 1.4.10
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4.10
*/
private static function maybe_restore_shipping_methods() {
WC()->shipping->reset_shipping();
@@ -972,7 +962,7 @@ class WC_Subscriptions_Cart {
/**
* Make sure cart product prices correctly include/exclude taxes.
*
- * @since 1.5.8
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5.8
*/
public static function cart_product_price( $price, $product ) {
@@ -991,20 +981,19 @@ class WC_Subscriptions_Cart {
}
/**
- * Display the recurring totals for items in the cart
+ * Displays the recurring totals for items in the cart.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function display_recurring_totals() {
- if ( self::cart_contains_subscription() ) {
-
- // We only want shipping for recurring amounts, and they need to be calculated again here
+ if ( self::cart_contains_subscription() && ! empty( WC()->cart->recurring_carts ) ) {
+ // We only want shipping for recurring amounts, and they need to be calculated again here.
self::$calculation_type = 'recurring_total';
$carts_with_multiple_payments = 0;
foreach ( WC()->cart->recurring_carts as $recurring_cart ) {
- // Cart contains more than one payment
+ // Cart contains more than one payment.
if ( 0 != $recurring_cart->next_payment_date ) {
$carts_with_multiple_payments++;
}
@@ -1035,7 +1024,7 @@ class WC_Subscriptions_Cart {
* to allow products on the same billing schedule to be grouped together - free trials and synchronisation is accounted for by
* using the first renewal date (if any) for the susbcription.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_recurring_cart_key( $cart_item, $renewal_time = '' ) {
@@ -1096,7 +1085,7 @@ class WC_Subscriptions_Cart {
*
* @param array $shipping_methods
*
- * @since 2.0.13
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.13
*/
public static function filter_recurring_cart_chosen_shipping_method( $shipping_methods ) {
@@ -1132,37 +1121,47 @@ class WC_Subscriptions_Cart {
* Ensures there is at least one chosen shipping method and that the chosen method is valid considering the available
* package rates.
*
- * @since 2.0.14
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.14
*/
public static function validate_recurring_shipping_methods() {
$shipping_methods = WC()->checkout()->shipping_methods;
$added_invalid_notice = false;
$standard_packages = WC()->shipping->get_packages();
- // temporarily store the current calculation type and recurring cart key so we can restore them later
+ // Temporarily store the current calculation type and recurring cart key so we can restore them later.
$calculation_type = self::$calculation_type;
$recurring_cart_key_flag = self::$recurring_cart_key;
+ $cached_recurring_cart = self::$cached_recurring_cart;
self::set_calculation_type( 'recurring_total' );
foreach ( WC()->cart->recurring_carts as $recurring_cart_key => $recurring_cart ) {
- self::set_recurring_cart_key( $recurring_cart_key );
-
if ( false === $recurring_cart->needs_shipping() || 0 == $recurring_cart->next_payment_date ) {
continue;
}
+ // Set the recurring cart flags so shipping calculations have the recurring cart as context.
+ self::set_recurring_cart_key( $recurring_cart_key );
+ self::set_cached_recurring_cart( $recurring_cart );
+
foreach ( $recurring_cart->get_shipping_packages() as $recurring_cart_package_key => $recurring_cart_package ) {
$package_index = isset( $recurring_cart_package['package_index'] ) ? $recurring_cart_package['package_index'] : 0;
- $package = self::get_calculated_shipping_for_package( $recurring_cart_package );
+ $package = WC()->shipping->calculate_shipping_for_package( $recurring_cart_package );
- if ( ( isset( $standard_packages[ $package_index ] ) && $package['rates'] == $standard_packages[ $package_index ]['rates'] ) ) {
- // the recurring package rates match the initial package rates, there won't be a selected shipping method for this recurring cart package move on to the next package.
+ $package_rates_match = false;
+ if ( isset( $standard_packages[ $package_index ] ) ) {
+ // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
+ $package_rates_match = apply_filters( 'wcs_recurring_shipping_package_rates_match_standard_rates', $package['rates'] == $standard_packages[ $package_index ]['rates'], $package['rates'], $standard_packages[ $package_index ]['rates'], $recurring_cart_key );
+ }
+
+ if ( $package_rates_match ) {
+ // The recurring package rates match the initial package rates, there won't be a selected shipping method for this recurring cart package move on to the next package.
if ( apply_filters( 'wcs_cart_totals_shipping_html_price_only', true, $package, $recurring_cart ) ) {
continue;
}
}
+ // If the chosen shipping method is not available for this recurring cart package, display an error and unset the selected method.
if ( ! isset( $package['rates'][ $shipping_methods[ $recurring_cart_package_key ] ] ) ) {
if ( ! $added_invalid_notice ) {
wc_add_notice( __( 'Invalid recurring shipping method.', 'woocommerce-subscriptions' ), 'error' );
@@ -1179,8 +1178,10 @@ class WC_Subscriptions_Cart {
WC()->checkout()->shipping_methods = $shipping_methods;
}
+ // Restore the calculation type and recurring cart key.
self::set_calculation_type( $calculation_type );
self::set_recurring_cart_key( $recurring_cart_key_flag );
+ self::set_cached_recurring_cart( $cached_recurring_cart );
}
/**
@@ -1188,7 +1189,7 @@ class WC_Subscriptions_Cart {
*
* @param int The product ID or variation ID to look for.
* @return bool Whether the product is in the cart.
- * @since 2.0.13
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.13
*/
public static function cart_contains_product( $product_id ) {
@@ -1211,7 +1212,7 @@ class WC_Subscriptions_Cart {
*
* @param int The product ID or variation ID other than which to look for.
* @return bool Whether another subscription product is in the cart.
- * @since 3.0.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.0.5
*/
public static function cart_contains_other_subscription_products( $product_id ) {
@@ -1230,53 +1231,6 @@ class WC_Subscriptions_Cart {
return $cart_contains_other_subscription_products;
}
- /**
- * Cache the package rates calculated by @see WC_Shipping::calculate_shipping_for_package() to avoid multiple calls of calculate_shipping_for_package() per request.
- *
- * @param array $rates A set of WC_Shipping_Rate objects.
- * @param array $package A shipping package in the form returned by @see WC_Cart->get_shipping_packages()
- * @return array $rates An unaltered set of WC_Shipping_Rate objects passed to the function
- * @since 2.0.18
- */
- public static function cache_package_rates( $rates, $package ) {
- self::$shipping_rates[ self::get_package_shipping_rates_cache_key( $package ) ] = $rates;
-
- return $rates;
- }
-
- /**
- * Calculates the shipping rates for a package.
- *
- * This function will check cached rates based on a hash of the package contents to avoid re-calculation per page load.
- * If there are no rates stored in the cache for this package, it will fall back to @see WC_Shipping::calculate_shipping_for_package()
- *
- * @param array $package A shipping package in the form returned by @see WC_Cart->get_shipping_packages()
- * @return array $package
- * @since 2.0.18
- */
- public static function get_calculated_shipping_for_package( $package ) {
- $key = self::get_package_shipping_rates_cache_key( $package );
-
- if ( isset( self::$shipping_rates[ $key ] ) ) {
- $package['rates'] = apply_filters( 'woocommerce_package_rates', self::$shipping_rates[ $key ], $package );
- } else {
- $package = WC()->shipping->calculate_shipping_for_package( $package );
- }
-
- return $package;
- }
-
- /**
- * Generate a unique package key for a given shipping package to be used for caching package rates.
- *
- * @param array $package A shipping package in the form returned by WC_Cart->get_shipping_packages().
- * @return string key hash
- * @since 2.0.18
- */
- private static function get_package_shipping_rates_cache_key( $package ) {
- return md5( json_encode( array( array_keys( $package['contents'] ), $package['contents_cost'], $package['applied_coupons'] ) ) );
- }
-
/**
* When calculating the free shipping method availability, WC uses the WC->cart object. During shipping calculations for
* recurring carts we need the recurring cart's total and coupons to be the base for checking its availability
@@ -1285,7 +1239,7 @@ class WC_Subscriptions_Cart {
* @param array $package
* @return bool $is_available a revised version of is_available based off the recurring cart object
*
- * @since 2.0.20
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.20
*/
public static function maybe_recalculate_shipping_method_availability( $is_available, $package ) {
@@ -1325,7 +1279,7 @@ class WC_Subscriptions_Cart {
* By default WooCommerce core checks the initial cart for shipping method availability. For recurring carts,
* shipping method availability is based whether the recurring total and coupons meet the requirements.
*
- * @since 2.5.6
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.6
*
* @param bool $is_available Whether the shipping method is available or not.
* @param array $package a shipping package.
@@ -1355,7 +1309,7 @@ class WC_Subscriptions_Cart {
* Allow third-parties to apply fees which apply to the cart to recurring carts.
*
* @param WC_Cart
- * @since 2.2.16
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.16
*/
public static function apply_recurring_fees( $cart ) {
@@ -1386,7 +1340,7 @@ class WC_Subscriptions_Cart {
* that those packages no longer use the previously selected shipping method.
*
* @param string $encoded_form_data Encoded checkout form data.
- * @since 2.3.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.0
*/
public static function update_chosen_shipping_methods( $encoded_form_data ) {
$chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods', array() );
@@ -1406,7 +1360,7 @@ class WC_Subscriptions_Cart {
/**
* Removes all subscription products from the shopping cart.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
public static function remove_subscriptions_from_cart() {
@@ -1426,7 +1380,7 @@ class WC_Subscriptions_Cart {
* We need to record these base tax rates to be able to honour grandfathered subscription
* recurring prices in renewal carts.
*
- * @since 3.0.10
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.0.10
* @param WC_Cart $cart The cart object. Could be the global (initial cart) or a recurring cart.
*/
public static function record_base_tax_rates( $cart ) {
@@ -1463,7 +1417,7 @@ class WC_Subscriptions_Cart {
* use the recurring cart key instead of numeric index. Therefore, we need to hook in to override
* the default shipping method when WooCommerce could not find a matching shipping method.
*
- * @since 2.0.12
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.12
*
* @param string $default_method the default shipping method for the customer/store returned by WC_Shipping::get_default_method()
* @param array $available_methods set of shipping rates for this calculation
@@ -1491,7 +1445,7 @@ class WC_Subscriptions_Cart {
*
* Only enabled if multiple checkout is not enabled.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*
* @param string $url The cart redirect $url.
* @return string $url.
@@ -1529,11 +1483,43 @@ class WC_Subscriptions_Cart {
/* Deprecated */
+ /**
+ * Calculates the shipping rates for a package.
+ *
+ * This function will check cached rates based on a hash of the package contents to avoid re-calculation per page load.
+ * If there are no rates stored in the cache for this package, it will fall back to @see WC_Shipping::calculate_shipping_for_package()
+ *
+ * @deprecated 5.4.0
+ *
+ * @param array $package A shipping package in the form returned by @see WC_Cart->get_shipping_packages()
+ * @return array $package
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.18
+ */
+ public static function get_calculated_shipping_for_package( $package ) {
+ _deprecated_function( __METHOD__, 'subscriptions-core 5.4.0', 'WC()->shipping->calculate_shipping_for_package()' );
+ return WC()->shipping->calculate_shipping_for_package( $package );
+ }
+
+ /**
+ * Cache the package rates calculated by @see WC_Shipping::calculate_shipping_for_package() to avoid multiple calls of calculate_shipping_for_package() per request.
+ *
+ * @deprecated 5.4.0
+ *
+ * @param array $rates A set of WC_Shipping_Rate objects.
+ * @param array $package A shipping package in the form returned by @see WC_Cart->get_shipping_packages()
+ * @return array $rates An unaltered set of WC_Shipping_Rate objects passed to the function
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.18
+ */
+ public static function cache_package_rates( $rates, $package ) {
+ _deprecated_function( __METHOD__, 'subscriptions-core 5.4.0' );
+ return $rates;
+ }
+
/**
* Don't allow new subscription products to be added to the cart if it contains a subscription renewal already.
*
- * @deprecated 2.6.0
- * @since 2.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function check_valid_add_to_cart( $is_valid, $product_id, $quantity, $variation_id = '', $variations = array(), $item_data = array() ) {
_deprecated_function( __METHOD__, '2.6.0', 'WC_Subscriptions_Cart_Validator::check_valid_add_to_cart' );
@@ -1551,8 +1537,8 @@ class WC_Subscriptions_Cart {
* Make sure cart totals are calculated when the cart widget is populated via the get_refreshed_fragments() method
* so that @see self::get_formatted_cart_subtotal() returns the correct subtotal price string.
*
- * @since 1.5.11
- * @deprecated 2.5.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5.11
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.0
*/
public static function pre_get_refreshed_fragments() {
wcs_deprecated_function( __METHOD__, '2.5.0' );
@@ -1567,8 +1553,8 @@ class WC_Subscriptions_Cart {
*
* Returns the cart_item containing the product renewal, else false.
*
- * @deprecated 2.0
- * @since 1.3
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.3
*/
public static function cart_contains_subscription_renewal( $role = '' ) {
_deprecated_function( __METHOD__, '2.0', 'wcs_cart_contains_renewal( $role )' );
@@ -1580,8 +1566,8 @@ class WC_Subscriptions_Cart {
*
* Returns the cart_item containing the product renewal, else false.
*
- * @deprecated 2.0
- * @since 1.4
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4
*/
public static function cart_contains_failed_renewal_order_payment() {
_deprecated_function( __METHOD__, '2.0', 'wcs_cart_contains_failed_renewal_order_payment()' );
@@ -1593,7 +1579,7 @@ class WC_Subscriptions_Cart {
* Restore renewal flag when cart is reset and modify Product object with
* renewal order related info
*
- * @since 1.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.3
*/
public static function get_cart_item_from_session( $session_data, $values, $key ) {
_deprecated_function( __METHOD__, '2.0', 'WCS_Cart_Renewal::get_cart_item_from_session( $session_data, $values, $key )' );
@@ -1602,7 +1588,7 @@ class WC_Subscriptions_Cart {
/**
* For subscription renewal via cart, use original order discount
*
- * @since 1.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.3
*/
public static function before_calculate_totals( $cart ) {
_deprecated_function( __METHOD__, '2.0', 'WCS_Cart_Renewal::set_renewal_discounts( $cart )' );
@@ -1613,7 +1599,7 @@ class WC_Subscriptions_Cart {
*
* No longer required as of 1.3.5 as totals are calculated correctly internally.
*
- * @since 1.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.3
*/
public static function get_discounted_price_for_renewal( $price, $values, $cart ) {
_deprecated_function( __METHOD__, '2.0', 'WCS_Cart_Renewal::get_discounted_price_for_renewal( $price, $values, $cart )' );
@@ -1623,8 +1609,8 @@ class WC_Subscriptions_Cart {
* Returns a string with the cart discount and subscription period.
*
* @return mixed formatted price or false if there are none
- * @since 1.2
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_formatted_discounts_before_tax( $discount, $cart ) {
_deprecated_function( __METHOD__, '2.0', 'values from WC()->cart->recurring_carts' );
@@ -1635,8 +1621,8 @@ class WC_Subscriptions_Cart {
* Gets the order discount amount - these are applied after tax
*
* @return mixed formatted price or false if there are none
- * @since 1.2
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_formatted_discounts_after_tax( $discount, $cart ) {
_deprecated_function( __METHOD__, '2.0', 'values from WC()->cart->recurring_carts' );
@@ -1649,8 +1635,8 @@ class WC_Subscriptions_Cart {
* @param string $discount_html String of the coupon's discount amount
* @param string $coupon WC_Coupon object for the coupon to which this line item relates
* @return string formatted subscription price string if the cart includes a coupon being applied to recurring amount
- * @since 1.4.6
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4.6
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function cart_coupon_discount_amount_html( $discount_html, $coupon ) {
_deprecated_function( __METHOD__, '2.0', 'values from WC()->cart->recurring_carts' );
@@ -1663,8 +1649,8 @@ class WC_Subscriptions_Cart {
* @param string $discount_html String of the coupon's discount amount
* @param string $coupon WC_Coupon object for the coupon to which this line item relates
* @return string formatted subscription price string if the cart includes a coupon being applied to recurring amount
- * @since 1.4.6
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4.6
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function cart_totals_fee_html( $cart_totals_fee_html, $fee ) {
_deprecated_function( __METHOD__, '2.0', 'values from WC()->cart->recurring_carts' );
@@ -1674,9 +1660,9 @@ class WC_Subscriptions_Cart {
/**
* Includes the sign-up fee total in the cart total (after calculation).
*
- * @since 1.5.10
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5.10
* @return string formatted price
- * @deprecated 2.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_formatted_cart_total( $cart_contents_total ) {
_deprecated_function( __METHOD__, '2.0', 'values from WC()->cart->recurring_carts' );
@@ -1686,8 +1672,8 @@ class WC_Subscriptions_Cart {
/**
* Includes the sign-up fee subtotal in the subtotal displayed in the cart.
*
- * @since 1.2
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_formatted_cart_subtotal( $cart_subtotal, $compound, $cart ) {
_deprecated_function( __METHOD__, '2.0', 'values from WC()->cart->recurring_carts' );
@@ -1698,8 +1684,8 @@ class WC_Subscriptions_Cart {
* Returns an array of taxes merged by code, formatted with recurring amount ready for output.
*
* @return array Array of tax_id => tax_amounts for items in the cart
- * @since 1.3.5
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.3.5
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_recurring_tax_totals( $tax_totals, $cart ) {
_deprecated_function( __METHOD__, '2.0', 'values from WC()->cart->recurring_carts' );
@@ -1711,8 +1697,8 @@ class WC_Subscriptions_Cart {
* recurring amount.
*
* @return array Array of tax_id => tax_amounts for items in the cart
- * @since 1.4.10
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4.10
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_taxes_total_html( $total ) {
_deprecated_function( __METHOD__, '2.0', 'values from WC()->cart->recurring_carts' );
@@ -1723,8 +1709,8 @@ class WC_Subscriptions_Cart {
* Appends the cart subscription string to a cart total using the @see self::get_cart_subscription_string and then returns it.
*
* @return string Formatted subscription price string for the cart total.
- * @since 1.2
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_formatted_total( $total ) {
_deprecated_function( __METHOD__, '2.0', 'values from WC()->cart->recurring_carts' );
@@ -1735,8 +1721,8 @@ class WC_Subscriptions_Cart {
* Appends the cart subscription string to a cart total using the @see self::get_cart_subscription_string and then returns it.
*
* @return string Formatted subscription price string for the cart total.
- * @since 1.2
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_formatted_total_ex_tax( $total_ex_tax ) {
_deprecated_function( __METHOD__, '2.0', 'values from WC()->cart->recurring_carts' );
@@ -1746,8 +1732,8 @@ class WC_Subscriptions_Cart {
/**
* Returns an array of the recurring total fields
*
- * @since 1.2
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_recurring_totals_fields() {
_deprecated_function( __METHOD__, '2.0', 'recurring total values stored in WC()->cart->recurring_carts' );
@@ -1759,8 +1745,8 @@ class WC_Subscriptions_Cart {
*
* Deprecated because a cart can now contain multiple subscription products, so there is no single period for the entire cart.
*
- * @since 1.0
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_cart_subscription_period() {
_deprecated_function( __METHOD__, '2.0', 'values from WC()->cart->recurring_carts' );
@@ -1782,8 +1768,8 @@ class WC_Subscriptions_Cart {
*
* Deprecated because a cart can now contain multiple subscription products, so there is no single interval for the entire cart.
*
- * @since 1.0
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_cart_subscription_interval() {
_deprecated_function( __METHOD__, '2.0', 'values from WC()->cart->recurring_carts' );
@@ -1803,8 +1789,8 @@ class WC_Subscriptions_Cart {
*
* Deprecated because a cart can now contain multiple subscription products, so there is no single length for the entire cart.
*
- * @since 1.1
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.1
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_cart_subscription_length() {
_deprecated_function( __METHOD__, '2.0', 'values from WC()->cart->recurring_carts' );
@@ -1828,8 +1814,8 @@ class WC_Subscriptions_Cart {
*
* Deprecated because a cart can now contain multiple subscription products, so there is no single trial length for the entire cart.
*
- * @since 1.1
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.1
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_cart_subscription_trial_length() {
_deprecated_function( __METHOD__, '2.0', 'values from WC()->cart->recurring_carts' );
@@ -1853,8 +1839,8 @@ class WC_Subscriptions_Cart {
*
* Deprecated because a cart can now contain multiple subscription products, so there is no single trial period for the entire cart.
*
- * @since 1.2
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_cart_subscription_trial_period() {
_deprecated_function( __METHOD__, '2.0', 'values from WC()->cart->recurring_carts' );
@@ -1880,7 +1866,7 @@ class WC_Subscriptions_Cart {
* Deprecated because the cart can now contain subscriptions on multiple billing schedules so there is no one "total"
*
* @return float price
- * @deprecated 2.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_recurring_cart_contents_total() {
_deprecated_function( __METHOD__, '2.0', 'values from WC()->cart->recurring_carts' );
@@ -1904,7 +1890,7 @@ class WC_Subscriptions_Cart {
* Deprecated because the cart can now contain subscriptions on multiple billing schedules so there is no one "total"
*
* @return double The total recurring item subtotal amount less tax for items in the cart.
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function get_recurring_subtotal_ex_tax() {
_deprecated_function( __METHOD__, '2.0', 'values from WC()->cart->recurring_carts' );
@@ -1924,7 +1910,7 @@ class WC_Subscriptions_Cart {
* Deprecated because the cart can now contain subscriptions on multiple billing schedules so there is no one "total"
*
* @return double The total recurring item subtotal amount for items in the cart.
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function get_recurring_subtotal() {
_deprecated_function( __METHOD__, '2.0', 'values from WC()->cart->recurring_carts' );
@@ -1944,7 +1930,7 @@ class WC_Subscriptions_Cart {
* Deprecated because the cart can now contain subscriptions on multiple billing schedules so there is no one "total"
*
* @return double The total recurring cart discount amount for items in the cart.
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function get_recurring_discount_cart() {
_deprecated_function( __METHOD__, '2.0', 'values from WC()->cart->recurring_carts' );
@@ -1964,7 +1950,7 @@ class WC_Subscriptions_Cart {
* Deprecated because the cart can now contain subscriptions on multiple billing schedules so there is no one "total"
*
* @return double
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_recurring_discount_cart_tax() {
_deprecated_function( __METHOD__, '2.0', 'values from WC()->cart->recurring_carts' );
@@ -1984,7 +1970,7 @@ class WC_Subscriptions_Cart {
* Deprecated because the cart can now contain subscriptions on multiple billing schedules so there is no one "total"
*
* @return double The total recurring discount amount for items in the cart.
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function get_recurring_discount_total() {
_deprecated_function( __METHOD__, '2.0', 'values from WC()->cart->recurring_carts' );
@@ -2006,7 +1992,7 @@ class WC_Subscriptions_Cart {
* Deprecated because the cart can now contain subscriptions on multiple billing schedules so there is no one "total"
*
* @return double The total recurring shipping tax amount for items in the cart.
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function get_recurring_shipping_tax_total() {
_deprecated_function( __METHOD__, '2.0', 'values from WC()->cart->recurring_carts' );
@@ -2028,7 +2014,7 @@ class WC_Subscriptions_Cart {
* Deprecated because the cart can now contain subscriptions on multiple billing schedules so there is no one "total"
*
* @return double The total recurring shipping amount for items in the cart.
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function get_recurring_shipping_total() {
_deprecated_function( __METHOD__, '2.0', 'values from WC()->cart->recurring_carts' );
@@ -2048,7 +2034,7 @@ class WC_Subscriptions_Cart {
* Deprecated because the cart can now contain subscriptions on multiple billing schedules so there is no one "total"
*
* @return array Array of tax_id => tax_amounts for items in the cart
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function get_recurring_taxes() {
_deprecated_function( __METHOD__, '2.0', 'values from WC()->cart->recurring_carts' );
@@ -2072,7 +2058,7 @@ class WC_Subscriptions_Cart {
* Deprecated because the cart can now contain subscriptions on multiple billing schedules so there is no one "total"
*
* @return array Array of fee_id => fee_details for items in the cart
- * @since 1.4.9
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4.9
*/
public static function get_recurring_fees() {
_deprecated_function( __METHOD__, '2.0', 'values from WC()->cart->recurring_carts' );
@@ -2092,7 +2078,7 @@ class WC_Subscriptions_Cart {
* Deprecated because the cart can now contain subscriptions on multiple billing schedules so there is no one "total"
*
* @return double The total recurring tax amount tax for items in the cart (maybe not including compound taxes)
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function get_recurring_taxes_total( $compound = true ) {
_deprecated_function( __METHOD__, '2.0', 'values from WC()->cart->recurring_carts' );
@@ -2123,7 +2109,7 @@ class WC_Subscriptions_Cart {
* Deprecated because the cart can now contain subscriptions on multiple billing schedules so there is no one "total"
*
* @return double The total recurring tax amount tax for items in the cart.
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function get_recurring_total_tax() {
_deprecated_function( __METHOD__, '2.0', 'values from WC()->cart->recurring_carts' );
@@ -2143,7 +2129,7 @@ class WC_Subscriptions_Cart {
* Deprecated because the cart can now contain subscriptions on multiple billing schedules so there is no one "total"
*
* @return double The total recurring amount less tax for items in the cart.
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function get_recurring_total_ex_tax() {
_deprecated_function( __METHOD__, '2.0', 'values from WC()->cart->recurring_carts' );
@@ -2156,7 +2142,7 @@ class WC_Subscriptions_Cart {
* Deprecated because the cart can now contain subscriptions on multiple billing schedules so there is no one "total"
*
* @return double The total recurring amount for items in the cart.
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function get_recurring_total() {
_deprecated_function( __METHOD__, '2.0', 'values from WC()->cart->recurring_carts' );
@@ -2174,8 +2160,8 @@ class WC_Subscriptions_Cart {
* Calculate the total amount of recurring shipping needed. Removes any item from the calculation that
* is not a subscription and calculates the totals.
*
- * @since 1.5
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function calculate_recurring_shipping() {
_deprecated_function( __METHOD__, '2.0', 'values from WC()->cart->recurring_carts' );
@@ -2193,8 +2179,8 @@ class WC_Subscriptions_Cart {
* @param string $initial_amount The initial amount to be displayed for the subscription as passed through the @see woocommerce_price() function.
* @param float $recurring_amount The price to display in the subscription.
* @param array $args (optional) Flags to customise to display the trial and length of the subscription. Default to false - don't display.
- * @since 1.0
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_cart_subscription_string( $initial_amount, $recurring_amount, $args = array() ) {
_deprecated_function( __METHOD__, '2.0', 'values from WC()->cart->recurring_carts' );
@@ -2271,8 +2257,8 @@ class WC_Subscriptions_Cart {
* Uses the a subscription's combined price total calculated by WooCommerce to determine the
* total price that should be charged per period.
*
- * @since 1.2
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function set_calculated_total( $total ) {
_deprecated_function( __METHOD__, '2.0', 'values from WC()->cart->recurring_carts' );
@@ -2282,7 +2268,7 @@ class WC_Subscriptions_Cart {
/**
* Get the recurring amounts values from the session
*
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function get_cart_from_session() {
_deprecated_function( __METHOD__, '2.0' );
@@ -2291,7 +2277,7 @@ class WC_Subscriptions_Cart {
/**
* Store the sign-up fee cart values in the session
*
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function set_session() {
_deprecated_function( __METHOD__, '2.0' );
@@ -2300,7 +2286,7 @@ class WC_Subscriptions_Cart {
/**
* Reset the sign-up fee fields in the current session
*
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function reset() {
_deprecated_function( __METHOD__, '2.0' );
@@ -2310,7 +2296,7 @@ class WC_Subscriptions_Cart {
* Returns a cart item's product ID. For a variation, this will be a variation ID, for a simple product,
* it will be the product's ID.
*
- * @since 1.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5
*/
public static function get_items_product_id( $cart_item ) {
_deprecated_function( __METHOD__, '2.0', 'wcs_get_canonical_product_id( $cart_item )' );
@@ -2340,7 +2326,7 @@ class WC_Subscriptions_Cart {
* Don't display shipping prices if the initial order won't require shipping (i.e. all the products in the cart are subscriptions with a free trial or synchronised to a date in the future)
*
* @return string Label for a shipping method
- * @since 1.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.3
*/
public static function get_cart_shipping_method_full_label( $label, $method ) {
_deprecated_function( __METHOD__, '2.0.12' );
@@ -2522,9 +2508,9 @@ class WC_Subscriptions_Cart {
* We can't do this on the cart page unfortunately because it doesn't pass the entire forms post data and instead only
* sends the shipping methods with a numerical index.
*
- * @deprecated 3.1.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
* @return null
- * @since 2.0.12
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.12
*/
public static function add_shipping_method_post_data() {
wcs_deprecated_function( __METHOD__, '3.1.0' );
@@ -2566,10 +2552,10 @@ class WC_Subscriptions_Cart {
*
* For more details, see: https://github.com/Prospress/woocommerce-subscriptions/pull/1187#issuecomment-186091152
*
- * @deprecated 3.1.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
*
* @param array $packages An array of shipping package of the form returned by WC_Cart->get_shipping_packages() which includes the package's contents, cost, customer, destination and alternative rates
- * @since 2.0.19
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.19
*/
public static function reset_shipping_method_counts( $packages ) {
wcs_deprecated_function( __METHOD__, '3.1.0' );
@@ -2583,8 +2569,8 @@ class WC_Subscriptions_Cart {
/**
* Checks to see if payment method is required on a subscription product with a $0 initial payment.
*
- * @since 2.5.0
- * @deprecated 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*/
public static function zero_initial_payment_requires_payment() {
wcs_deprecated_function( __METHOD__, '4.0.0', 'WCS_Zero_Initial_Payment_Checkout_Manager::zero_initial_checkout_requires_payment() if available.' );
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-change-payment-gateway.php b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-change-payment-gateway.php
index d10cf5f..6662818 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-change-payment-gateway.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-change-payment-gateway.php
@@ -6,7 +6,7 @@
* @subpackage WC_Subscriptions_Change_Payment_Gateway
* @category Class
* @author Brent Shepherd
- * @since 1.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4
*/
class WC_Subscriptions_Change_Payment_Gateway {
@@ -22,7 +22,7 @@ class WC_Subscriptions_Change_Payment_Gateway {
/**
* Bootstraps the class and hooks required actions & filters.
*
- * @since 1.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4
*/
public static function init() {
@@ -78,7 +78,7 @@ class WC_Subscriptions_Change_Payment_Gateway {
* Set a flag to indicate that the current request is for changing payment. Better than requiring other extensions
* to check the $_GET global as it allows for the flag to be overridden.
*
- * @since 1.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4
*/
public static function set_change_payment_method_flag() {
if ( isset( $_GET['change_payment_method'] ) ) {
@@ -91,7 +91,7 @@ class WC_Subscriptions_Change_Payment_Gateway {
*
* This is particularly important for those occasions when the new payment method caused and error or failure.
*
- * @since 2.3.6
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.6
*/
public static function store_pay_shortcode_messages() {
self::$notices = wc_get_notices();
@@ -100,9 +100,8 @@ class WC_Subscriptions_Change_Payment_Gateway {
/**
* Store messages ore errors added by other plugins.
*
- * @since 1.4
- * @since 2.3.6 Deprecated in favor of the method with proper spelling.
- * @deprecated
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.6, Deprecated in favor of the method with proper spelling.
*/
public static function store_pay_shortcode_mesages() {
wcs_deprecated_function( __METHOD__, '2.3.6', __CLASS__ . '::store_pay_shortcode_messages' );
@@ -112,7 +111,7 @@ class WC_Subscriptions_Change_Payment_Gateway {
/**
* If requesting a payment method change, replace the woocommerce_pay_shortcode() with a change payment form.
*
- * @since 1.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4
*/
public static function maybe_replace_pay_shortcode() {
global $wp;
@@ -148,7 +147,7 @@ class WC_Subscriptions_Change_Payment_Gateway {
* Action that allows payment methods to modify the subscription object so, for example,
* if the new payment method still hasn't been set, they can set it temporarily (without saving).
*
- * @since 2.4.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.4.0
*
* @param WC_Subscription $subscription
*/
@@ -214,7 +213,7 @@ class WC_Subscriptions_Change_Payment_Gateway {
*
* Will display a customer facing notice if the request is invalid.
*
- * @since 3.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.0.0
*
* @param WC_Subscription $subscription
* @return bool Whether the request is valid or not.
@@ -247,7 +246,7 @@ class WC_Subscriptions_Change_Payment_Gateway {
*
* @param array $all_actions The $subscription_key => $actions array with all actions that will be displayed for a subscription on the "My Subscriptions" table
* @param array $subscriptions All of a given users subscriptions that will be displayed on the "My Subscriptions" table
- * @since 1.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4
*/
public static function change_payment_method_button( $actions, $subscription ) {
@@ -275,7 +274,7 @@ class WC_Subscriptions_Change_Payment_Gateway {
*
* @access public
* @return void
- * @since 1.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4
*/
public static function change_payment_method_via_pay_shortcode() {
@@ -332,7 +331,12 @@ class WC_Subscriptions_Change_Payment_Gateway {
// Process payment for the new method (with a $0 order total)
if ( wc_notice_count( 'error' ) == 0 ) {
- $result = $available_gateways[ $new_payment_method ]->process_payment( $subscription->get_id() );
+ try {
+ $result = $available_gateways[ $new_payment_method ]->process_payment( $subscription->get_id() );
+ } catch ( Exception $e ) {
+ wc_add_notice( $e->getMessage(), 'error' );
+ return;
+ }
if ( 'success' == $result['result'] && wc_get_page_permalink( 'myaccount' ) == $result['redirect'] ) {
$result['redirect'] = $subscription->get_view_order_url();
@@ -344,6 +348,14 @@ class WC_Subscriptions_Change_Payment_Gateway {
return;
}
+ /**
+ * After processing the payment result, make sure we get a new instance of the subscription.
+ *
+ * Because process_payment() is sent an ID, all subscription meta changes would occur on a different instance on the subscription.
+ * We need a new instance to ensure we have the latest changes when processing the update all subscription payment method request below.
+ */
+ $subscription = wcs_get_subscription( $subscription->get_id() );
+
$subscription->set_requires_manual_renewal( false );
$subscription->save();
@@ -365,7 +377,7 @@ class WC_Subscriptions_Change_Payment_Gateway {
// Redirect to success/confirmation/payment page
wc_add_notice( $notice );
- wp_redirect( $result['redirect'] );
+ wp_safe_redirect( $result['redirect'] );
exit;
}
}
@@ -379,7 +391,7 @@ class WC_Subscriptions_Change_Payment_Gateway {
* @param WC_Subscription $subscription An instance of a WC_Subscription object.
* @param string $new_payment_method The ID of the new payment method.
* @return bool Were other subscriptions updated.
- * @since 2.5.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.0
*/
public static function update_all_payment_methods_from_subscription( $subscription, $new_payment_method ) {
@@ -432,7 +444,7 @@ class WC_Subscriptions_Change_Payment_Gateway {
* @param WC_Payment_Gateway $gateway The payment gateway to check.
* @param WC_Subscription $subscription An instance of a WC_Subscription object.
* @return bool Gateway supports updating all current subscriptions.
- * @since 2.5.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.0
*/
public static function can_update_all_subscription_payment_methods( $gateway, $subscription ) {
@@ -456,7 +468,7 @@ class WC_Subscriptions_Change_Payment_Gateway {
*
* @param WC_Subscription $subscription An instance of a WC_Subscription object.
* @return bool Subscription will update all current subscriptions.
- * @since 2.5.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.0
*/
public static function will_subscription_update_all_payment_methods( $subscription ) {
if ( ! wcs_is_subscription( $subscription ) ) {
@@ -472,7 +484,7 @@ class WC_Subscriptions_Change_Payment_Gateway {
* @param WC_Subscription $subscription An instance of a WC_Subscription object.
* @param string $new_payment_method The ID of the new payment method.
* @param array $new_payment_method_meta The meta for the new payment method. Optional. Default false.
- * @since 1.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4
*/
public static function update_payment_method( $subscription, $new_payment_method, $new_payment_method_meta = false ) {
@@ -550,7 +562,7 @@ class WC_Subscriptions_Change_Payment_Gateway {
* when requesting to change the payment method.
*
* @param array $available_gateways The payment gateways which are currently being allowed.
- * @since 1.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4
*/
public static function get_available_payment_gateways( $available_gateways ) {
$is_change_payment_method_request = isset( $_GET['change_payment_method'] );
@@ -589,7 +601,7 @@ class WC_Subscriptions_Change_Payment_Gateway {
/**
* Make sure certain totals are set to 0 when the request is to change the payment method without charging anything.
*
- * @since 1.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4
*/
public static function maybe_zero_total( $total, $subscription ) {
global $wp;
@@ -607,7 +619,7 @@ class WC_Subscriptions_Change_Payment_Gateway {
/**
* Redirect back to the "My Account" page instead of the "Thank You" page after changing the payment method.
*
- * @since 1.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4
*/
public static function get_return_url( $return_url ) {
@@ -626,7 +638,7 @@ class WC_Subscriptions_Change_Payment_Gateway {
*
* @param WC_Order $renewal_order The order which recorded the successful payment (to make up for the failed automatic payment).
* @param WC_Order $original_order The original order in which the subscription was purchased.
- * @since 1.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4
*/
public static function change_failing_payment_method( $renewal_order, $subscription ) {
@@ -655,7 +667,7 @@ class WC_Subscriptions_Change_Payment_Gateway {
* @param bool $subscription_can_be_changed Flag of whether the subscription can be changed.
* @param WC_Subscription $subscription The subscription to check.
* @return bool Flag indicating whether the subscription payment method can be updated.
- * @since 1.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4
*/
public static function can_subscription_be_updated_to_new_payment_method( $subscription_can_be_changed, $subscription ) {
@@ -693,7 +705,7 @@ class WC_Subscriptions_Change_Payment_Gateway {
*
* @param string $title
* @return string
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function change_payment_method_page_title( $title ) {
@@ -717,7 +729,7 @@ class WC_Subscriptions_Change_Payment_Gateway {
*
* @param array $crumbs
* @return array
- * @since 2.4.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.4.2
*/
public static function change_payment_method_breadcrumb( $crumbs ) {
@@ -752,7 +764,7 @@ class WC_Subscriptions_Change_Payment_Gateway {
/**
* Get the Change Payment Method page title (also used for the page breadcrumb)
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
* @param WC_Subscription $subscription
* @return string
*/
@@ -774,7 +786,7 @@ class WC_Subscriptions_Change_Payment_Gateway {
* @param bool $needs_payment
* @param WC_Subscription $subscription
* @return bool
- * @since 2.0.7
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.7
*/
public static function maybe_override_needs_payment( $needs_payment ) {
@@ -790,7 +802,7 @@ class WC_Subscriptions_Change_Payment_Gateway {
*
* @param string $content The default HTML page content.
* @return string $content.
- * @since 2.5.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.0
*/
public static function maybe_request_log_in( $content ) {
global $wp;
@@ -822,8 +834,8 @@ class WC_Subscriptions_Change_Payment_Gateway {
* Update the recurring payment method on a subscription order.
*
* @param array $available_gateways The payment gateways which are currently being allowed.
- * @since 1.4
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function update_recurring_payment_method( $subscription_key, $order, $new_payment_method ) {
_deprecated_function( __METHOD__, '2.0', __CLASS__ . '::update_payment_method()' );
@@ -835,8 +847,8 @@ class WC_Subscriptions_Change_Payment_Gateway {
*
* Deprecated as we now operate on a WC_Subscription object instead of the parent order, so we don't need to hack around date changes.
*
- * @since 1.4
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function store_original_order_dates( $new_order_status, $subscription_id ) {
_deprecated_function( __METHOD__, '2.0' );
@@ -847,8 +859,8 @@ class WC_Subscriptions_Change_Payment_Gateway {
*
* Deprecated as we now operate on a WC_Subscription object instead of the parent order, so we don't need to hack around date changes.
*
- * @since 1.4
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function restore_original_order_dates( $order_id ) {
_deprecated_function( __METHOD__, '2.0' );
@@ -870,7 +882,7 @@ class WC_Subscriptions_Change_Payment_Gateway {
* 'order' WC_Order The order which recorded the successful payment (to make up for the failed automatic payment).
* 'payment_gateway' WC_Payment_Gateway The subscription's recurring payment gateway
* 'order_uses_manual_payments' bool A boolean flag indicating whether the subscription requires manual renewal payment.
- * @since 1.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4
*/
public static function can_subscription_be_changed_to( $subscription_can_be_changed, $new_status_or_meta, $args ) {
_deprecated_function( __METHOD__, '2.0', __CLASS__ . '::can_subscription_be_updated_to_new_payment_method()' );
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-checkout.php b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-checkout.php
index 5cd9784..31d74df 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-checkout.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-checkout.php
@@ -16,7 +16,7 @@ class WC_Subscriptions_Checkout {
/**
* Bootstraps the class and hooks required actions & filters.
*
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function init() {
@@ -49,10 +49,13 @@ class WC_Subscriptions_Checkout {
// Override the WC default "Add to cart" text to "Sign up now" (in various places/templates)
add_filter( 'woocommerce_order_button_text', array( __CLASS__, 'order_button_text' ) );
+
+ // Check the "Ship to different address" checkbox if the shipping address of the originating order is different to the billing address.
+ add_filter( 'woocommerce_ship_to_different_address_checked', array( __CLASS__, 'maybe_check_ship_to_different_address' ), 10, 1 );
}
/**
- * @since 2.2.17
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.17
*/
public static function attach_dependant_hooks() {
// Make sure guest checkout is not enabled in option param passed to WC JS
@@ -69,7 +72,7 @@ class WC_Subscriptions_Checkout {
*
* @param int $order_id The post_id of a shop_order post/WC_Order object
* @param array $posted_data The data posted on checkout
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function process_checkout( $order_id, $posted_data = array() ) {
@@ -85,11 +88,13 @@ class WC_Subscriptions_Checkout {
$subscriptions = wcs_get_subscriptions_for_order( wcs_get_objects_property( $order, 'id' ), array( 'order_type' => 'parent' ) );
if ( ! empty( $subscriptions ) ) {
- remove_action( 'before_delete_post', 'WC_Subscriptions_Manager::maybe_cancel_subscription' );
+ $action_hook = wcs_is_custom_order_tables_usage_enabled() ? 'woocommerce_before_delete_subscription' : 'before_delete_post';
+
+ remove_action( $action_hook, 'WC_Subscriptions_Manager::maybe_cancel_subscription' );
foreach ( $subscriptions as $subscription ) {
- wp_delete_post( $subscription->get_id() );
+ $subscription->delete( true );
}
- add_action( 'before_delete_post', 'WC_Subscriptions_Manager::maybe_cancel_subscription' );
+ add_action( $action_hook, 'WC_Subscriptions_Manager::maybe_cancel_subscription' );
}
WC_Subscriptions_Cart::set_global_recurring_shipping_packages();
@@ -117,7 +122,7 @@ class WC_Subscriptions_Checkout {
*
* @param WC_Order $order
* @param WC_Cart $cart
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function create_subscription( $order, $cart, $posted_data ) {
@@ -257,7 +262,13 @@ class WC_Subscriptions_Checkout {
return new WP_Error( 'checkout-error', $e->getMessage() );
}
- return $subscription;
+ /**
+ * Fetch and return a fresh instance of the subscription from the database.
+ *
+ * After saving the subscription, we need to fetch the subscription from the database as the current object state may not match the loaded state.
+ * This occurs because different instances of the subscription might have been saved in any one of the processes above resulting in this object being out of sync.
+ */
+ return wcs_get_subscription( $subscription );
}
@@ -276,7 +287,7 @@ class WC_Subscriptions_Checkout {
if ( $cart->needs_shipping() ) {
foreach ( $cart->get_shipping_packages() as $recurring_cart_package_key => $recurring_cart_package ) {
$package_index = isset( $recurring_cart_package['package_index'] ) ? $recurring_cart_package['package_index'] : 0;
- $package = WC_Subscriptions_Cart::get_calculated_shipping_for_package( $recurring_cart_package );
+ $package = WC()->shipping->calculate_shipping_for_package( $recurring_cart_package );
$shipping_method_id = isset( WC()->checkout()->shipping_methods[ $package_index ] ) ? WC()->checkout()->shipping_methods[ $package_index ] : '';
if ( isset( WC()->checkout()->shipping_methods[ $recurring_cart_package_key ] ) ) {
@@ -289,7 +300,7 @@ class WC_Subscriptions_Checkout {
if ( isset( $package['rates'][ $shipping_method_id ] ) ) {
$shipping_rate = $package['rates'][ $shipping_method_id ];
$item = new WC_Order_Item_Shipping();
- $item->legacy_package_key = $package_key; // @deprecated For legacy actions.
+ $item->legacy_package_key = $package_key; // @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions, For legacy actions.
$item->set_props(
array(
'method_title' => $shipping_rate->label,
@@ -333,7 +344,7 @@ class WC_Subscriptions_Checkout {
* @param string $cart_item_key The hash used to identify the item in the cart
* @param array $cart_item The cart item's data.
* @param WC_Order|WC_Subscription $subscription The order or subscription object to which the line item relates
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
public static function remove_backorder_meta_from_subscription_line_item( $item, $cart_item_key, $cart_item, $subscription ) {
@@ -349,7 +360,7 @@ class WC_Subscriptions_Checkout {
* @param string $cart_item_key The item's cart item key.
* @param array $cart_item The cart item.
* @param WC_Subscription $subscription The subscription the item is being added to.
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
public static function maybe_add_free_trial_item_meta( $item, $cart_item_key, $cart_item, $subscription ) {
if ( wcs_is_subscription( $subscription ) && WC_Subscriptions_Product::get_trial_length( $item->get_product() ) > 0 ) {
@@ -360,7 +371,7 @@ class WC_Subscriptions_Checkout {
/**
* Add a cart item to a subscription.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function add_cart_item( $subscription, $cart_item, $cart_item_key ) {
_deprecated_function( __METHOD__, '2.2.0', 'WC_Checkout::create_order_line_items( $subscription, $cart )' );
@@ -401,7 +412,7 @@ class WC_Subscriptions_Checkout {
/**
* When a new order is inserted, add subscriptions related order meta.
*
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function add_order_meta( $order_id, $posted ) {
_deprecated_function( __METHOD__, '2.0' );
@@ -410,7 +421,7 @@ class WC_Subscriptions_Checkout {
/**
* Add each subscription product's details to an order so that the state of the subscription persists even when a product is changed
*
- * @since 1.2.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2.5
*/
public static function add_order_item_meta( $item_id, $values ) {
_deprecated_function( __METHOD__, '2.0' );
@@ -423,7 +434,7 @@ class WC_Subscriptions_Checkout {
* @param string $handle Default empty string ('').
* @param array $woocommerce_params
*
- * @since 2.5.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.3
* @return array
*/
public static function filter_woocommerce_script_parameters( $woocommerce_params, $handle = '' ) {
@@ -442,7 +453,7 @@ class WC_Subscriptions_Checkout {
/**
* Stores the subtracted base location tax totals in the subscription line item meta.
*
- * @since 3.0.10
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.0.10
*
* @param WC_Line_Item_Product $line_item The line item added to the order/subscription.
* @param string $cart_item_key The key of the cart item being added to the cart.
@@ -459,8 +470,8 @@ class WC_Subscriptions_Checkout {
* Also make sure the guest checkout option value passed to the woocommerce.js forces registration.
* Otherwise the registration form is hidden by woocommerce.js.
*
- * @since 1.1
- * @deprecated 2.5.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.1
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.3
*/
public static function filter_woocommerce_script_paramaters( $woocommerce_params, $handle = '' ) {
wcs_deprecated_function( __METHOD__, '2.5.3', 'WC_Subscriptions_Admin::filter_woocommerce_script_parameters( $woocommerce_params, $handle )' );
@@ -471,7 +482,7 @@ class WC_Subscriptions_Checkout {
/**
* Enables the 'registeration required' (guest checkout) setting when purchasing subscriptions.
*
- * @since 3.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
*
* @param bool $account_required Whether an account is required to checkout.
* @return bool
@@ -487,7 +498,7 @@ class WC_Subscriptions_Checkout {
/**
* During the checkout process, force registration when the cart contains a subscription.
*
- * @since 1.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.1
* @param $woocommerce_params This parameter is not used.
*/
public static function force_registration_during_checkout( $woocommerce_params ) {
@@ -504,7 +515,7 @@ class WC_Subscriptions_Checkout {
*
* The message will redirect the customer to the My Account page if registration is enabled there, otherwise a generic 'you need an account' message will be displayed.
*
- * @since 3.0.11
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.0.11
* @return string The error message.
*/
private static function get_registration_error_message() {
@@ -523,7 +534,7 @@ class WC_Subscriptions_Checkout {
/**
* Enables registration for carts containing subscriptions if admin allow it.
*
- * @since 3.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
*
* @param bool $registration_enabled Whether registration is enabled on checkout by default.
* @return bool
@@ -549,8 +560,8 @@ class WC_Subscriptions_Checkout {
* When creating an order at checkout, if the checkout is to renew a subscription from a failed
* payment, hijack the order creation to make a renewal order - not a plain WooCommerce order.
*
- * @since 1.3
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.3
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function filter_woocommerce_create_order( $order_id, $checkout_object ) {
_deprecated_function( __METHOD__, '2.0' );
@@ -560,7 +571,7 @@ class WC_Subscriptions_Checkout {
/**
* Customise which actions are shown against a subscriptions order on the My Account page.
*
- * @since 1.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.3
*/
public static function filter_woocommerce_my_account_my_orders_actions( $actions, $order ) {
_deprecated_function( __METHOD__, '2.0', 'WCS_Cart_Renewal::filter_my_account_my_orders_actions()' );
@@ -570,8 +581,8 @@ class WC_Subscriptions_Checkout {
/**
* If shopping cart contains subscriptions, make sure a user can register on the checkout page
*
- * @since 1.0
- * @deprecated 3.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
*/
public static function make_checkout_registration_possible( $checkout = '' ) {
wcs_deprecated_function( __METHOD__, '3.1.0' );
@@ -590,8 +601,8 @@ class WC_Subscriptions_Checkout {
/**
* Make sure account fields display the required "*" when they are required.
*
- * @since 1.3.5
- * @deprecated 3.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.3.5
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
*/
public static function make_checkout_account_fields_required( $checkout_fields ) {
wcs_deprecated_function( __METHOD__, '3.1.0' );
@@ -616,8 +627,8 @@ class WC_Subscriptions_Checkout {
/**
* After displaying the checkout form, restore the store's original registration settings.
*
- * @since 1.1
- * @deprecated 3.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.1
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
*/
public static function restore_checkout_registration_settings( $checkout = '' ) {
wcs_deprecated_function( __METHOD__, '3.1.0' );
@@ -632,7 +643,7 @@ class WC_Subscriptions_Checkout {
/**
* Overrides the "Place order" button text with "Sign up now" when the cart contains initial subscription purchases.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*
* @param string $button_text The place order button text.
* @return string $button_text
@@ -649,4 +660,45 @@ class WC_Subscriptions_Checkout {
return apply_filters( 'wcs_place_subscription_order_text', __( 'Sign up now', 'woocommerce-subscriptions' ) );
}
+
+ /**
+ * If the cart contains a renewal order, resubscribe order or a subscription switch
+ * that needs to ship to an address that is different to the order's billing address,
+ * tell the checkout to check the "Ship to different address" checkbox.
+ *
+ * @since 5.3.0
+ *
+ * @param bool $ship_to_different_address Whether the order will check the "Ship to different address" checkbox
+ * @return bool $ship_to_different_address
+ */
+ public static function maybe_check_ship_to_different_address( $ship_to_different_address ) {
+ $switch_items = wcs_cart_contains_switches();
+ $renewal_item = wcs_cart_contains_renewal();
+ $resubscribe_item = wcs_cart_contains_resubscribe();
+
+ if ( ! $switch_items && ! $renewal_item && ! $resubscribe_item ) {
+ return $ship_to_different_address;
+ }
+
+ if ( ! $ship_to_different_address ) {
+ // Get the subscription ID from the corresponding cart item
+ if ( $switch_items ) {
+ $subscription_id = array_values( $switch_items )[0]['subscription_id'];
+ } elseif ( $renewal_item ) {
+ $subscription_id = $renewal_item['subscription_renewal']['subscription_id'];
+ } elseif ( $resubscribe_item ) {
+ $subscription_id = $resubscribe_item['subscription_resubscribe']['subscription_id'];
+ }
+
+ $order = wc_get_order( $subscription_id );
+
+ // If the order's addresses are different, we need to display the shipping fields otherwise the billing address will override it
+ $addresses_are_equal = wcs_compare_order_billing_shipping_address( $order );
+ if ( ! $addresses_are_equal ) {
+ $ship_to_different_address = 1;
+ }
+ }
+
+ return $ship_to_different_address;
+ }
}
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-core-plugin.php b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-core-plugin.php
index 9c27d10..3c9cf00 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-core-plugin.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-core-plugin.php
@@ -3,7 +3,7 @@
* WooCommerce Subscriptions setup
*
* @package WooCommerce Subscriptions
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*/
defined( 'ABSPATH' ) || exit;
@@ -13,11 +13,10 @@ require_once dirname( __FILE__ ) . '/class-wcs-core-autoloader.php';
class WC_Subscriptions_Core_Plugin {
/**
- * The plugin version core is based off.
- *
+ * The version of subscriptions-core library.
* @var string
*/
- protected $plugin_version = '3.1.6';
+ protected $library_version = '5.8.0'; // WRCS: DEFINED_VERSION.
/**
* The subscription scheduler instance.
@@ -58,6 +57,9 @@ class WC_Subscriptions_Core_Plugin {
$this->autoloader->register();
}
+ // Load the Order Tables/Data Store Controller class early.
+ new WCS_Orders_Table_Data_Store_Controller();
+
$this->define_constants();
$this->includes();
$this->init();
@@ -70,7 +72,7 @@ class WC_Subscriptions_Core_Plugin {
/**
* Gets the Subscriptions Core instance.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
* @return WC_Subscriptions_Core_Plugin
*/
public static function instance() {
@@ -206,7 +208,7 @@ class WC_Subscriptions_Core_Plugin {
/**
* Attaches the hooks to init/setup the plugin.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*/
public function init_hooks() {
register_deactivation_hook( $this->get_plugin_file(), array( $this, 'deactivate_plugin' ) );
@@ -234,7 +236,7 @@ class WC_Subscriptions_Core_Plugin {
/**
* Gets the subscriptions core directory.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
* @param string $path Optional. The path to append.
* @return string
*/
@@ -245,7 +247,7 @@ class WC_Subscriptions_Core_Plugin {
/**
* Gets the subscriptions core directory url.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
* @param string $path Optional. The path to append.
* @return string
*/
@@ -256,10 +258,20 @@ class WC_Subscriptions_Core_Plugin {
/**
* Gets the plugin's version
*
- * @since 4.0.0
+ * @deprecated 5.0.0 This function is no longer recommended for version detection. Use get_library_version() instead.
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*/
public function get_plugin_version() {
- return $this->plugin_version;
+ return $this->library_version;
+ }
+
+ /**
+ * Gets the subscription-core library version.
+ *
+ * @since 5.0.0
+ */
+ public function get_library_version() {
+ return $this->library_version;
}
/**
@@ -301,7 +313,7 @@ class WC_Subscriptions_Core_Plugin {
/**
* Gets the core Payment Gateways handler class
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
* @return string
*/
public function get_gateways_handler_class() {
@@ -311,7 +323,7 @@ class WC_Subscriptions_Core_Plugin {
/**
* Registers Subscriptions order types.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*/
public function register_order_types() {
$subscriptions_exist = $this->cache->cache_and_get( 'wcs_do_subscriptions_exist', 'wcs_do_subscriptions_exist' );
@@ -382,7 +394,7 @@ class WC_Subscriptions_Core_Plugin {
/**
* Registers data stores.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
* @return string[]
*/
public function add_data_stores( $data_stores ) {
@@ -400,7 +412,7 @@ class WC_Subscriptions_Core_Plugin {
/**
* Registers our custom post statuses, used for subscription statuses.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*/
public function register_post_statuses() {
$subscription_statuses = wcs_get_subscription_statuses();
@@ -438,7 +450,7 @@ class WC_Subscriptions_Core_Plugin {
/**
* Runs the required processes when the plugin is deactivated.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*/
public function deactivate_plugin() {
delete_option( WC_Subscriptions_Admin::$option_prefix . '_is_active' );
@@ -449,7 +461,7 @@ class WC_Subscriptions_Core_Plugin {
/**
* Runs the required process on plugin activation.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*/
public function activate_plugin() {
$is_active = get_option( WC_Subscriptions_Admin::$option_prefix . '_is_active', false );
@@ -492,7 +504,7 @@ class WC_Subscriptions_Core_Plugin {
/**
* Registers plugin translation files.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*/
public function load_plugin_textdomain() {
$plugin_rel_path = apply_filters( 'woocommerce_subscriptions_translation_file_rel_path', $this->get_subscriptions_core_directory() . '/languages' );
@@ -504,7 +516,7 @@ class WC_Subscriptions_Core_Plugin {
/**
* Adds the settings, docs and support links to the plugin screen.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*
* @param string[] $links The plugin's links displayed on the plugin screen.
* @return string[]
@@ -522,7 +534,7 @@ class WC_Subscriptions_Core_Plugin {
/**
* Displays an upgrade notice for stores upgrading to 2.0.0.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*
* @param array $plugin_data Information about the plugin.
* @param array $r response from the server about the new version.
@@ -545,7 +557,7 @@ class WC_Subscriptions_Core_Plugin {
/**
* Sets up the Blocks integration class.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*/
public function setup_blocks_integration() {
/**
@@ -572,7 +584,7 @@ class WC_Subscriptions_Core_Plugin {
* Renewals use a lot more memory on WordPress multisite (10-15mb instead of 0.1-1mb) so
* we need to reduce the number of renewals run in each request.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*
* @param int $batch_size The default Action Scheduler batch size.
* @return int
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-coupon.php b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-coupon.php
index 58c1e2f..bc51f6a 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-coupon.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-coupon.php
@@ -8,7 +8,7 @@
* @subpackage WC_Subscriptions_Coupon
* @category Class
* @author Max Rice
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
class WC_Subscriptions_Coupon {
@@ -25,7 +25,7 @@ class WC_Subscriptions_Coupon {
/**
* Stores the coupons not applied to a given calculation (so they can be applied later)
*
- * @since 1.3.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.3.5
* @deprecated
*/
private static $removed_coupons = array();
@@ -64,7 +64,7 @@ class WC_Subscriptions_Coupon {
/**
* Set up the class, including it's hooks & filters, when the file is loaded.
*
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
**/
public static function init() {
@@ -103,7 +103,7 @@ class WC_Subscriptions_Coupon {
* @param string $coupon_html Html string of the recurring coupon's cell in the Cart totals table
* @param WC_coupon $coupon WC_Coupon object of the recurring coupon
* @return string $coupon_html Modified html string of the coupon containing the marking
- * @since 2.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.3
*/
public static function mark_recurring_coupon_in_initial_cart_for_hiding( $coupon_html, $coupon ) {
$displaying_initial_cart_totals = false;
@@ -124,7 +124,7 @@ class WC_Subscriptions_Coupon {
/**
* Add discount types
*
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function add_discount_types( $discount_types ) {
@@ -142,7 +142,7 @@ class WC_Subscriptions_Coupon {
/**
* Get the discount amount for Subscriptions coupon types
*
- * @since 2.0.10
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.10
*/
public static function get_discount_amount( $discount, $discounting_amount, $item, $single, $coupon ) {
@@ -158,7 +158,7 @@ class WC_Subscriptions_Coupon {
/**
* Get the discount amount which applies for a cart item for subscription coupon types
*
- * @since 2.2.13
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.13
* @param array $cart_item
* @param float $discount the original discount amount
* @param float $discounting_amount the cart item price/total which the coupon should apply to
@@ -317,7 +317,7 @@ class WC_Subscriptions_Coupon {
*
* Uses methods and data structures introduced in WC 3.0.
*
- * @since 2.2.13
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.13
* @param WC_Order_Item $line_item
* @param float $discount the original discount amount
* @param float $discounting_amount the line item price/total
@@ -368,7 +368,7 @@ class WC_Subscriptions_Coupon {
* - 'recurring_fee' for the recurring amount subscription coupon
* - 'sign_up_fee' for the sign-up fee subscription coupon
*
- * @since 1.3.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.3.5
*/
public static function cart_contains_discount( $coupon_type = 'any' ) {
@@ -399,7 +399,7 @@ class WC_Subscriptions_Coupon {
* @param WC_Coupon $coupon
* @param WC_Discounts $discount Added in WC 3.2 the WC_Discounts object contains information about the coupon being applied to either carts or orders - Optional
* @return boolean Whether the coupon is valid or not
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function validate_subscription_coupon( $valid, $coupon, $discount = null ) {
@@ -429,7 +429,7 @@ class WC_Subscriptions_Coupon {
/**
* Check if a subscription coupon is valid for the cart.
*
- * @since 2.2.13
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.13
* @param boolean $valid
* @param WC_Coupon $coupon
* @return bool whether the coupon is valid
@@ -480,7 +480,7 @@ class WC_Subscriptions_Coupon {
/**
* Check if a subscription coupon is valid for an order/subscription.
*
- * @since 2.2.13
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.13
* @param WC_Coupon $coupon The subscription coupon being validated. Can accept recurring_fee, recurring_percent, sign_up_fee or sign_up_fee_percent coupon types.
* @param WC_Order|WC_Subscription $order The order or subscription object to which the coupon is being applied
* @return bool whether the coupon is valid
@@ -511,7 +511,7 @@ class WC_Subscriptions_Coupon {
/**
* Returns a subscription coupon-specific error if validation failed
*
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function add_coupon_error( $error ) {
@@ -529,7 +529,7 @@ class WC_Subscriptions_Coupon {
* This function is hooked to "woocommerce_before_calculate_totals" so that WC will calculate a subscription
* product's total based on the total of it's price per period and sign up fee (if any).
*
- * @since 1.3.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.3.5
*
* @param WC_Cart $cart
*/
@@ -601,7 +601,7 @@ class WC_Subscriptions_Coupon {
*
* @param string $code coupon code
* @return array subtotal
- * @since 2.0.10
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.10
*/
private static function get_renewal_subtotal( $code ) {
@@ -636,7 +636,7 @@ class WC_Subscriptions_Coupon {
* @param int|WC_Product $product_id
* @param array $cart_item
* @return boolean whether a product is a renewal order line item
- * @since 2.0.10
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.10
*/
private static function is_subscription_renewal_line_item( $product_id, $cart_item ) {
@@ -665,7 +665,7 @@ class WC_Subscriptions_Coupon {
*
* @param array $coupon_types
* @return array supported coupon types
- * @since 2.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2
*/
public static function add_pseudo_coupon_types( $coupon_types ) {
return array_merge(
@@ -685,7 +685,7 @@ class WC_Subscriptions_Coupon {
* @param string $label
* @param WC_Coupon $coupon
* @return string
- * @since 2.2.8
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.8
*/
public static function get_pseudo_coupon_label( $label, $coupon ) {
// If the coupon is one of our pseudo coupons, rather than displaying "Coupon: discount_renewal" display a nicer label.
@@ -724,7 +724,7 @@ class WC_Subscriptions_Coupon {
/**
* Checks if a coupon is one of our virtual coupons applied to renewal carts.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*
* @param string $coupon_type The coupon's type.
* @return bool Whether the coupon is a recuring cart virtual coupon.
@@ -736,7 +736,7 @@ class WC_Subscriptions_Coupon {
/**
* Checks if a coupon is one of our recurring coupons.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*
* @param string $coupon_type The coupon's type.
* @return bool Whether the coupon is a recuring cart virtual coupon.
@@ -750,7 +750,7 @@ class WC_Subscriptions_Coupon {
/**
* Apply sign up fee or recurring fee discount
*
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function apply_subscription_discount( $original_price, $cart_item, $cart ) {
_deprecated_function( __METHOD__, '2.0.10', 'Have moved to filtering on "woocommerce_coupon_get_discount_amount" to return discount amount. See: ' . __CLASS__ . '::get_discount_amount()' );
@@ -870,7 +870,7 @@ class WC_Subscriptions_Coupon {
/**
* Validates a subscription coupon's use for a given product.
*
- * @since 2.5.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.4
*
* @param bool $is_valid Whether the coupon is valid for the product.
* @param WC_Product $product The product object.
@@ -905,7 +905,7 @@ class WC_Subscriptions_Coupon {
/**
* Store how much discount each coupon grants.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
* @param WC_Cart $cart The WooCommerce cart object.
* @param mixed $code
* @param mixed $amount
@@ -926,7 +926,7 @@ class WC_Subscriptions_Coupon {
/**
* Restores discount coupons which had been removed for special subscription calculations.
*
- * @since 1.3.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.3.5
*/
public static function restore_coupons( $cart ) {
_deprecated_function( __METHOD__, '2.0' );
@@ -954,7 +954,7 @@ class WC_Subscriptions_Coupon {
* This function overrides that by ensuring the limit is accounted for across all recurring carts.
* The items which the coupon applied to in initial cart are the items in recurring carts that the coupon will apply to.
*
- * @since 3.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.0.0
*
* @param int $apply_quantity The item quantity to apply the coupon to.
* @param object $item The stdClass cart item object. @see WC_Discounts::set_items_from_cart() for an example of object properties.
@@ -1021,7 +1021,7 @@ class WC_Subscriptions_Coupon {
/**
* Apply sign up fee or recurring fee discount before tax is calculated
*
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function apply_subscription_discount_before_tax( $original_price, $cart_item, $cart ) {
_deprecated_function( __METHOD__, '2.0', __CLASS__ . '::apply_subscription_discount( $original_price, $cart_item, $cart )' );
@@ -1031,8 +1031,8 @@ class WC_Subscriptions_Coupon {
/**
* Apply sign up fee or recurring fee discount after tax is calculated
*
- * @since 1.2
- * @version 1.3.6
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v1.3.6
*/
public static function apply_subscription_discount_after_tax( $coupon, $cart_item, $price ) {
_deprecated_function( __METHOD__, '2.0', 'WooCommerce 2.3 removed after tax discounts. Use ' . __CLASS__ . '::apply_subscription_discount( $original_price, $cart_item, $cart )' );
@@ -1045,7 +1045,7 @@ class WC_Subscriptions_Coupon {
* this functionality in older versions of WC, so we require 3.2+ to enable this.
*
* @author Jeremy Pry
- * @deprecated 4.0.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*/
public static function maybe_add_recurring_coupon_hooks() {
_deprecated_function( __METHOD__, '4.0.0' );
@@ -1058,7 +1058,7 @@ class WC_Subscriptions_Coupon {
* @author Jeremy Pry
*
* @param int $id The coupon ID.
- * @deprecated 4.0.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*/
public static function add_coupon_fields( $id ) {
_deprecated_function( __METHOD__, '4.0.0', 'WCS_Limited_Recurring_Coupon_Manager::add_coupon_fields( $id ) if available' );
@@ -1074,7 +1074,7 @@ class WC_Subscriptions_Coupon {
* @author Jeremy Pry
*
* @param int $post_id
- * @deprecated 4.0.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*/
public static function save_coupon_fields( $post_id ) {
_deprecated_function( __METHOD__, '4.0.0', 'WCS_Limited_Recurring_Coupon_Manager::save_coupon_fields( $post_id ) if available' );
@@ -1089,7 +1089,7 @@ class WC_Subscriptions_Coupon {
* @author Jeremy Pry
*
* @param WC_Subscription $subscription The current subscription.
- * @deprecated 4.0.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*/
public static function check_coupon_usages( $subscription ) {
_deprecated_function( __METHOD__, '4.0.0', 'WCS_Limited_Recurring_Coupon_Manager::check_coupon_usages( $subscription ) if available' );
@@ -1105,7 +1105,7 @@ class WC_Subscriptions_Coupon {
*
* @param string $column_name The name of the current column in the table.
* @param int $post_id The coupon post ID.
- * @deprecated 4.0.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*/
public static function add_limit_to_list_table( $column_name, $post_id ) {
wcs_deprecated_function( __METHOD__, '4.0.0', 'WCS_Limited_Recurring_Coupon_Manager::add_limit_to_list_table( $column_name, $post_id ) if available' );
@@ -1122,7 +1122,7 @@ class WC_Subscriptions_Coupon {
* @param WC_Payment_Gateway[] $gateways The available payment gateways.
*
* @return array The filtered payment gateways.
- * @deprecated 4.0.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*/
public static function gateways_subscription_amount_changes( $gateways ) {
wcs_deprecated_function( __METHOD__, '4.0.0', 'WCS_Limited_Recurring_Coupon_Manager::gateways_subscription_amount_changes( $gateways ) if available' );
@@ -1141,7 +1141,7 @@ class WC_Subscriptions_Coupon {
* @param string $message The current message indicating there are no payment methods available..
*
* @return string The filtered message indicating there are no payment methods available.
- * @deprecated 4.0.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*/
public static function no_available_payment_methods_message( $message ) {
wcs_deprecated_function( __METHOD__, '4.0.0', 'WCS_Limited_Recurring_Coupon_Manager::no_available_payment_methods_message() if available' );
@@ -1156,7 +1156,7 @@ class WC_Subscriptions_Coupon {
* @param string $code The coupon code.
*
* @return bool
- * @deprecated 4.0.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*/
public static function coupon_is_limited( $code ) {
wcs_deprecated_function( __METHOD__, '4.0.0', 'WCS_Limited_Recurring_Coupon_Manager::coupon_is_limited() if available' );
@@ -1172,7 +1172,7 @@ class WC_Subscriptions_Coupon {
*
* @author Jeremy Pry
* @return bool
- * @deprecated 4.0.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*/
public static function cart_contains_limited_recurring_coupon() {
wcs_deprecated_function( __METHOD__, '4.0.0', 'WCS_Limited_Recurring_Coupon_Manager::cart_contains_limited_recurring_coupon() if available' );
@@ -1191,7 +1191,7 @@ class WC_Subscriptions_Coupon {
* @param WC_Order|WC_Subscription $order
*
* @return bool
- * @deprecated 4.0.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*/
public static function order_has_limited_recurring_coupon( $order ) {
wcs_deprecated_function( __METHOD__, '4.0.0', 'WCS_Limited_Recurring_Coupon_Manager::order_has_limited_recurring_coupon( $order ) if available' );
@@ -1211,7 +1211,7 @@ class WC_Subscriptions_Coupon {
*
* @return false|int False for non-recurring coupons, or the limit number for recurring coupons.
* A value of 0 is for unlimited usage.
- * @deprecated 4.0.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*/
public static function get_coupon_limit( $code ) {
wcs_deprecated_function( __METHOD__, '4.0.0', 'WCS_Limited_Recurring_Coupon_Manager::get_coupon_limit( $code ) if available' );
@@ -1227,7 +1227,7 @@ class WC_Subscriptions_Coupon {
*
* @param WC_Cart $recurring_cart The recurring cart object.
* @return bool
- * @deprecated 4.0.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*/
public static function recurring_cart_contains_expiring_coupon( $recurring_cart ) {
wcs_deprecated_function( __METHOD__, '4.0.0', 'WCS_Limited_Recurring_Coupon_Manager::recurring_cart_contains_expiring_coupon( $recurring_cart ) if available' );
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-data-copier.php b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-data-copier.php
new file mode 100644
index 0000000..b6930f5
--- /dev/null
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-data-copier.php
@@ -0,0 +1,546 @@
+copy_data();
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param WC_Order $from_object The object to copy data from.
+ * @param WC_Order $to_object The object to copy data to.
+ * @param string $copy_type Optional. The type of copy. Can be 'subscription', 'parent', 'renewal_order' or 'resubscribe_order'. Default is 'subscription'.
+ */
+ public function __construct( $from_object, $to_object, $copy_type = self::DEFAULT_COPY_TYPE ) {
+ $this->from_object = $from_object;
+ $this->to_object = $to_object;
+ $this->copy_type = $copy_type;
+ }
+
+ /**
+ * Copies the data from the "from" object to the "to" object.
+ */
+ public function copy_data() {
+
+ if ( ! wcs_is_custom_order_tables_usage_enabled() ) {
+ $data_array = $GLOBALS['wpdb']->get_results( $this->get_deprecated_meta_query(), ARRAY_A );
+ $data = wp_list_pluck( $data_array, 'meta_value', 'meta_key' );
+ } else {
+ $data = $this->get_meta_data();
+ $data += $this->get_order_data();
+ $data += $this->get_operational_data();
+ $data += $this->get_address_data();
+
+ // Payment token meta isn't accounted from in the above methods, so we need to add it separately.
+ if ( ! isset( $data['_payment_tokens'] ) ) {
+ $tokens = $this->from_object->get_payment_tokens();
+
+ if ( ! empty( $tokens ) ) {
+ $data['_payment_tokens'] = $tokens;
+ }
+ }
+
+ // Remove any excluded meta keys.
+ $data = $this->filter_excluded_meta_keys_via_query( $data );
+ }
+
+ $data = $this->apply_deprecated_filter( $data );
+
+ /**
+ * Filters the data to be copied from one object to another.
+ *
+ * This filter name contains a dynamic part, $this->copy_type. The full set of hooks include:
+ * - wc_subscriptions_subscription_data
+ * - wc_subscriptions_parent_data
+ * - wc_subscriptions_renewal_order_data
+ * - wc_subscriptions_resubscribe_order_data
+ *
+ * @since subscriptions-core 2.5.0
+ *
+ * @param array $data {
+ * The data to be copied to the "to" object. Each value is keyed by the meta key. Example format [ '_meta_key' => 'meta_value' ].
+ *
+ * @type mixed $meta_value The meta value to be copied.
+ * }
+ * @param WC_Order $from_object The object to copy data from.
+ * @param WC_Order $to_object The object to copy data to.
+ */
+ $data = apply_filters( "wc_subscriptions_{$this->copy_type}_data", $data, $this->to_object, $this->from_object );
+
+ /**
+ * Filters the data to be copied from one object to another.
+ *
+ * @since subscriptions-core 2.5.0
+ *
+ * @param array $data {
+ * The data to be copied to the "to" object. Each value is keyed by the meta key. Example format [ '_meta_key' => 'meta_value' ].
+ *
+ * @type mixed $meta_value The meta value to be copied.
+ * }
+ * @param WC_Order $from_object The object to copy data from.
+ * @param WC_Order $to_object The object to copy data to.
+ */
+ $data = apply_filters( 'wc_subscriptions_object_data', $data, $this->to_object, $this->from_object, $this->copy_type );
+
+ foreach ( $data as $key => $value ) {
+ $this->set_data( $key, maybe_unserialize( $value ) );
+ }
+
+ $this->to_object->save();
+ }
+
+ /**
+ * Sets a piece of data on the "to" object.
+ *
+ * This function uses a setter where appropriate, otherwise it sets the data directly.
+ * Values which are stored as a bool in memory are converted before being set. eg 'no' -> false, 'yes' -> true.
+ *
+ * @param string $key The data key to set.
+ * @param mixed $value The value to set.
+ */
+ private function set_data( $key, $value ) {
+
+ // WC will automatically set/update these keys when a shipping/billing address attribute changes so we can ignore these keys.
+ if ( in_array( $key, [ '_shipping_address_index', '_billing_address_index' ], true ) ) {
+ return;
+ }
+
+ // The WC_Order setter for these keys will expect an array of values, return early if the value is not an array.
+ if (
+ in_array( $key, [ '_shipping_address', '_shipping', '_billing_address', '_billing' ], true )
+ && ! is_array( $value )
+ ) {
+ return;
+ }
+
+ // Special cases where properties with setters don't map nicely to their function names.
+ $setter_map = [
+ '_cart_discount' => 'set_discount_total',
+ '_cart_discount_tax' => 'set_discount_tax',
+ '_customer_user' => 'set_customer_id',
+ '_order_tax' => 'set_cart_tax',
+ '_order_shipping' => 'set_shipping_total',
+ '_order_currency' => 'set_currency',
+ '_order_shipping_tax' => 'set_shipping_tax',
+ '_order_total' => 'set_total',
+ '_order_version' => 'set_version',
+ ];
+
+ $setter = isset( $setter_map[ $key ] ) ? $setter_map[ $key ] : 'set_' . ltrim( $key, '_' );
+
+ if ( is_callable( [ $this->to_object, $setter ] ) ) {
+ // Re-bool the value before setting it. Setters like `set_prices_include_tax()` expect a bool.
+ if ( is_string( $value ) && in_array( $value, [ 'yes', 'no' ], true ) ) {
+ $value = 'yes' === $value;
+ }
+
+ $this->to_object->{$setter}( $value );
+ } elseif ( '_payment_tokens' === $key ) {
+ // Payment tokens don't have a setter and cannot be set via metadata so we need to set them via the datastore.
+ $this->to_object->get_data_store()->update_payment_token_ids( $this->to_object, $value );
+ } else {
+ $this->to_object->update_meta_data( $key, $value );
+ }
+ }
+
+ /**
+ * Determines if there are callbacks attached to the deprecated "wcs_{$this->copy_type}_meta_query" filter.
+ *
+ * @return bool True if there are callbacks attached to the deprecated "wcs_{$this->copy_type}_meta_query" filter. False otherwise.
+ */
+ private function has_filter_on_meta_query_hook() {
+ return has_filter( "wcs_{$this->copy_type}_meta_query" );
+ }
+
+ /**
+ * Gets the "from" object's meta data.
+ *
+ * @return string[] The meta data.
+ */
+ private function get_meta_data() {
+ $meta_data = [];
+
+ foreach ( $this->from_object->get_meta_data() as $meta ) {
+ $meta_data[ $meta->key ] = $meta->value;
+ }
+
+ return $meta_data;
+ }
+
+ /**
+ * Gets the "from" object's operational data that was previously stored in wp post meta.
+ *
+ * @return string[] The operational data with the legacy meta key.
+ */
+ private function get_operational_data() {
+ return [
+ '_created_via' => $this->from_object->get_created_via( 'edit' ),
+ '_order_version' => $this->from_object->get_version( 'edit' ),
+ '_prices_include_tax' => wc_bool_to_string( $this->from_object->get_prices_include_tax( 'edit' ) ),
+ '_recorded_coupon_usage_counts' => wc_bool_to_string( $this->from_object->get_recorded_coupon_usage_counts( 'edit' ) ),
+ '_download_permissions_granted' => wc_bool_to_string( $this->from_object->get_download_permissions_granted( 'edit' ) ),
+ '_cart_hash' => $this->from_object->get_cart_hash( 'edit' ),
+ '_new_order_email_sent' => wc_bool_to_string( $this->from_object->get_new_order_email_sent( 'edit' ) ),
+ '_order_key' => $this->from_object->get_order_key( 'edit' ),
+ '_order_stock_reduced' => $this->from_object->get_order_stock_reduced( 'edit' ),
+ '_date_paid' => $this->from_object->get_date_paid( 'edit' ),
+ '_date_completed' => $this->from_object->get_date_completed( 'edit' ),
+ '_order_shipping_tax' => $this->from_object->get_shipping_tax( 'edit' ),
+ '_order_shipping' => $this->from_object->get_shipping_total( 'edit' ),
+ '_cart_discount_tax' => $this->from_object->get_discount_tax( 'edit' ),
+ '_cart_discount' => $this->from_object->get_discount_total( 'edit' ),
+ '_recorded_sales' => wc_bool_to_string( $this->from_object->get_recorded_sales( 'edit' ) ),
+ ];
+ }
+
+ /**
+ * Gets the "from" object's core data that was previously stored in wp post meta.
+ *
+ * @return string[] The core data with the legacy meta keys.
+ */
+ private function get_order_data() {
+ return [
+ '_order_currency' => $this->from_object->get_currency( 'edit' ),
+ '_order_tax' => $this->from_object->get_cart_tax( 'edit' ),
+ '_order_total' => $this->from_object->get_total( 'edit' ),
+ '_customer_user' => $this->from_object->get_customer_id( 'edit' ),
+ '_billing_email' => $this->from_object->get_billing_email( 'edit' ),
+ '_payment_method' => $this->from_object->get_payment_method( 'edit' ),
+ '_payment_method_title' => $this->from_object->get_payment_method_title( 'edit' ),
+ '_customer_ip_address' => $this->from_object->get_customer_ip_address( 'edit' ),
+ '_customer_user_agent' => $this->from_object->get_customer_user_agent( 'edit' ),
+ '_transaction_id' => $this->from_object->get_transaction_id( 'edit' ),
+ ];
+ }
+
+ /**
+ * Gets the "from" object's address data that was previously stored in wp post meta.
+ *
+ * @return string[] The address data with the legacy meta keys.
+ */
+ private function get_address_data() {
+ return array_filter(
+ [
+ '_billing_first_name' => $this->from_object->get_billing_first_name( 'edit' ),
+ '_billing_last_name' => $this->from_object->get_billing_last_name( 'edit' ),
+ '_billing_company' => $this->from_object->get_billing_company( 'edit' ),
+ '_billing_address_1' => $this->from_object->get_billing_address_1( 'edit' ),
+ '_billing_address_2' => $this->from_object->get_billing_address_2( 'edit' ),
+ '_billing_city' => $this->from_object->get_billing_city( 'edit' ),
+ '_billing_state' => $this->from_object->get_billing_state( 'edit' ),
+ '_billing_postcode' => $this->from_object->get_billing_postcode( 'edit' ),
+ '_billing_country' => $this->from_object->get_billing_country( 'edit' ),
+ '_billing_email' => $this->from_object->get_billing_email( 'edit' ),
+ '_billing_phone' => $this->from_object->get_billing_phone( 'edit' ),
+ '_shipping_first_name' => $this->from_object->get_shipping_first_name( 'edit' ),
+ '_shipping_last_name' => $this->from_object->get_shipping_last_name( 'edit' ),
+ '_shipping_company' => $this->from_object->get_shipping_company( 'edit' ),
+ '_shipping_address_1' => $this->from_object->get_shipping_address_1( 'edit' ),
+ '_shipping_address_2' => $this->from_object->get_shipping_address_2( 'edit' ),
+ '_shipping_city' => $this->from_object->get_shipping_city( 'edit' ),
+ '_shipping_state' => $this->from_object->get_shipping_state( 'edit' ),
+ '_shipping_postcode' => $this->from_object->get_shipping_postcode( 'edit' ),
+ '_shipping_country' => $this->from_object->get_shipping_country( 'edit' ),
+ ]
+ );
+ }
+
+ /**
+ * Removes the meta keys excluded via the deprecated from the set of data to be copied.
+ *
+ * @param array $data The data to be copied.
+ * @return array The data to be copied with the excluded keys removed.
+ */
+ public function filter_excluded_meta_keys_via_query( $data ) {
+ $excluded_keys = $this->get_excluded_data_keys();
+
+ foreach ( $data as $meta_key => $meta_value ) {
+ if ( isset( $excluded_keys['in'] ) && in_array( $meta_key, $excluded_keys['in'], true ) ) {
+ unset( $data[ $meta_key ] );
+ } elseif ( isset( $excluded_keys['regex'] ) ) {
+ foreach ( $excluded_keys['regex'] as $regex ) {
+ if ( preg_match( $regex, $meta_key ) ) {
+ unset( $data[ $meta_key ] );
+ break;
+ }
+ }
+ }
+ }
+
+ return $data;
+ }
+
+ /**
+ * Returns the deprecated meta database query that returns the "from" objects meta data.
+ *
+ * Triggers a deprecation notice if the deprecated "wcs_{$this->copy_type}_meta_query" filter is in use by at least 1 third-party.
+ *
+ * @return string SQL SELECT query.
+ */
+ private function get_deprecated_meta_query() {
+ global $wpdb;
+
+ $meta_query = sprintf(
+ "SELECT `meta_key`, `meta_value`
+ FROM %s
+ WHERE `post_id` = %d
+ AND `meta_key` NOT LIKE '%s'
+ AND `meta_key` NOT IN ('%s')",
+ $wpdb->postmeta,
+ $this->from_object->get_id(),
+ '_schedule_%',
+ implode( "', '", self::DEFAULT_EXCLUDED_META_KEYS )
+ );
+
+ if ( in_array( $this->copy_type, [ 'renewal_order', 'parent' ], true ) ) {
+ $meta_query .= " AND `meta_key` NOT LIKE '_download_permissions_granted' ";
+ }
+
+ if ( $this->has_filter_on_meta_query_hook() ) {
+ /**
+ * Filters the data to be copied from one object to another.
+ *
+ * This filter name contains a dynamic part, $this->copy_type. The full set of hooks include:
+ * - wcs_subscription_meta_query
+ * - wcs_parent_meta_query
+ * - wcs_renewal_order_meta_query
+ * - wcs_resubscribe_order_meta_query
+ *
+ * @deprecated subscriptions-core 2.5.0
+ *
+ * @param string $meta_query The SQL query to fetch the meta data to be copied.
+ * @param WC_Order $this->to_object The object to copy data to.
+ * @param WC_Order $this->from_object The object to copy data from.
+ */
+ $meta_query = apply_filters( "wcs_{$this->copy_type}_meta_query", $meta_query, $this->to_object, $this->from_object );
+ wcs_deprecated_hook( "wcs_{$this->copy_type}_meta_query", 'subscriptions-core 2.5.0', "wc_subscriptions_{$this->copy_type}_data" );
+ }
+
+ return $meta_query;
+ }
+
+ /**
+ * Applies the deprecated "wcs_{$this->copy_type}_meta filter.
+ *
+ * Triggers a deprecation notice if the deprecated "wcs_{$this->copy_type}_meta" filter is in use by at least 1 third-party.
+ *
+ * @param array $data The data to copy.
+ * @return array The filtered set of data to copy.
+ */
+ private function apply_deprecated_filter( $data ) {
+ // Only continue if the filter is use.
+ if ( ! has_filter( "wcs_{$this->copy_type}_meta" ) ) {
+ return $data;
+ }
+
+ // Convert the data into the backwards compatible format ready for filtering - wpdb's ARRAY_A format.
+ $data_array = [];
+
+ foreach ( $data as $key => $value ) {
+ $data_array[] = [
+ 'meta_key' => $key, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key -- This is a meta key, not a query.
+ 'meta_value' => $value, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_value -- This is a meta value, not a query.
+ ];
+ }
+
+ wcs_deprecated_hook( "wcs_{$this->copy_type}_meta", 'wcs-core 2.5.0', "wc_subscriptions_{$this->copy_type}_data" );
+
+ /**
+ * Filters the data to be copied from one object to another.
+ *
+ * This filter name contains a dynamic part, $this->copy_type. The full set of hooks include:
+ * - wcs_subscription_meta
+ * - wcs_parent_meta
+ * - wcs_renewal_order_meta
+ * - wcs_resubscribe_order_meta
+ *
+ * @deprecated subscriptions-core 2.5.0
+ *
+ * @param array[] $data_array {
+ * The metadata to be copied to the "to" object.
+ *
+ * @type array $meta_data {
+ * The metadata to be copied.
+ *
+ * @type string $meta_key The meta key to be copied.
+ * @type mixed $meta_value The meta value to be copied.
+ * }
+ * }
+ * @param WC_Order $this->to_object The object to copy data to.
+ * @param WC_Order $this->from_object The object to copy data from.
+ */
+ $data_array = apply_filters( "wcs_{$this->copy_type}_meta", $data_array, $this->to_object, $this->from_object );
+
+ // Return the data to a key => value format.
+ return wp_list_pluck( $data_array, 'meta_value', 'meta_key' );
+ }
+
+ /**
+ * Gets a list of meta keys to exclude from the copy.
+ *
+ * If third-parties are hooked onto the "wcs_{$this->copy_type}_meta_query" filter, this function will attempt
+ * to pluck the excluded meta keys from the filtered SQL query. There is no guarantee that this will work for all
+ * queries, however it should work under most standard circumstances.
+ *
+ * If no third-parties are hooked onto the "wcs_{$this->copy_type}_meta_query" filter, this function will simply return
+ * the default list of excluded meta keys.
+ *
+ * @return string[][] An array of excluded meta keys. The array has two keys: 'in' and 'regex'. The 'in' key contains an array of meta keys to exclude. The 'regex' key contains an array of regular expressions to exclude.
+ */
+ private function get_excluded_data_keys() {
+ $excluded_keys = [];
+
+ // If there are no third-parties hooked into the deprecated filter, there is no need to parse the query.
+ if ( ! $this->has_filter_on_meta_query_hook() ) {
+ $excluded_keys['in'] = self::DEFAULT_EXCLUDED_META_KEYS;
+
+ if ( in_array( $this->copy_type, [ 'renewal_order', 'parent' ], true ) ) {
+ $excluded_keys['regex'][] = $this->get_keys_from_like_clause( '_download_permissions_granted' );
+ }
+
+ return $excluded_keys;
+ }
+
+ // Get the deprecated meta query and attempt to pull the excluded keys from it.
+ $meta_query = $this->get_deprecated_meta_query();
+
+ // Normalize the query.
+ $meta_query = str_replace( [ "\r", "\n", "\t" ], ' ', $meta_query ); // Remove line breaks, tabs, etc.
+ $meta_query = preg_replace( '/\s+/', ' ', $meta_query ); // Remove duplicate whitespace.
+ $meta_query = str_replace( '`', '', $meta_query ); // Remove backticks.
+ $meta_query = str_replace( '"', "'", $meta_query ); // Replace double quotes with single quotes.
+
+ // Handle all the NOT LIKE clauses.
+ preg_match_all( "/meta_key NOT LIKE '(.*?)'/", $meta_query, $not_like_clauses );
+
+ if ( ! empty( $not_like_clauses[1] ) ) {
+ foreach ( $not_like_clauses[1] as $not_like_clause ) {
+ $excluded_keys['regex'][] = $this->get_keys_from_like_clause( $not_like_clause );
+ }
+ }
+
+ // Handle all the NOT IN clauses.
+ preg_match_all( '/meta_key NOT IN \((.*?)\)/', $meta_query, $not_in_clauses );
+
+ if ( ! empty( $not_in_clauses[1] ) ) {
+ $excluded_keys['in'] = [];
+ foreach ( $not_in_clauses[1] as $not_in_clause ) {
+ $excluded_keys['in'] = array_merge( $excluded_keys['in'], $this->get_keys_from_in_clause( $not_in_clause ) );
+ }
+ }
+
+ return $excluded_keys;
+ }
+
+ /**
+ * Gets a list of meta keys from a SQL IN clause.
+ *
+ * @param string $in_clause The concatenated string of meta keys from the IN clause. eg: '_paid_date', '_date_paid', '_completed_date' ...
+ * @return string[] The meta keys from the IN clause. eg: [ '_paid_date', '_date_paid', '_completed_date' ]
+ */
+ private function get_keys_from_in_clause( $in_clause ) {
+ // Remove single quotes.
+ $in_keys = str_replace( "'", '', $in_clause );
+
+ // Split into an array.
+ $in_keys = explode( ',', $in_keys );
+
+ // Trim whitespace from each key.
+ $in_keys = array_map( 'trim', $in_keys );
+
+ return $in_keys;
+ }
+
+ /**
+ * Formats a LIKE clause into a regex pattern.
+ *
+ * @param string $like_clause A SQL LIKE clause. eg: '_schedule_%%'
+ * @return string A regex pattern. eg: '/^_schedule_.*$/'
+ */
+ private function get_keys_from_like_clause( $like_clause ) {
+ // Remove the surrounding quotes.
+ $like_clause = str_replace( "'", '', $like_clause );
+
+ // Replace the wildcard with a regex wildcard.
+ $like_clause = str_replace( '%', '.*?', $like_clause );
+
+ // Add the regex wildcard to the beginning and end of the string.
+ return '^' . trim( $like_clause ) . '$^';
+ }
+}
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-email.php b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-email.php
index 9417e60..77d42e3 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-email.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-email.php
@@ -14,7 +14,7 @@ class WC_Subscriptions_Email {
/**
* Bootstraps the class and hooks required actions & filters.
*
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function init() {
@@ -31,7 +31,7 @@ class WC_Subscriptions_Email {
/**
* Add Subscriptions' email classes.
*
- * @since 1.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4
*/
public static function add_emails( $email_classes ) {
$email_classes['WCS_Email_New_Renewal_Order'] = new WCS_Email_New_Renewal_Order();
@@ -51,7 +51,7 @@ class WC_Subscriptions_Email {
/**
* Hooks up all of Subscription's transaction emails after the WooCommerce object is constructed.
*
- * @since 1.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4
*/
public static function hook_transactional_emails() {
@@ -105,7 +105,7 @@ class WC_Subscriptions_Email {
* Init the mailer and call for the cancelled email notification hook.
*
* @param $subscription WC Subscription
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function send_cancelled_email( $subscription ) {
WC()->mailer();
@@ -119,7 +119,7 @@ class WC_Subscriptions_Email {
* Init the mailer and call for the expired email notification hook.
*
* @param $subscription WC Subscription
- * @since 2.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1
*/
public static function send_expired_email( $subscription ) {
WC()->mailer();
@@ -131,7 +131,7 @@ class WC_Subscriptions_Email {
* Init the mailer and call for the suspended email notification hook.
*
* @param $subscription WC Subscription
- * @since 2.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1
*/
public static function send_on_hold_email( $subscription ) {
WC()->mailer();
@@ -261,7 +261,7 @@ class WC_Subscriptions_Email {
* @param bool $sent_to_admin Whether the email is sent to admin - defaults to false
* @param bool $plain_text Whether the email should use plain text templates - defaults to false
* @param WC_Email $email
- * @since 2.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1
*/
public static function order_details( $order, $sent_to_admin = false, $plain_text = false, $email = '' ) {
@@ -297,7 +297,7 @@ class WC_Subscriptions_Email {
*
* @param string Optional. The action hook or filter to detach WC core's transactional emails from. Defaults to the current filter.
* @param int Optional. The priority the function runs on. Default 10.
- * @since 2.2.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.3
*/
public static function detach_woocommerce_transactional_email( $hook = '', $priority = 10 ) {
@@ -316,7 +316,7 @@ class WC_Subscriptions_Email {
* @param string Optional. The action hook or filter to attach WC core's transactional emails to. Defaults to the current filter.
* @param int Optional. The priority the function should run on. Default 10.
* @param int Optional. The number of arguments the function accepts. Default 10.
- * @since 2.2.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.3
*/
public static function attach_woocommerce_transactional_email( $hook = '', $priority = 10, $accepted_args = 10 ) {
@@ -338,7 +338,7 @@ class WC_Subscriptions_Email {
* @param bool $sent_to_admin Whether the email is sent to admin - defaults to false
* @param bool $plain_text Whether the email should use plain text templates - defaults to false
* @param WC_Email $email
- * @since 2.2.17
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.17
*/
public static function order_download_details( $order, $sent_to_admin = false, $plain_text = false, $email = '' ) {
if ( is_callable( array( 'WC_Emails', 'order_downloads' ) ) ) {
@@ -352,7 +352,7 @@ class WC_Subscriptions_Email {
* @param int $user_id The ID of the user who the subscription belongs to
* @param string $subscription_key A subscription key of the form created by @see self::get_subscription_key()
* @return void
- * @deprecated 2.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function send_subscription_email( $user_id, $subscription_key ) {
_deprecated_function( __FUNCTION__, '2.0' );
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-extend-store-endpoint.php b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-extend-store-endpoint.php
index 0574d1c..7fc02aa 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-extend-store-endpoint.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-extend-store-endpoint.php
@@ -6,7 +6,7 @@
* for each subscription item
*
* @package WooCommerce Subscriptions
- * @since WCBLOCKS-DEV
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions
*/
use Automattic\WooCommerce\Blocks\Package;
@@ -46,7 +46,7 @@ class WC_Subscriptions_Extend_Store_Endpoint {
/**
* Bootstraps the class and hooks required data.
*
- * @since WCBLOCKS-DEV
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions
*/
public static function init() {
self::$schema = class_exists( 'Automattic\WooCommerce\StoreApi\StoreApi' ) ? Automattic\WooCommerce\StoreApi\StoreApi::container()->get( Automattic\WooCommerce\StoreApi\SchemaController::class ) : Package::container()->get( Automattic\WooCommerce\Blocks\StoreApi\SchemaController::class );
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-frontend-scripts.php b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-frontend-scripts.php
index 735a460..916d20d 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-frontend-scripts.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-frontend-scripts.php
@@ -3,7 +3,7 @@
* Enqueues WC Subscriptions frontend scripts.
*
* @package WooCommerce Subscriptions
- * @since 3.1.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.3
*/
defined( 'ABSPATH' ) || exit;
@@ -21,7 +21,7 @@ class WC_Subscriptions_Frontend_Scripts {
/**
* Gets the plugin URL for an assets file.
*
- * @since 3.1.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.3
* @return string The file URL.
*/
public static function get_file_url( $file_relative_url = '' ) {
@@ -31,15 +31,15 @@ class WC_Subscriptions_Frontend_Scripts {
/**
* Enqueues scripts for frontend.
*
- * @since 3.1.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.3
*/
public static function enqueue_scripts() {
$dependencies = array( 'jquery' );
if ( is_cart() || is_checkout() ) {
- wp_enqueue_script( 'wcs-cart', self::get_file_url( 'assets/js/frontend/wcs-cart.js' ), $dependencies, WC_Subscriptions_Core_Plugin::instance()->get_plugin_version(), true );
+ wp_enqueue_script( 'wcs-cart', self::get_file_url( 'assets/js/frontend/wcs-cart.js' ), $dependencies, WC_Subscriptions_Core_Plugin::instance()->get_library_version(), true );
} elseif ( is_product() ) {
- wp_enqueue_script( 'wcs-single-product', self::get_file_url( 'assets/js/frontend/single-product.js' ), $dependencies, WC_Subscriptions_Core_Plugin::instance()->get_plugin_version(), true );
+ wp_enqueue_script( 'wcs-single-product', self::get_file_url( 'assets/js/frontend/single-product.js' ), $dependencies, WC_Subscriptions_Core_Plugin::instance()->get_library_version(), true );
} elseif ( wcs_is_view_subscription_page() ) {
$subscription = wcs_get_subscription( absint( get_query_var( 'view-subscription' ) ) );
@@ -54,7 +54,7 @@ class WC_Subscriptions_Frontend_Scripts {
'has_payment_gateway' => $subscription->has_payment_gateway() && wc_get_payment_gateway_by_order( $subscription )->supports( 'subscriptions' ),
);
- wp_enqueue_script( 'wcs-view-subscription', self::get_file_url( 'assets/js/frontend/view-subscription.js' ), $dependencies, WC_Subscriptions_Core_Plugin::instance()->get_plugin_version(), true );
+ wp_enqueue_script( 'wcs-view-subscription', self::get_file_url( 'assets/js/frontend/view-subscription.js' ), $dependencies, WC_Subscriptions_Core_Plugin::instance()->get_library_version(), true );
wp_localize_script( 'wcs-view-subscription', 'WCSViewSubscription', apply_filters( 'woocommerce_subscriptions_frontend_view_subscription_script_parameters', $script_params ) );
}
}
@@ -63,7 +63,7 @@ class WC_Subscriptions_Frontend_Scripts {
/**
* Enqueues stylesheets.
*
- * @since 3.1.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.3
*/
public static function enqueue_styles( $styles ) {
@@ -78,7 +78,7 @@ class WC_Subscriptions_Frontend_Scripts {
$styles['wcs-view-subscription'] = array(
'src' => str_replace( array( 'http:', 'https:' ), '', self::get_file_url( 'assets/css/view-subscription.css' ) ),
'deps' => 'woocommerce-smallscreen',
- 'version' => WC_Subscriptions_Core_Plugin::instance()->get_plugin_version(),
+ 'version' => WC_Subscriptions_Core_Plugin::instance()->get_library_version(),
'media' => 'all',
);
}
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-manager.php b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-manager.php
index b529710..4a3a204 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-manager.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-manager.php
@@ -12,24 +12,23 @@
* @subpackage WC_Subscriptions_Manager
* @category Class
* @author Brent Shepherd
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
class WC_Subscriptions_Manager {
/**
* The database key for user's subscriptions.
*
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static $users_meta_key = 'woocommerce_subscriptions';
/**
* Set up the class, including it's hooks & filters, when the file is loaded.
*
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
**/
public static function init() {
-
// When an order's status is changed, run the appropriate subscription function
add_action( 'woocommerce_order_status_cancelled', __CLASS__ . '::cancel_subscriptions_for_order' );
add_action( 'woocommerce_order_status_failed', __CLASS__ . '::failed_subscription_sign_ups_for_order' );
@@ -47,31 +46,57 @@ class WC_Subscriptions_Manager {
// Whenever a renewal payment is due, put the subscription on hold and create a renewal order before anything else, in case things don't go to plan
add_action( 'woocommerce_scheduled_subscription_payment', __CLASS__ . '::prepare_renewal', 1, 1 );
- // Order is trashed, trash subscription
- add_action( 'wp_trash_post', __CLASS__ . '::maybe_trash_subscription', 10 );
+ // When a subscriptions trial end scheduled action is run, attach a callback to trigger a subscription specific trial ended hook.
+ add_action( 'woocommerce_scheduled_subscription_trial_end', __CLASS__ . '::trigger_subscription_trial_ended_hook', 10, 1 );
- // Order is restored (untrashed), restore subscription
- add_action( 'untrashed_post', __CLASS__ . '::maybe_untrash_subscription', 10 );
-
- // When order is deleted, delete the subscription.
- add_action( 'before_delete_post', array( __CLASS__, 'maybe_delete_subscription' ) );
+ // Attach hooks that depend on WooCommerce being loaded.
+ add_action( 'woocommerce_loaded', [ __CLASS__, 'attach_wc_dependant_hooks' ] );
// When a user is being deleted from the site, via standard WordPress functions, make sure their subscriptions are cancelled
add_action( 'delete_user', __CLASS__ . '::trash_users_subscriptions' );
// Do the same thing for WordPress networks
add_action( 'wpmu_delete_user', __CLASS__ . '::trash_users_subscriptions_for_network' );
+ }
- // make sure a subscription is cancelled before it is trashed/deleted
- add_action( 'wp_trash_post', __CLASS__ . '::maybe_cancel_subscription', 10, 1 );
- add_action( 'before_delete_post', __CLASS__ . '::maybe_cancel_subscription', 10, 1 );
+ /**
+ * Attaches hooks that depend on WooCommerce being loaded.
+ *
+ * We need to use different hooks on stores that have HPOS enabled but to check if this feature
+ * is enabled, we must wait for WooCommerce to be loaded first.
+ *
+ * @since 5.2.0
+ */
+ public static function attach_wc_dependant_hooks() {
+ if ( wcs_is_custom_order_tables_usage_enabled() ) {
+ // When a parent order is trashed, untrashed or deleted, make sure the appropriate action is taken on the related subscription
+ add_action( 'woocommerce_before_trash_order', [ __CLASS__, 'maybe_trash_subscription' ], 10 );
+ add_action( 'woocommerce_untrash_order', [ __CLASS__, 'maybe_untrash_subscription' ], 10 );
+ add_action( 'woocommerce_before_delete_order', [ __CLASS__, 'maybe_delete_subscription' ] );
- // set correct status to restore after a subscription is trashed/deleted
- add_action( 'trashed_post', __CLASS__ . '::fix_trash_meta_status' );
+ // make sure a subscription is cancelled before it is trashed/deleted
+ add_action( 'woocommerce_before_trash_subscription', [ __CLASS__, 'maybe_cancel_subscription' ], 10, 1 );
+ add_action( 'woocommerce_before_delete_subscription', [ __CLASS__, 'maybe_cancel_subscription' ], 10, 1 );
- // call special hooks when a subscription is trashed/deleted
- add_action( 'trashed_post', __CLASS__ . '::trigger_subscription_trashed_hook' );
- add_action( 'deleted_post', __CLASS__ . '::trigger_subscription_deleted_hook' );
+ // set correct status to restore after a subscription is trashed/deleted
+ add_action( 'woocommerce_trash_subscription', [ __CLASS__, 'fix_trash_meta_status' ] );
+ } else {
+ // When a parent order is trashed, untrashed or deleted, make sure the appropriate action is taken on the related subscription
+ add_action( 'wp_trash_post', __CLASS__ . '::maybe_trash_subscription', 10 );
+ add_action( 'untrashed_post', __CLASS__ . '::maybe_untrash_subscription', 10 );
+ add_action( 'before_delete_post', array( __CLASS__, 'maybe_delete_subscription' ) );
+
+ // make sure a subscription is cancelled before it is trashed/deleted
+ add_action( 'wp_trash_post', __CLASS__ . '::maybe_cancel_subscription', 10, 1 );
+ add_action( 'before_delete_post', __CLASS__ . '::maybe_cancel_subscription', 10, 1 );
+
+ // set correct status to restore after a subscription is trashed/deleted
+ add_action( 'trashed_post', __CLASS__ . '::fix_trash_meta_status' );
+
+ // call special hooks when a subscription is trashed/deleted
+ add_action( 'trashed_post', __CLASS__ . '::trigger_subscription_trashed_hook' );
+ add_action( 'deleted_post', __CLASS__ . '::trigger_subscription_deleted_hook' );
+ }
}
/**
@@ -80,7 +105,7 @@ class WC_Subscriptions_Manager {
* This function is hooked early on the scheduled subscription payment hook.
*
* @param int $subscription_id The ID of a 'shop_subscription' post
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function prepare_renewal( $subscription_id ) {
@@ -100,7 +125,7 @@ class WC_Subscriptions_Manager {
* @param int $subscription_id The ID of a 'shop_subscription' post
* @param string $required_status The subscription status required to process a renewal order
* @param string $order_note Reason for subscription status change
- * @since 2.2.12
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.12
*/
public static function process_renewal( $subscription_id, $required_status, $order_note ) {
@@ -151,7 +176,7 @@ class WC_Subscriptions_Manager {
* Expires a single subscription on a users account.
*
* @param int $subscription_id The ID of a 'shop_subscription' post
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function expire_subscription( $subscription_id, $deprecated = null ) {
@@ -174,7 +199,7 @@ class WC_Subscriptions_Manager {
* Fires when a cancelled subscription reaches the end of its prepaid term.
*
* @param int $subscription_id The ID of a 'shop_subscription' post
- * @since 1.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.3
*/
public static function subscription_end_of_prepaid_term( $subscription_id, $deprecated = null ) {
@@ -190,12 +215,23 @@ class WC_Subscriptions_Manager {
}
}
+ /**
+ * Trigger action hook after a subscription's trial period has ended.
+ *
+ * @since 5.5.0
+ *
+ * @param int $subscription_id
+ */
+ public static function trigger_subscription_trial_ended_hook( $subscription_id ) {
+ do_action( 'woocommerce_subscription_trial_ended', $subscription_id );
+ }
+
/**
* Records a payment on a subscription.
*
* @param int $user_id The id of the user who owns the subscription.
* @param string $subscription_key A subscription key of the form obtained by @see get_subscription_key( $order_id, $product_id )
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function process_subscription_payment( $user_id, $subscription_key ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscription::payment_complete()' );
@@ -216,7 +252,7 @@ class WC_Subscriptions_Manager {
*
* @param int $user_id The id of the user who owns the expiring subscription.
* @param string $subscription_key A subscription key of the form obtained by @see get_subscription_key( $order_id, $product_id )
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function process_subscription_payment_failure( $user_id, $subscription_key ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscription::payment_failed()' );
@@ -246,7 +282,7 @@ class WC_Subscriptions_Manager {
* function directly, do not call this function also.
*
* @param WC_Order|int $order The order or ID of the order for which subscription payments should be marked against.
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function process_subscription_payments_on_order( $order, $product_id = '' ) {
wcs_deprecated_function( __METHOD__, '2.6.0' );
@@ -269,7 +305,7 @@ class WC_Subscriptions_Manager {
* function directly, do not call this function also.
*
* @param int|WC_Order $order The order or ID of the order for which subscription payments should be marked against.
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function process_subscription_payment_failure_on_order( $order, $product_id = '' ) {
wcs_deprecated_function( __METHOD__, '2.6.0' );
@@ -289,7 +325,7 @@ class WC_Subscriptions_Manager {
* Activates all the subscriptions created by a given order.
*
* @param WC_Order|int $order The order or ID of the order for which subscriptions should be marked as activated.
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function activate_subscriptions_for_order( $order ) {
@@ -315,7 +351,7 @@ class WC_Subscriptions_Manager {
* Suspends all the subscriptions on an order by changing their status to "on-hold".
*
* @param WC_Order|int $order The order or ID of the order for which subscriptions should be marked as activated.
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function put_subscription_on_hold_for_order( $order ) {
@@ -343,7 +379,7 @@ class WC_Subscriptions_Manager {
* Mark all subscriptions in an order as cancelled on the user's account.
*
* @param WC_Order|int $order The order or ID of the order for which subscriptions should be marked as cancelled.
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function cancel_subscriptions_for_order( $order ) {
@@ -371,7 +407,7 @@ class WC_Subscriptions_Manager {
* Marks all the subscriptions in an order as expired
*
* @param WC_Order|int $order The order or ID of the order for which subscriptions should be marked as expired.
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function expire_subscriptions_for_order( $order ) {
@@ -399,7 +435,7 @@ class WC_Subscriptions_Manager {
* Called when a sign up fails during the payment processing step.
*
* @param WC_Order|int $order The order or ID of the order for which subscriptions should be marked as failed.
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function failed_subscription_sign_ups_for_order( $order ) {
@@ -440,7 +476,7 @@ class WC_Subscriptions_Manager {
* @param array $args An array of name => value pairs to customise the details of the subscription, including:
* 'start_date' A MySQL formatted date/time string on which the subscription should start, in UTC timezone
* 'expiry_date' A MySQL formatted date/time string on which the subscription should expire, in UTC timezone
- * @since 1.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.1
*/
public static function create_pending_subscription_for_order( $order, $product_id, $args = array() ) {
_deprecated_function( __METHOD__, '2.0', 'wcs_create_subscription()' );
@@ -574,7 +610,7 @@ class WC_Subscriptions_Manager {
* an order containing subscriptions.
*
* @param int|WC_Order $order The order ID or WC_Order object to create the subscription from.
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function process_subscriptions_on_checkout( $order ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscriptions_Checkout::process_checkout()' );
@@ -589,7 +625,7 @@ class WC_Subscriptions_Manager {
*
* @param WC_Order $order The order to get subscriptions and user details from.
* @param string $status (optional) A status to change the subscriptions in an order to. Default is 'active'.
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function update_users_subscriptions_for_order( $order, $status = 'pending' ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscriptions::update_status()' );
@@ -643,7 +679,7 @@ class WC_Subscriptions_Manager {
* 'completed_payments' An array of MySQL formatted dates for all payments that have been made on the subscription
* 'failed_payments' An integer representing a count of failed payments
* 'suspension_count' An integer representing a count of the number of times the subscription has been suspended for this billing period
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function update_users_subscriptions( $user_id, $subscriptions ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscriptions API methods' );
@@ -679,7 +715,7 @@ class WC_Subscriptions_Manager {
* 'completed_payments' An array of MySQL formatted dates for all payments that have been made on the subscription
* 'failed_payments' An integer representing a count of failed payments
* 'suspension_count' An integer representing a count of the number of times the subscription has been suspended for this billing period
- * @since 1.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4
*/
public static function update_subscription( $subscription_key, $new_subscription_details ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscriptions API methods' );
@@ -726,7 +762,7 @@ class WC_Subscriptions_Manager {
*
* @uses wp_parse_args To allow only part of a subscription's details to be updated, like status.
* @param int $user_id The ID of the user for whom subscription details should be updated
- * @since 1.3.8
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.3.8
*/
public static function cancel_users_subscriptions( $user_id ) {
@@ -749,7 +785,7 @@ class WC_Subscriptions_Manager {
*
* @uses wp_parse_args To allow only part of a subscription's details to be updated, like status.
* @param int $user_id The ID of the user for whom subscription details should be updated
- * @since 1.3.8
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.3.8
*/
public static function cancel_users_subscriptions_for_network( $user_id ) {
@@ -774,12 +810,12 @@ class WC_Subscriptions_Manager {
* Clear all subscriptions for a given order.
*
* @param WC_Order $order The order for which subscriptions should be cleared.
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function clear_users_subscriptions_from_order( $order ) {
foreach ( wcs_get_subscriptions_for_order( $order, array( 'order_type' => 'parent' ) ) as $subscription_id => $subscription ) {
- wp_delete_post( $subscription->get_id() );
+ $subscription->delete( true );
}
do_action( 'cleared_users_subscriptions_from_order', $order );
@@ -790,27 +826,46 @@ class WC_Subscriptions_Manager {
*
* Also make sure all related scheduled actions are cancelled when deleting a subscription.
*
- * @param int $post_id The post ID of the WC Subscription or WC Order being trashed
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
+ *
+ * @param int $order_id The order ID of the WC Subscription or WC Order being trashed
*/
- public static function maybe_trash_subscription( $post_id ) {
- if ( 'shop_order' === WC_Data_Store::load( 'order' )->get_order_type( $post_id ) ) {
+ public static function maybe_trash_subscription( $order_id ) {
+ if ( 'shop_order' === WC_Data_Store::load( 'order' )->get_order_type( $order_id ) ) {
// delete subscription
- foreach ( wcs_get_subscriptions_for_order( $post_id, array( 'order_type' => 'parent' ) ) as $subscription ) {
- wp_trash_post( $subscription->get_id() );
+ foreach ( wcs_get_subscriptions_for_order( $order_id, [ 'order_type' => 'parent' ] ) as $subscription ) {
+ $subscription->delete();
}
}
}
/**
* Untrash all subscriptions attached to an order when it's restored.
- * @param int $post_id The post ID of the WC Order being restored
- * @since 2.2.17
+ *
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.17
+ *
+ * @param int $order_id The Order ID of the order being restored
*/
- public static function maybe_untrash_subscription( $post_id ) {
- if ( 'shop_order' === WC_Data_Store::load( 'order' )->get_order_type( $post_id ) ) {
- foreach ( wcs_get_subscriptions_for_order( $post_id, array( 'order_type' => 'parent', 'subscription_status' => array( 'trash' ) ) ) as $subscription ) { // phpcs:ignore WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
+ public static function maybe_untrash_subscription( $order_id ) {
+ if ( 'shop_order' !== WC_Data_Store::load( 'order' )->get_order_type( $order_id ) ) {
+ return;
+ }
+
+ $data_store = WC_Data_Store::load( 'subscription' );
+ $use_crud_method = method_exists( $data_store, 'has_callable' ) && $data_store->has_callable( 'untrash_order' );
+ $subscriptions = wcs_get_subscriptions_for_order(
+ $order_id,
+ [
+ 'order_type' => 'parent',
+ 'subscription_status' => [ 'trash' ],
+ ]
+ );
+
+ foreach ( $subscriptions as $subscription ) {
+ if ( $use_crud_method ) {
+ $data_store->untrash_order( $subscription );
+ } else {
wp_untrash_post( $subscription->get_id() );
}
}
@@ -819,75 +874,104 @@ class WC_Subscriptions_Manager {
/**
* Delete related subscriptions when an order is deleted.
*
- * @author Jeremy Pry
- *
- * @param int $post_id The post ID being deleted.
+ * @param int $order_id The post ID being deleted.
*/
- public static function maybe_delete_subscription( $post_id ) {
- if ( 'shop_order' !== WC_Data_Store::load( 'order' )->get_order_type( $post_id ) ) {
+ public static function maybe_delete_subscription( $order_id ) {
+ if ( 'shop_order' !== WC_Data_Store::load( 'order' )->get_order_type( $order_id ) ) {
return;
}
/** @var WC_Subscription[] $subscriptions */
- $subscriptions = wcs_get_subscriptions_for_order( $post_id, array(
- 'subscription_status' => array( 'any', 'trash' ),
- 'order_type' => 'parent',
- ) );
+ $subscriptions = wcs_get_subscriptions_for_order(
+ $order_id,
+ [
+ 'order_type' => 'parent',
+ 'subscription_status' => [ 'any', 'trash' ],
+ ]
+ );
+
foreach ( $subscriptions as $subscription ) {
- wp_delete_post( $subscription->get_id() );
+ $subscription->delete( true );
}
}
/**
* Make sure a subscription is cancelled before it is trashed or deleted
*
- * @param int $post_id
- * @since 2.0
+ * @param int $id
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
- public static function maybe_cancel_subscription( $post_id ) {
+ public static function maybe_cancel_subscription( $id ) {
- if ( 'shop_subscription' == get_post_type( $post_id ) && 'auto-draft' !== get_post_status( $post_id ) ) {
+ $subscription = wcs_get_subscription( $id );
+ if ( ! $subscription ) {
+ return;
+ }
- $subscription = wcs_get_subscription( $post_id );
+ if ( $subscription->get_type() !== 'shop_subscription' ) {
+ return;
+ }
- if ( $subscription->can_be_updated_to( 'cancelled' ) ) {
+ if ( $subscription->can_be_updated_to( 'cancelled' ) ) {
- $subscription->update_status( 'cancelled' );
+ $subscription->update_status( 'cancelled' );
- }
}
}
/**
- * When WordPress trashes a post, it sets a '_wp_trash_meta_status' post meta value so that the post can
- * be restored to its original status. However, when setting that value, it uses the 'post_status' of a
- * $post variable in memory. If that status is changed on the 'wp_trash_post' or 'wp_delete_post' hooks,
+ * When an order is trashed, store the '_wp_trash_meta_status' meta value with a cancelled subscription status
+ * to prevent subscriptions being restored with an active status.
+ *
+ * When WordPress and WooCommerce set this meta value, they use the status of the order in memory.
+ * If that status is changed on the before trashed or before deleted hooks,
* as is the case with a subscription, which is cancelled before being trashed if it is active or on-hold,
* then the '_wp_trash_meta_status' value will be incorrectly set to its status before being trashed.
*
* This function fixes that by setting '_wp_trash_meta_status' to 'wc-cancelled' whenever its former status
* is something that can not be restored.
*
- * @param int $post_id
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
+ *
+ * @param int $id
*/
- public static function fix_trash_meta_status( $post_id ) {
+ public static function fix_trash_meta_status( $id ) {
+ $subscription = wcs_get_subscription( $id );
- if ( 'shop_subscription' == get_post_type( $post_id ) && ! in_array( get_post_meta( $post_id, '_wp_trash_meta_status', true ), array( 'wc-pending', 'wc-expired', 'wc-cancelled' ) ) ) {
- update_post_meta( $post_id, '_wp_trash_meta_status', 'wc-cancelled' );
+ if ( ! $subscription ) {
+ return;
+ }
+
+ if ( $subscription->get_type() !== 'shop_subscription' ) {
+ return;
+ }
+
+ $data_store = $subscription->get_data_store();
+ $meta_data = $data_store->read_meta( $subscription );
+
+ foreach ( $meta_data as $meta ) {
+ if ( '_wp_trash_meta_status' === $meta->meta_key && ! in_array( $meta->meta_value, [ 'wc-pending', 'wc-expired', 'wc-cancelled' ], true ) ) {
+ $new_meta = (object) [
+ 'id' => $meta->meta_id,
+ 'key' => $meta->meta_key,
+ 'value' => 'wc-cancelled',
+ ];
+ $data_store->update_meta( $subscription, $new_meta );
+ break;
+ }
}
}
/**
* Trigger action hook after a subscription has been trashed.
*
- * @param int $post_id
- * @since 2.0
+ * @param int $id
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
- public static function trigger_subscription_trashed_hook( $post_id ) {
+ public static function trigger_subscription_trashed_hook( $id ) {
- if ( 'shop_subscription' == get_post_type( $post_id ) ) {
- do_action( 'woocommerce_subscription_trashed', $post_id );
+ if ( 'shop_subscription' === WC_Data_Store::load( 'subscription' )->get_order_type( $id ) ) {
+ do_action( 'woocommerce_subscription_trashed', $id );
}
}
@@ -895,7 +979,7 @@ class WC_Subscriptions_Manager {
* Takes a user ID and trashes any subscriptions that user has.
*
* @param int $user_id The ID of the user whose subscriptions will be trashed
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function trash_users_subscriptions( $user_id ) {
$subscriptions = wcs_get_users_subscriptions( $user_id );
@@ -926,7 +1010,7 @@ class WC_Subscriptions_Manager {
* Takes a user ID and trashes any subscriptions that user has on any site in a WordPress network
*
* @param int $user_id The ID of the user whose subscriptions will be trashed
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function trash_users_subscriptions_for_network( $user_id ) {
@@ -948,13 +1032,13 @@ class WC_Subscriptions_Manager {
/**
* Trigger action hook after a subscription has been deleted.
*
- * @param int $post_id
- * @since 2.0
+ * @param int $id
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
- public static function trigger_subscription_deleted_hook( $post_id ) {
+ public static function trigger_subscription_deleted_hook( $id ) {
- if ( 'shop_subscription' == get_post_type( $post_id ) ) {
- do_action( 'woocommerce_subscription_deleted', $post_id );
+ if ( 'shop_subscription' === WC_Data_Store::load( 'subscription' )->get_order_type( $id ) ) {
+ do_action( 'woocommerce_subscription_deleted', $id );
}
}
@@ -962,8 +1046,8 @@ class WC_Subscriptions_Manager {
* Checks if the current request is by a user to change the status of their subscription, and if it is
* validate the subscription cancellation request and maybe processes the cancellation.
*
- * @since 1.0
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function maybe_change_users_subscription() {
_deprecated_function( __METHOD__, '2.0', 'WCS_User_Change_Status_Handler::maybe_change_users_subscription()' );
@@ -979,7 +1063,7 @@ class WC_Subscriptions_Manager {
* @param string $new_status_or_meta The status or meta data you want to change th subscription to. Can be 'active', 'on-hold', 'cancelled', 'expired', 'trash', 'deleted', 'failed', 'new-payment-date' or some other value attached to the 'woocommerce_can_subscription_be_changed_to' filter.
* @param string $subscription_key A subscription key of the form created by @see self::get_subscription_key()
* @param int $user_id The ID of the user who owns the subscriptions. Although this parameter is optional, if you have the User ID you should pass it to improve performance.
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function can_subscription_be_changed_to( $new_status_or_meta, $subscription_key, $user_id = '' ) {
@@ -1027,7 +1111,7 @@ class WC_Subscriptions_Manager {
* @param string $subscription_key A subscription key of the form created by @see self::get_subscription_key()
* @param deprecated don't use
* @return array Subscription details
- * @since 1.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.1
*/
public static function get_subscription( $subscription_key, $deprecated = null ) {
@@ -1052,7 +1136,7 @@ class WC_Subscriptions_Manager {
*
* @param string $status An subscription status of it's internal form.
* @return string A translated subscription status string for display.
- * @since 1.2.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2.3
*/
public static function get_status_to_display( $status, $subscription_key = '', $user_id = 0 ) {
_deprecated_function( __METHOD__, '2.0', 'wcs_get_subscription_statuses()' );
@@ -1087,8 +1171,8 @@ class WC_Subscriptions_Manager {
/**
* Return an i18n'ified associative array of all possible subscription periods.
*
- * @since 1.1
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.1
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_subscription_period_strings( $number = 1, $period = '' ) {
_deprecated_function( __METHOD__, '2.0', 'wcs_get_subscription_period_strings()' );
@@ -1098,8 +1182,8 @@ class WC_Subscriptions_Manager {
/**
* Return an i18n'ified associative array of all possible subscription periods.
*
- * @since 1.0
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_subscription_period_interval_strings( $interval = '' ) {
_deprecated_function( __METHOD__, '2.0', 'wcs_get_subscription_period_interval_strings()' );
@@ -1116,8 +1200,8 @@ class WC_Subscriptions_Manager {
* Y – for years; allowable range is 1 to 5
*
* @param subscription_period string (optional) One of day, week, month or year. If empty, all subscription ranges are returned.
- * @since 1.0
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_subscription_ranges( $subscription_period = '' ) {
_deprecated_function( __METHOD__, '2.0', 'wcs_get_subscription_ranges()' );
@@ -1129,8 +1213,8 @@ class WC_Subscriptions_Manager {
*
* @see self::get_subscription_ranges()
* @param subscription_period string (optional) One of day, week, month or year. If empty, all subscription ranges are returned.
- * @since 1.1
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.1
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_subscription_trial_lengths( $subscription_period = '' ) {
_deprecated_function( __METHOD__, '2.0', 'wcs_get_subscription_trial_lengths( $subscription_period )' );
@@ -1140,8 +1224,8 @@ class WC_Subscriptions_Manager {
/**
* Return an i18n'ified associative array of all possible subscription trial periods.
*
- * @since 1.2
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_subscription_trial_period_strings( $number = 1, $period = '' ) {
_deprecated_function( __METHOD__, '2.0', 'wcs_get_subscription_trial_period_strings( $number, $period )' );
@@ -1152,8 +1236,8 @@ class WC_Subscriptions_Manager {
* Return an i18n'ified associative array of all time periods allowed for subscriptions.
*
* @param string $form Either 'singular' for singular trial periods or 'plural'.
- * @since 1.2
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_available_time_periods( $form = 'singular' ) {
_deprecated_function( __METHOD__, '2.0', 'wcs_get_available_time_periods( $form )' );
@@ -1166,7 +1250,7 @@ class WC_Subscriptions_Manager {
* @param order_id int The ID of the order in which the subscription was purchased.
* @param product_id int The ID of the subscription product.
* @return string The key representing the given subscription.
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function get_subscription_key( $order_id, $product_id = '' ) {
@@ -1208,8 +1292,8 @@ class WC_Subscriptions_Manager {
* @param string $subscription_key A subscription key of the form created by @see self::get_subscription_key()
* @param int $user_id The ID of the user who owns the subscriptions. Although this parameter is optional, if you have the User ID you should pass it to improve performance.
* @return int The number of outstanding failed payments on the subscription, if any.
- * @since 1.0
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_subscriptions_failed_payment_count( $subscription_key, $user_id = '' ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscription::get_failed_payment_count()' );
@@ -1222,8 +1306,8 @@ class WC_Subscriptions_Manager {
* @param string $subscription_key A subscription key of the form created by @see self::get_subscription_key()
* @param int $user_id The ID of the user who owns the subscriptions. Although this parameter is optional, if you have the User ID you should pass it to improve performance.
* @return int The number of outstanding failed payments on the subscription, if any.
- * @since 1.4
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_subscriptions_completed_payment_count( $subscription_key ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscription::get_payment_count()' );
@@ -1237,8 +1321,8 @@ class WC_Subscriptions_Manager {
* @param string $subscription_key A subscription key of the form created by @see self::get_subscription_key()
* @param int $user_id The ID of the user who owns the subscriptions. Although this parameter is optional, if you have the User ID you should pass it to improve performance.
* @param string $type (optional) The format for the Either 'mysql' or 'timestamp'.
- * @since 1.1
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.1
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_subscription_expiration_date( $subscription_key, $user_id = '', $type = 'mysql' ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscription::get_date( "end" )' );
@@ -1254,8 +1338,8 @@ class WC_Subscriptions_Manager {
* @param int $user_id (optional) The ID of the user who owns the subscriptions. Although this parameter is optional, if you have the User ID you should pass it to improve performance.
* @param (optional) $next_payment string | int The date and time the next payment is due, either as MySQL formatted datetime string or a Unix timestamp. If empty, @see self::calculate_subscription_expiration_date() will be called.
* @return mixed If the expiration does not get set, returns false, otherwise it will return a MySQL datetime formatted string for the new date when the subscription will expire
- * @since 1.2.4
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2.4
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function set_expiration_date( $subscription_key, $user_id = '', $expiration_date = '' ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscription::update_dates( array( "end" => $expiration_date ) )' );
@@ -1277,8 +1361,8 @@ class WC_Subscriptions_Manager {
* @param string $subscription_key A subscription key of the form created by @see self::get_subscription_key()
* @param int $user_id The ID of the user who owns the subscriptions. Although this parameter is optional, if you have the User ID you should pass it to improve performance.
* @param string $type (optional) The format for the Either 'mysql' or 'timestamp'.
- * @since 1.1
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.1
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function calculate_subscription_expiration_date( $subscription_key, $user_id = '', $type = 'mysql' ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscription::get_date( "end" )' );
@@ -1294,8 +1378,8 @@ class WC_Subscriptions_Manager {
* @param int $user_id The ID of the user who owns the subscriptions. Although this parameter is optional, if you have the User ID you should pass it to improve performance.
* @param string $type (optional) The format for the Either 'mysql' or 'timestamp'.
* @return mixed If there is no future payment set, returns 0, otherwise it will return a date of the next payment in the form specified by $type
- * @since 1.2
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_next_payment_date( $subscription_key, $user_id = '', $type = 'mysql' ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscription::get_date( "next_payment" )' );
@@ -1314,8 +1398,8 @@ class WC_Subscriptions_Manager {
* @param int $user_id (optional) The ID of the user who owns the subscriptions. Although this parameter is optional, if you have the User ID you should pass it to improve performance.
* @param (optional) $next_payment string | int The date and time the next payment is due, either as MySQL formatted datetime string or a Unix timestamp. If empty, @see self::calculate_next_payment_date() will be called.
* @return mixed If there is no future payment set, returns 0, otherwise it will return a MySQL datetime formatted string for the date of the next payment
- * @since 1.2
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function set_next_payment_date( $subscription_key, $user_id = '', $next_payment = '' ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscription::update_dates( array( "next_payment" => $next_payment ) )' );
@@ -1336,8 +1420,8 @@ class WC_Subscriptions_Manager {
* @param int $user_id The ID of the user who owns the subscriptions. Although this parameter is optional, if you have the User ID you should pass it to improve performance.
* @param string $type (optional) The format for the Either 'mysql' or 'timestamp'.
* @return mixed If there is no future payment set, returns 0, otherwise it will return a date of the next payment in the form specified by $type
- * @since 1.2
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_last_payment_date( $subscription_key, $user_id = '', $type = 'mysql' ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscription::get_date( "last_payment" )' );
@@ -1352,8 +1436,8 @@ class WC_Subscriptions_Manager {
* @param string $subscription_key A subscription key of the form created by @see self::get_subscription_key()
* @param int $lock_time The amount of time to lock for in seconds from now, the lock will be set 1 hour before this time
* @param int $user_id (optional) The ID of the user who owns the subscriptions. Although this parameter is optional, if you have the User ID you should pass it to improve performance.
- * @since 1.2
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function update_wp_cron_lock( $subscription_key, $lock_time, $user_id = '' ) {
_deprecated_function( __METHOD__, '2.0' );
@@ -1366,8 +1450,8 @@ class WC_Subscriptions_Manager {
* @param int $user_id (optional) The ID of the user who owns the subscriptions. Although this parameter is optional, if you have the User ID you should pass it to improve performance.
* @param string $type (optional) The format for the Either 'mysql' or 'timestamp'.
* @return mixed If there is no future payment set, returns 0, otherwise it will return a date of the next payment of the type specified with $type
- * @since 1.2
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function calculate_next_payment_date( $subscription_key, $user_id = '', $type = 'mysql', $from_date = '' ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscription::calculate_date( "next_payment" )' );
@@ -1382,7 +1466,7 @@ class WC_Subscriptions_Manager {
* @param string $subscription_key A subscription key of the form created by @see self::get_subscription_key()
* @param int $user_id The ID of the user who owns the subscriptions. Although this parameter is optional, if you have the User ID you should pass it to improve performance.
* @return mixed If the subscription has no trial period, returns 0, otherwise it will return the date the trial period ends or ended in the form specified by $type
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function get_trial_expiration_date( $subscription_key, $user_id = '', $type = 'mysql' ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscription::get_date( "trial_end" )' );
@@ -1398,7 +1482,7 @@ class WC_Subscriptions_Manager {
* @param int $user_id (optional) The ID of the user who owns the subscription. Although this parameter is optional, if you have the User ID you should pass it to improve performance.
* @param (optional) $next_payment string | int The date and time the next payment is due, either as MySQL formatted datetime string or a Unix timestamp. If empty, @see self::calculate_next_payment_date() will be called.
* @return mixed If the trial expiration does not get set, returns false, otherwise it will return a MySQL datetime formatted string for the new date when the trial will expire
- * @since 1.2.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2.4
*/
public static function set_trial_expiration_date( $subscription_key, $user_id = '', $trial_expiration_date = '' ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscription::update_dates( array( "trial_end" => $expiration_date ) )' );
@@ -1416,7 +1500,7 @@ class WC_Subscriptions_Manager {
* @param string $subscription_key A subscription key of the form created by @see self::get_subscription_key()
* @param int $user_id The ID of the user who owns the subscriptions. Although this parameter is optional, if you have the User ID you should pass it to improve performance.
* @param string $type (optional) The format for the Either 'mysql' or 'timestamp'.
- * @since 1.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.1
*/
public static function calculate_trial_expiration_date( $subscription_key, $user_id = '', $type = 'mysql' ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscription::calculate_date( "trial_end" )' );
@@ -1431,7 +1515,7 @@ class WC_Subscriptions_Manager {
*
* @param string $subscription_key A subscription key of the form created by @see self::get_subscription_key()
* @return int The ID of the user who owns the subscriptions, or 0 if no user can be found with the subscription
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function get_user_id_from_subscription_key( $subscription_key ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscription::get_user_id()' );
@@ -1446,8 +1530,8 @@ class WC_Subscriptions_Manager {
* @param string $subscription_key A subscription key of the form created by @see self::get_subscription_key()
* @param int $user_id The ID of the user who owns the subscriptions. Although this parameter is optional, if you have the User ID you should pass it to improve performance.
* @return bool | null True if the subscription exists and requires manual payments, false if the subscription uses automatic payments, null if the subscription doesn't exist.
- * @since 1.2
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function requires_manual_renewal( $subscription_key, $user_id = '' ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscription::is_manual()' );
@@ -1460,7 +1544,7 @@ class WC_Subscriptions_Manager {
* @param string $subscription_key A subscription key of the form created by @see self::get_subscription_key()
* @param int $user_id The ID of the user who owns the subscriptions. Although this parameter is optional, if you have the User ID you should pass it to improve performance.
* @return bool True if the subscription has an unpaid renewal order, false if the subscription has no unpaid renewal orders.
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function subscription_requires_payment( $subscription_key, $user_id ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscription::needs_payment()' );
@@ -1480,8 +1564,8 @@ class WC_Subscriptions_Manager {
* @param string $subscription_key A subscription key of the form created by @see self::get_subscription_key()
* @param int $user_id (optional) int The ID of the user to check against. Defaults to the currently logged in user.
* @return bool True if the user has the subscription (or any subscription if no subscription specified), otherwise false.
- * @since 1.3
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.3
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function user_owns_subscription( $subscription_key, $user_id = 0 ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscriptions::get_user_id()' );
@@ -1508,7 +1592,7 @@ class WC_Subscriptions_Manager {
* @param product_id int (optional) The ID of a subscription product.
* @param status string (optional) A subscription status to check against. For example, for a $status of 'active', a subscriber must have an active subscription for a return value of true.
* @return bool True if the user has the subscription (or any subscription if no subscription specified), otherwise false.
- * @version 1.3.5
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v1.3.5
*/
public static function user_has_subscription( $user_id = 0, $product_id = '', $status = 'any' ) {
_deprecated_function( __METHOD__, '2.0', 'wcs_user_has_subscription()' );
@@ -1519,7 +1603,7 @@ class WC_Subscriptions_Manager {
* Gets all the active and inactive subscriptions for all users.
*
* @return array An associative array containing all users with subscriptions and the details of their subscriptions: 'user_id' => $subscriptions
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function get_all_users_subscriptions() {
_deprecated_function( __METHOD__, '2.0' );
@@ -1538,7 +1622,7 @@ class WC_Subscriptions_Manager {
*
* @param int $user_id (optional) The id of the user whose subscriptions you want. Defaults to the currently logged in user.
* @param array $order_ids (optional) An array of post_ids of WC_Order objects as a way to get only subscriptions for certain orders. Defaults to null, which will return subscriptions for all orders.
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function get_users_subscriptions( $user_id = 0, $order_ids = array() ) {
_deprecated_function( __METHOD__, '2.0', 'wcs_get_users_subscriptions( $user_id )' );
@@ -1556,7 +1640,7 @@ class WC_Subscriptions_Manager {
* Gets all the subscriptions for a user that have been trashed, as specified by $user_id
*
* @param int $user_id (optional) The id of the user whose subscriptions you want. Defaults to the currently logged in user.
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function get_users_trashed_subscriptions( $user_id = '' ) {
@@ -1575,8 +1659,8 @@ class WC_Subscriptions_Manager {
* A convenience wrapper to assign the inactive subscriber role to a user.
*
* @param int $user_id The id of the user whose role should be changed
- * @since 1.2
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function make_user_inactive( $user_id ) {
_deprecated_function( __METHOD__, '2.0', 'wcs_make_user_inactive()' );
@@ -1589,8 +1673,8 @@ class WC_Subscriptions_Manager {
* Hooked to 'subscription_end_of_prepaid_term' hook.
*
* @param int $user_id The id of the user whose role should be changed
- * @since 1.3.2
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.3.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function maybe_assign_user_cancelled_role( $user_id ) {
_deprecated_function( __METHOD__, '2.0', 'wcs_maybe_make_user_inactive()' );
@@ -1602,8 +1686,8 @@ class WC_Subscriptions_Manager {
*
* @param int $user_id The id of the user whose role should be changed
* @param string $role_name Either a WordPress role or one of the WCS keys: 'default_subscriber_role' or 'default_cancelled_role'
- * @since 1.0
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function update_users_role( $user_id, $role_name ) {
_deprecated_function( __METHOD__, '2.0', 'wcs_update_users_role()' );
@@ -1616,8 +1700,8 @@ class WC_Subscriptions_Manager {
* A wrapper for the @see woocommerce_paying_customer() function.
*
* @param int $order_id The id of the order for which customers should be pulled from and marked as paying.
- * @since 1.0
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function mark_paying_customer( $order ) {
_deprecated_function( __METHOD__, '2.0' );
@@ -1636,8 +1720,8 @@ class WC_Subscriptions_Manager {
* Deprecated as orders now take care of the customer's status as paying or not paying
*
* @param object $order The order for which a customer ID should be pulled from and marked as paying.
- * @since 1.0
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function mark_not_paying_customer( $order ) {
_deprecated_function( __METHOD__, '2.0' );
@@ -1655,8 +1739,8 @@ class WC_Subscriptions_Manager {
* Return a link for subscribers to change the status of their subscription, as specified with $status parameter
*
* @param string $subscription_key A subscription key of the form created by @see self::get_subscription_key()
- * @since 1.0
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_users_change_status_link( $subscription_key, $status ) {
_deprecated_function( __METHOD__, '2.0', 'wcs_get_users_change_status_link( $subscription_id, $status )' );
@@ -1684,8 +1768,8 @@ class WC_Subscriptions_Manager {
* @param string $subscription_key A subscription key of the form created by @see self::get_subscription_key()
* @param int $user_id The id of the user who purchased the subscription
* @param string $timezone Either 'server' or 'user' to describe the timezone of the $new_payment_date.
- * @since 1.2
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function update_next_payment_date( $new_payment_date, $subscription_key, $user_id = '', $timezone = 'server' ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscription::update_dates( array( "next_payment" => $new_payment_date ) )' );
@@ -1719,7 +1803,7 @@ class WC_Subscriptions_Manager {
/**
* Because neither PHP nor WP include a real array merge function that works recursively.
*
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function array_merge_recursive_for_real( $first_array, $second_array ) {
@@ -1745,7 +1829,7 @@ class WC_Subscriptions_Manager {
* Used mainly to calculate the recurring amount from a total which may also include a sign up fee.
*
* @param float $total The total amount
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
* @return float $proportion A proportion of the total (e.g. 0.5 is half of the total)
*/
public static function get_amount_from_proportion( $total, $proportion ) {
@@ -1775,8 +1859,8 @@ class WC_Subscriptions_Manager {
* 'subscription_length': The total number of periods the subscription should continue for. Default 0, meaning continue indefinitely.
* 'trial_length': The total number of periods the subscription trial period should continue for. Default 0, meaning no trial period.
* 'trial_period': The temporal period for the subscription's trial period. Should be one of {day|week|month|year} as used by @see self::get_subscription_period_strings()
- * @since 1.2
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
* @return float $proportion A proportion of the total (e.g. 0.5 is half of the total)
*/
public static function get_subscription_price_string( $subscription_details ) {
@@ -1796,7 +1880,7 @@ class WC_Subscriptions_Manager {
* 'include_time': (bool) whether to include a specific time for the selector. Default true.
* 'include_year': (bool) whether to include a the year field. Default true.
* 'include_buttons': (bool) whether to include submit buttons on the selector. Default true.
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function touch_time( $args = array() ) {
global $wp_locale;
@@ -1896,8 +1980,8 @@ class WC_Subscriptions_Manager {
*
* @param int $user_id The id of the user whose subscription should be put on-hold.
* @param string $subscription_key A subscription key of the form created by @see self::get_subscription_key()
- * @since 1.2.5
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2.5
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function maybe_put_subscription_on_hold( $user_id, $subscription_key ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscription::update_status()' );
@@ -1923,7 +2007,7 @@ class WC_Subscriptions_Manager {
* bug in upgrade process for 2.0.0 of Subscriptions (i.e. not 2.0.1 or newer). See WCS_Repair_2_0_2::maybe_repair_status() for more details.
*
* @param int $subscription_id The ID of a 'shop_subscription' post
- * @since 2.0.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.2
*/
public static function maybe_process_failed_renewal_for_repair( $subscription_id ) {
@@ -1962,8 +2046,8 @@ class WC_Subscriptions_Manager {
*
* @param int $user_id The id of the user who the subscription belongs to
* @param string $subscription_key A subscription key of the form created by @see self::get_subscription_key()
- * @since 1.3.2
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.3.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function maybe_process_subscription_payment( $user_id, $subscription_key ) {
_deprecated_function( __METHOD__, '2.0', __CLASS__ . '::prepare_renewal( $subscription_id )' );
@@ -1974,7 +2058,7 @@ class WC_Subscriptions_Manager {
* Return a link for subscribers to change the status of their subscription, as specified with $status parameter
*
* @param string $subscription_key A subscription key of the form created by @see self::get_subscription_key()
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function current_user_can_suspend_subscription( $subscription_key ) {
_deprecated_function( __METHOD__, '2.0', 'wcs_can_user_put_subscription_on_hold( $subscription, $user )' );
@@ -1989,8 +2073,8 @@ class WC_Subscriptions_Manager {
*
* @param string $search_query The query to search the database for.
* @return array Subscription details
- * @since 1.1
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.1
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function search_subscriptions( $search_query ) {
_deprecated_function( __METHOD__, '2.0', 'wcs_get_subscriptions()' );
@@ -2040,7 +2124,7 @@ class WC_Subscriptions_Manager {
*
* @param int $user_id The id of the user whose subscription is to be activated.
* @param string $subscription_key A subscription key of the form created by @see self::get_subscription_key()
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function activate_subscription( $user_id, $subscription_key ) {
_deprecated_function( __METHOD__, '2.0' );
@@ -2079,7 +2163,7 @@ class WC_Subscriptions_Manager {
*
* @param int $user_id The id of the user whose subscription is to be activated.
* @param string $subscription_key A subscription key of the form created by @see self::get_subscription_key()
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function reactivate_subscription( $user_id, $subscription_key ) {
_deprecated_function( __METHOD__, '2.0' );
@@ -2094,7 +2178,7 @@ class WC_Subscriptions_Manager {
*
* @param int $user_id The id of the user whose subscription should be put on-hold.
* @param string $subscription_key A subscription key of the form created by @see self::get_subscription_key()
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function put_subscription_on_hold( $user_id, $subscription_key ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscription::update_status( "on-hold" )' );
@@ -2129,7 +2213,7 @@ class WC_Subscriptions_Manager {
*
* @param int $user_id The id of the user whose subscription should be cancelled.
* @param string $subscription_key A subscription key of the form created by @see self::get_subscription_key()
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function cancel_subscription( $user_id, $subscription_key ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscriptions::cancel_order()' );
@@ -2162,7 +2246,7 @@ class WC_Subscriptions_Manager {
*
* @param int $user_id The id of the user whose subscription should be cancelled.
* @param string $subscription_key A subscription key of the form created by @see self::get_subscription_key()
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function failed_subscription_signup( $user_id, $subscription_key ) {
_deprecated_function( __METHOD__, '2.0' );
@@ -2192,7 +2276,7 @@ class WC_Subscriptions_Manager {
*
* @param int $user_id The ID of the user who the subscription belongs to
* @param string $subscription_key A subscription key of the form created by @see self::get_subscription_key()
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function trash_subscription( $user_id, $subscription_key ) {
_deprecated_function( __METHOD__, '2.0', 'wp_trash_post()' );
@@ -2229,7 +2313,7 @@ class WC_Subscriptions_Manager {
*
* @param int $user_id The ID of the user who the subscription belongs to
* @param string $subscription_key A subscription key of the form created by @see self::get_subscription_key()
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function delete_subscription( $user_id, $subscription_key ) {
_deprecated_function( __METHOD__, '2.0', 'wp_delete_post()' );
@@ -2263,8 +2347,8 @@ class WC_Subscriptions_Manager {
*
* Deprecated because editing a subscription's next payment date is now done from the Edit Subscription screen.
*
- * @since 1.2
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function ajax_update_next_payment_date() {
_deprecated_function( __METHOD__, '2.0', 'wp_delete_post()' );
@@ -2338,8 +2422,8 @@ class WC_Subscriptions_Manager {
*
* @param int $user_id The id of the user who purchased the subscription
* @param string $subscription_key A subscription key of the form created by @see self::get_subscription_key()
- * @since 1.1.2
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.1.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function safeguard_scheduled_payments( $user_id, $subscription_key ) {
_deprecated_function( __METHOD__, '2.0' );
@@ -2354,8 +2438,8 @@ class WC_Subscriptions_Manager {
*
* @param int $user_id The id of the user who the subscription belongs to
* @param string $subscription_key A subscription key of the form created by @see self::get_subscription_key()
- * @since 1.1.5
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.1.5
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function maybe_reschedule_subscription_payment( $user_id, $subscription_key ) {
_deprecated_function( __METHOD__, '2.0' );
@@ -2377,8 +2461,8 @@ class WC_Subscriptions_Manager {
* Fires when the trial period for a subscription has completed.
*
* @param int $subscription_id The ID of a 'shop_subscription' post
- * @since 1.0
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function subscription_trial_end( $subscription_id, $deprecated = null ) {
_deprecated_function( __METHOD__, '2.0' );
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-order.php b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-order.php
index 58245d0..172a31a 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-order.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-order.php
@@ -7,20 +7,9 @@
* @package WooCommerce Subscriptions
* @subpackage WC_Subscriptions_Order
* @category Class
- * @author Brent Shepherd
*/
class WC_Subscriptions_Order {
- /**
- * Store a record of which product/item IDs need to have subscriptions details updated
- * whenever a subscription is saved via the "Edit Order" page.
- */
- private static $requires_update = array(
- 'next_billing_date' => array(),
- 'trial_expiration' => array(),
- 'expiration_date' => array(),
- );
-
/**
* A flag to indicate whether subscription price strings should include the subscription length
*/
@@ -29,7 +18,7 @@ class WC_Subscriptions_Order {
/**
* Bootstraps the class and hooks required actions & filters.
*
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function init() {
@@ -88,7 +77,7 @@ class WC_Subscriptions_Order {
* line totals for each non-subscription product.
*
* @param mixed $order A WC_Order object or the ID of the order which the subscription was purchased in.
- * @since 1.5.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5.3
*/
public static function get_non_subscription_total( $order ) {
@@ -115,7 +104,7 @@ class WC_Subscriptions_Order {
* @param mixed $order A WC_Order object or the ID of the order which the subscription was purchased in.
* @param int $product_id (optional) The post ID of the subscription WC_Product object purchased in the order. Defaults to the ID of the first product purchased in the order.
* @return float The initial sign-up fee charged when the subscription product in the order was first purchased, if any.
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function get_sign_up_fee( $order, $product_id = '' ) {
@@ -150,7 +139,7 @@ class WC_Subscriptions_Order {
* This function checks if the 'product_id' field exists on an order item before falling back to 'id'.
*
* @param array $order_item An order item in the structure returned by WC_Order::get_items()
- * @since 1.2.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2.5
*/
public static function get_items_product_id( $order_item ) {
return ( isset( $order_item['product_id'] ) ) ? $order_item['product_id'] : $order_item['id'];
@@ -161,7 +150,7 @@ class WC_Subscriptions_Order {
*
* @param WC_Order|int $order The WC_Order object or ID of the order for which the meta should be sought.
* @param int $product_id The product/post ID of a subscription product.
- * @since 1.2.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2.5
*/
public static function get_item_by_product_id( $order, $product_id = '' ) {
@@ -183,7 +172,7 @@ class WC_Subscriptions_Order {
*
* @param WC_Order|int $order The WC_Order object or ID of the order for which the meta should be sought.
* @param int $product_id The product/post ID of a subscription product.
- * @since 1.2.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2.5
*/
public static function get_item_by_subscription_key( $subscription_key ) {
@@ -200,7 +189,7 @@ class WC_Subscriptions_Order {
*
* @param WC_Order|int $order The WC_Order object or ID of the order for which the meta should be sought.
* @param int $product_id The product/post ID of a subscription product.
- * @since 1.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4
*/
public static function get_item_id_by_subscription_key( $subscription_key ) {
global $wpdb;
@@ -226,7 +215,7 @@ class WC_Subscriptions_Order {
* @param WC_Order|int $order The WC_Order object or ID of the order for which the meta should be sought.
* @param int $item_id The product/post ID of a subscription. Option - if no product id is provided, the first item's meta will be returned
* @return array $item An array containing the order_item_id, order_item_name, order_item_type, order_id and any item_meta. Array structure matches that returned by WC_Order::get_items()
- * @since 1.2.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2.5
*/
public static function get_item_by_id( $order_item_id ) {
global $wpdb;
@@ -261,7 +250,7 @@ class WC_Subscriptions_Order {
* @param string $meta_key The key as stored in the post meta table for the meta item.
* @param int $product_id The product/post ID of a subscription. Option - if no product id is provided, we will loop through the order and find the subscription
* @param mixed $default (optional) The default value to return if the meta key does not exist. Default 0.
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function get_item_meta( $order, $meta_key, $product_id = '', $default = 0 ) {
@@ -292,7 +281,7 @@ class WC_Subscriptions_Order {
* set of parameters.
*
* @param int $meta_id The order item meta data ID of the item you want to get.
- * @since 1.2.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2.5
*/
public static function get_item_meta_data( $meta_id ) {
global $wpdb;
@@ -311,7 +300,7 @@ class WC_Subscriptions_Order {
*
* @param WC_Order|int $order The WC_Order object or ID of the order for which the meta should be sought.
* @param int $product_id The product/post ID of a subscription. Option - if no product id is provided, it is expected that only one item exists and the last item's meta will be returned
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function get_item_name( $order, $product_id = '' ) {
@@ -330,7 +319,7 @@ class WC_Subscriptions_Order {
*
* @param int $order_id
*
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function subscription_thank_you( $order_id ) {
if ( wcs_order_contains_subscription( $order_id, 'any' ) ) {
@@ -378,7 +367,7 @@ class WC_Subscriptions_Order {
* that can result in "requested URL's length exceeds the capacity limit" errors when bulk editing orders.
*
* @param string $column The string of the current column.
- * @since 1.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.1
*/
public static function add_contains_subscription_hidden_field( $column ) {
global $post;
@@ -394,7 +383,7 @@ class WC_Subscriptions_Order {
* in that row contains a subscription or not.
*
* @param string $column The string of the current column.
- * @since 1.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.1
*/
public static function contains_subscription_hidden_field( $order_id ) {
@@ -408,7 +397,7 @@ class WC_Subscriptions_Order {
* parent of a subscription, a renewal order for a subscription, or a regular order.
*
* @param array $columns The current list of columns
- * @since 2.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1
*/
public static function add_contains_subscription_column( $columns ) {
@@ -425,7 +414,7 @@ class WC_Subscriptions_Order {
* regular order.
*
* @param string $column The string of the current column
- * @since 2.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1
*/
public static function add_contains_subscription_column_content( $column ) {
global $post;
@@ -446,99 +435,103 @@ class WC_Subscriptions_Order {
/**
* Records the initial payment against a subscription.
*
- * This function is called when an orders status is changed to completed or processing
+ * This function is called when an order's status is changed to completed or processing
* for those gateways which never call @see WC_Order::payment_complete(), like the core
* WooCommerce Cheque and Bank Transfer gateways.
*
* It will also set the start date on the subscription to the time the payment is completed.
*
- * @param $order_id int|WC_Order
- * @param $old_order_status
- * @param $new_order_status
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
+ *
+ * @param int|WC_Order $order_id The order ID or WC_Order object.
+ * @param string $old_order_status The old order status.
+ * @param string $new_order_status The new order status.
*/
public static function maybe_record_subscription_payment( $order_id, $old_order_status, $new_order_status ) {
- if ( wcs_order_contains_subscription( $order_id, 'parent' ) ) {
+ if ( ! wcs_order_contains_subscription( $order_id, 'parent' ) ) {
+ return;
+ }
- $subscriptions = wcs_get_subscriptions_for_order( $order_id, array( 'order_type' => 'parent' ) );
- $was_activated = false;
- $order = wc_get_order( $order_id );
- $order_completed = in_array( $new_order_status, array( apply_filters( 'woocommerce_payment_complete_order_status', 'processing', $order_id, $order ), 'processing', 'completed' ) ) && in_array( $old_order_status, apply_filters( 'woocommerce_valid_order_statuses_for_payment', array( 'pending', 'on-hold', 'failed' ), $order ) );
+ $subscriptions = wcs_get_subscriptions_for_order( $order_id, array( 'order_type' => 'parent' ) );
+ $was_activated = false;
+ $order = wc_get_order( $order_id );
+ $paid_statuses = array( apply_filters( 'woocommerce_payment_complete_order_status', 'processing', $order_id, $order ), 'processing', 'completed' );
+ $unpaid_statuses = apply_filters( 'woocommerce_valid_order_statuses_for_payment', array( 'pending', 'on-hold', 'failed' ), $order );
+ $order_completed = in_array( $new_order_status, $paid_statuses, true ) && in_array( $old_order_status, $unpaid_statuses, true );
- foreach ( $subscriptions as $subscription ) {
- // A special case where payment completes after user cancels subscription
- if ( $order_completed && $subscription->has_status( 'cancelled' ) ) {
+ foreach ( $subscriptions as $subscription ) {
+ // A special case where payment completes after user cancels subscription
+ if ( $order_completed && $subscription->has_status( 'cancelled' ) ) {
- // Store the actual cancelled_date so as to restore it after it is rewritten by update_status()
- $cancelled_date = $subscription->get_date( 'cancelled' );
+ // Store the actual cancelled_date so as to restore it after it is rewritten by update_status()
+ $cancelled_date = $subscription->get_date( 'cancelled' );
- // Force set cancelled_date and end date to 0 temporarily so that next_payment_date can be calculated properly
- // This next_payment_date will be the end of prepaid term that will be picked by action scheduler
- $subscription->update_dates( array( 'cancelled' => 0, 'end' => 0 ) );
+ // Force set cancelled_date and end date to 0 temporarily so that next_payment_date can be calculated properly
+ // This next_payment_date will be the end of prepaid term that will be picked by action scheduler
+ $subscription->update_dates( array( 'cancelled' => 0, 'end' => 0 ) );
- $next_payment_date = $subscription->calculate_date( 'next_payment' );
- $subscription->update_dates( array( 'next_payment' => $next_payment_date ) );
+ $next_payment_date = $subscription->calculate_date( 'next_payment' );
+ $subscription->update_dates( array( 'next_payment' => $next_payment_date ) );
- $subscription->update_status( 'pending-cancel', __( 'Payment completed on order after subscription was cancelled.', 'woocommerce-subscriptions' ) );
+ $subscription->update_status( 'pending-cancel', __( 'Payment completed on order after subscription was cancelled.', 'woocommerce-subscriptions' ) );
- // Restore the actual cancelled date
- $subscription->update_dates( array( 'cancelled' => $cancelled_date ) );
- }
+ // Restore the actual cancelled date
+ $subscription->update_dates( array( 'cancelled' => $cancelled_date ) );
+ }
- // Do we need to activate a subscription?
- if ( $order_completed && ! $subscription->has_status( wcs_get_subscription_ended_statuses() ) && ! $subscription->has_status( 'active' ) ) {
+ // Do we need to activate a subscription?
+ if ( $order_completed && ! $subscription->has_status( wcs_get_subscription_ended_statuses() ) && ! $subscription->has_status( 'active' ) ) {
- $new_start_date_offset = current_time( 'timestamp', true ) - $subscription->get_time( 'start' );
+ $new_start_date_offset = current_time( 'timestamp', true ) - $subscription->get_time( 'start' );
- // if the payment has been processed more than an hour after the order was first created, let's update the dates on the subscription to account for that, because it may have even been processed days after it was first placed
- if ( abs( $new_start_date_offset ) > HOUR_IN_SECONDS ) {
+ // if the payment has been processed more than an hour after the order was first created, let's update the dates on the subscription to account for that, because it may have even been processed days after it was first placed
+ if ( abs( $new_start_date_offset ) > HOUR_IN_SECONDS ) {
- $dates = array( 'start' => current_time( 'mysql', true ) );
+ $dates = array( 'start' => current_time( 'mysql', true ) );
- if ( WC_Subscriptions_Synchroniser::subscription_contains_synced_product( $subscription ) ) {
+ if ( WC_Subscriptions_Synchroniser::subscription_contains_synced_product( $subscription ) ) {
- $trial_end = $subscription->get_time( 'trial_end' );
- $next_payment = $subscription->get_time( 'next_payment' );
+ $trial_end = $subscription->get_time( 'trial_end' );
+ $next_payment = $subscription->get_time( 'next_payment' );
- // if either there is a free trial date or a next payment date that falls before now, we need to recalculate all the sync'd dates
- if ( ( $trial_end > 0 && $trial_end < wcs_date_to_time( $dates['start'] ) ) || ( $next_payment > 0 && $next_payment < wcs_date_to_time( $dates['start'] ) ) ) {
+ // if either there is a free trial date or a next payment date that falls before now, we need to recalculate all the sync'd dates
+ if ( ( $trial_end > 0 && $trial_end < wcs_date_to_time( $dates['start'] ) ) || ( $next_payment > 0 && $next_payment < wcs_date_to_time( $dates['start'] ) ) ) {
- foreach ( $subscription->get_items() as $item ) {
- $product_id = wcs_get_canonical_product_id( $item );
+ foreach ( $subscription->get_items() as $item ) {
+ $product_id = wcs_get_canonical_product_id( $item );
- if ( WC_Subscriptions_Synchroniser::is_product_synced( $product_id ) ) {
- $dates['trial_end'] = WC_Subscriptions_Product::get_trial_expiration_date( $product_id, $dates['start'] );
- $dates['next_payment'] = WC_Subscriptions_Synchroniser::calculate_first_payment_date( $product_id, 'mysql', $dates['start'] );
- $dates['end'] = WC_Subscriptions_Product::get_expiration_date( $product_id, $dates['start'] );
- break;
- }
- }
- }
- } else {
- // No sync'ing to mess about with, just add the offset to the existing dates
- foreach ( array( 'trial_end', 'next_payment', 'end' ) as $date_type ) {
- if ( 0 != $subscription->get_time( $date_type ) ) {
- $dates[ $date_type ] = gmdate( 'Y-m-d H:i:s', $subscription->get_time( $date_type ) + $new_start_date_offset );
+ if ( WC_Subscriptions_Synchroniser::is_product_synced( $product_id ) ) {
+ $dates['trial_end'] = WC_Subscriptions_Product::get_trial_expiration_date( $product_id, $dates['start'] );
+ $dates['next_payment'] = WC_Subscriptions_Synchroniser::calculate_first_payment_date( $product_id, 'mysql', $dates['start'] );
+ $dates['end'] = WC_Subscriptions_Product::get_expiration_date( $product_id, $dates['start'] );
+ break;
}
}
}
-
- $subscription->update_dates( $dates );
+ } else {
+ // No sync'ing to mess about with, just add the offset to the existing dates
+ foreach ( array( 'trial_end', 'next_payment', 'end' ) as $date_type ) {
+ if ( 0 != $subscription->get_time( $date_type ) ) {
+ $dates[ $date_type ] = gmdate( 'Y-m-d H:i:s', $subscription->get_time( $date_type ) + $new_start_date_offset );
+ }
+ }
}
- $subscription->payment_complete_for_order( $order );
- $was_activated = true;
-
- } elseif ( 'failed' == $new_order_status ) {
- $subscription->payment_failed();
+ $subscription->update_dates( $dates );
}
- }
- if ( $was_activated ) {
- do_action( 'subscriptions_activated_for_order', $order_id );
+ $subscription->payment_complete_for_order( $order );
+ $was_activated = true;
+
+ } elseif ( 'failed' == $new_order_status ) {
+ $subscription->payment_failed();
}
}
+
+ if ( $was_activated ) {
+ do_action( 'subscriptions_activated_for_order', $order_id );
+ }
}
/* Order Price Getters */
@@ -548,7 +541,7 @@ class WC_Subscriptions_Order {
*
* @param WC_Order|int $order A WC_Order object or ID of a WC_Order order.
* @param array $item | int An array representing an order item or a product ID of an item in an order (not an order item ID)
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function is_item_subscription( $order, $order_item ) {
@@ -578,7 +571,7 @@ class WC_Subscriptions_Order {
* Returns all parent subscription orders for a user, specificed with $user_id
*
* @return array An array of order IDs.
- * @since 1.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4
*/
public static function get_users_subscription_orders( $user_id = 0 ) {
global $wpdb;
@@ -681,7 +674,7 @@ class WC_Subscriptions_Order {
/**
* Adds the subscription information to our order emails.
*
- * @since 1.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5
*/
public static function add_sub_info_email( $order, $is_admin_email, $plaintext = false ) {
@@ -708,7 +701,7 @@ class WC_Subscriptions_Order {
/**
* Add admin dropdown for order types to Woocommerce -> Orders screen
*
- * @since version 1.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5
*/
public static function restrict_manage_subscriptions() {
global $typenow;
@@ -748,7 +741,7 @@ class WC_Subscriptions_Order {
* Including or excluding posts with a '_subscription_renewal' meta value includes or excludes
* renewal orders, as required.
*
- * @since 1.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5
*/
public static function orders_by_type_query( $vars ) {
global $typenow, $wpdb;
@@ -812,7 +805,7 @@ class WC_Subscriptions_Order {
/**
* Add related subscriptions below order details tables.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function add_subscriptions_to_view_order_templates( $order_id ) {
@@ -835,7 +828,7 @@ class WC_Subscriptions_Order {
/**
* Loads the related orders table on the view subscription page
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_related_orders_template( $subscription ) {
@@ -857,7 +850,7 @@ class WC_Subscriptions_Order {
/**
* Unset pay action for an order if a more recent order exists
*
- * @since 2.2.9
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.9
*/
public static function maybe_remove_pay_action( $actions, $order ) {
@@ -879,7 +872,7 @@ class WC_Subscriptions_Order {
* Allow subscription order items to be edited in WC 2.2. until Subscriptions 2.0 introduces
* its own WC_Subscription object.
*
- * @since 1.5.10
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5.10
*/
public static function is_order_editable( $is_editable, $order ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscription::is_editable()' );
@@ -899,7 +892,7 @@ class WC_Subscriptions_Order {
* @param WC_Order $order A WC_Order object
* @param int $product_id The product/post ID of a subscription
* @return null|object A subscription from the order, either with an item to the product ID (if any) or just the first subscription purchase in the order.
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
private static function get_matching_subscription( $order, $product_id = '' ) {
@@ -937,7 +930,7 @@ class WC_Subscriptions_Order {
* @param WC_Order $order A WC_Order object
* @param int $product_id The product/post ID of a subscription
* @return array The line item for this product on the subscription object
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
private static function get_matching_subscription_item( $order, $product_id = '' ) {
@@ -957,7 +950,7 @@ class WC_Subscriptions_Order {
/**
* Don't display migrated subscription meta data on the Edit Order screen
*
- * @since 1.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4
*/
public static function hide_order_itemmeta( $hidden_meta_keys ) {
@@ -1011,7 +1004,7 @@ class WC_Subscriptions_Order {
*
* @param $order_id
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function maybe_cancel_subscription_on_full_refund( $order ) {
@@ -1039,8 +1032,8 @@ class WC_Subscriptions_Order {
*
* @param $order_id
*
- * @since 2.0
- * @deprecated 2.3.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.3
*/
public static function maybe_cancel_subscription_on_partial_refund( $order_id ) {
wcs_deprecated_function( __METHOD__, '2.3.3' );
@@ -1056,7 +1049,7 @@ class WC_Subscriptions_Order {
*
* @return bool $needs_shipping whether an order needs to display the shipping address
*
- * @since 2.0.14
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.14
*/
public static function maybe_display_shipping_address( $needs_shipping, $hidden_shipping_methods, $order ) {
$order_shipping_methods = $order->get_shipping_methods();
@@ -1089,7 +1082,7 @@ class WC_Subscriptions_Order {
*
* @return string $new_order_status
*
- * @since 2.1.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1.3
*/
public static function maybe_autocomplete_order( $new_order_status, $order_id, $order = null ) {
// Exit early if the order has no ID, or if the new order status is not 'processing'.
@@ -1164,7 +1157,7 @@ class WC_Subscriptions_Order {
/**
* Map subscription related order arguments passed to @see wc_get_orders() to WP_Query args.
*
- * @since 2.2.20
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.20
* @param array $query WP_Query arguments.
* @param array $args @see wc_get_orders() arguments.
* @return array The WP_Query query arguments.
@@ -1232,8 +1225,8 @@ class WC_Subscriptions_Order {
*
* @param mixed $order A WC_Order object or the ID of the order which the subscription was purchased in.
* @return bool True if the order contains a subscription, otherwise false.
- * @version 1.2
- * @since 1.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function order_contains_subscription( $order ) {
_deprecated_function( __METHOD__, '2.0', 'wcs_order_contains_subscription( $order )' );
@@ -1246,7 +1239,7 @@ class WC_Subscriptions_Order {
*
* With the advent of a separate subscription object in 2.0, this became unnecessary.
*
- * @since 1.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4
*/
public static function set_recurring_payment_method( $order_id ) {
_deprecated_function( __METHOD__, '2.0' );
@@ -1257,7 +1250,7 @@ class WC_Subscriptions_Order {
* to files purchased on the order.
*
* @return bool False if the order contains a subscription that has expired or is cancelled/on-hold, otherwise, the original value of $download_permitted
- * @since 1.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.3
*/
public static function is_download_permitted( $download_permitted, $order ) {
_deprecated_function( __METHOD__, '2.0' );
@@ -1271,8 +1264,8 @@ class WC_Subscriptions_Order {
* are stored against a 'shop_subscription' post, not the 'shop_order' used to purchase the subscription.
*
* @param item_id int An order_item_id as returned by the insert statement of @see woocommerce_add_order_item()
- * @since 1.2.5
- * @version 1.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2.5
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v1.4
* @return void
*/
public static function prefill_order_item_meta( $item, $item_id ) {
@@ -1287,7 +1280,7 @@ class WC_Subscriptions_Order {
* are stored against a 'shop_subscription' post, not the 'shop_order' used to purchase the subscription.
*
* Based on the @see woocommerce_calc_line_taxes() function.
- * @since 1.2.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2.4
* @return void
*/
public static function calculate_recurring_line_taxes() {
@@ -1332,7 +1325,7 @@ class WC_Subscriptions_Order {
* are stored against a 'shop_subscription' post, not the 'shop_order' used to purchase the subscription.
*
* @param int $post_id The post ID of the shop_order post object.
- * @since 1.2.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2.4
* @return void
*/
public static function recurring_order_totals_meta_box_section( $post_id ) {
@@ -1349,7 +1342,7 @@ class WC_Subscriptions_Order {
*
* @param int $post_id The ID of the post which is the WC_Order object.
* @param Object $post The post object of the order.
- * @since 1.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.1
*/
public static function pre_process_shop_order_meta( $post_id, $post ) {
_deprecated_function( __METHOD__, '2.0' );
@@ -1363,7 +1356,7 @@ class WC_Subscriptions_Order {
*
* @param int $post_id The ID of the post which is the WC_Order object.
* @param Object $post The post object of the order.
- * @since 1.2.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2.4
*/
public static function process_shop_order_item_meta( $post_id, $post ) {
_deprecated_function( __METHOD__, '2.0' );
@@ -1375,7 +1368,7 @@ class WC_Subscriptions_Order {
*
* @param mixed $order A WC_Order object or the ID of the order which the subscription was purchased in.
* @return bool True if the subscription exists and requires manual payments, false if the subscription uses automatic payments (defaults to false for backward compatibility).
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function requires_manual_renewal( $order ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscription::is_manual()' );
@@ -1400,7 +1393,7 @@ class WC_Subscriptions_Order {
*
* @param mixed $order A WC_Order object or the ID of the order which the subscription was purchased in.
* @return float The total initial amount charged when the subscription product in the order was first purchased, if any.
- * @since 1.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.1
*/
public static function get_total_initial_payment( $order, $product_id = '' ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Order::get_total()' );
@@ -1418,7 +1411,7 @@ class WC_Subscriptions_Order {
* @param WC_Order $order A WC_Order object
* @param int $product_id The product/post ID of a subscription
* @return float The total amount to be charged for each billing period, if any, not including failed payments.
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function get_item_recurring_amount( $order, $product_id ) {
_deprecated_function( __METHOD__, '2.0', 'the value for the item on the subscription object rather than the value on the original order. A line item can be deleted from a subscription since Subscriptions v2.0, so even if it exists on an order, it may not exist as a subscription. That means for accurate results, you must use the value on the subscription object' );
@@ -1438,7 +1431,7 @@ class WC_Subscriptions_Order {
* Returns the proportion of cart discount that is recurring for the product specified with $product_id
*
* @param WC_Order|int $order A WC_Order object or ID of a WC_Order order.
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function get_recurring_discount_cart( $order, $product_id = '' ) {
_deprecated_function( __METHOD__, '2.0', 'the value for the subscription object rather than the value on the original order. The value is stored against the subscription since Subscriptions v2.0 as an order can be used to create multiple different subscriptions with different discounts, so use the subscription object' );
@@ -1468,7 +1461,7 @@ class WC_Subscriptions_Order {
* Returns the proportion of cart discount tax that is recurring for the product specified with $product_id
*
* @param WC_Order|int $order A WC_Order object or ID of a WC_Order order.
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function get_recurring_discount_cart_tax( $order, $product_id = '' ) {
_deprecated_function( __METHOD__, '2.0', 'the value for the subscription object rather than the value on the original order. The value is stored against the subscription since Subscriptions v2.0 as an order can be used to create multiple different subscriptions with different discounts, so use the subscription object' );
@@ -1498,7 +1491,7 @@ class WC_Subscriptions_Order {
* Returns the proportion of total discount that is recurring for the product specified with $product_id
*
* @param WC_Order|int $order A WC_Order object or ID of a WC_Order order.
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function get_recurring_discount_total( $order, $product_id = '' ) {
_deprecated_function( __METHOD__, '2.0', 'the value for the subscription object rather than the value on the original order. The value is stored against the subscription since Subscriptions v2.0 as an order can be used to create multiple different subscriptions with different discounts, so use the subscription object' );
@@ -1544,7 +1537,7 @@ class WC_Subscriptions_Order {
* this is equal to @see WC_Order::get_total_tax()
*
* @param WC_Order|int $order A WC_Order object or ID of a WC_Order order.
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function get_recurring_shipping_tax_total( $order, $product_id = '' ) {
_deprecated_function( __METHOD__, '2.0', 'the value for the subscription object rather than the value on the original order. The value is stored against the subscription since Subscriptions v2.0 as an order can be used to create multiple different subscriptions with different amounts, so use the subscription object' );
@@ -1576,7 +1569,7 @@ class WC_Subscriptions_Order {
* equal to @see WC_Order::get_total_shipping()
*
* @param WC_Order|int $order A WC_Order object or ID of a WC_Order order.
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function get_recurring_shipping_total( $order, $product_id = '' ) {
_deprecated_function( __METHOD__, '2.0', 'the value for the subscription object rather than the value on the original order. The value is stored against the subscription since Subscriptions v2.0 as an order can be used to create multiple different subscriptions with different amounts, so use the subscription object' );
@@ -1623,7 +1616,7 @@ class WC_Subscriptions_Order {
* Returns an array of taxes on an order with their recurring totals.
*
* @param WC_Order|int $order A WC_Order object or ID of a WC_Order order.
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function get_recurring_taxes( $order ) {
_deprecated_function( __METHOD__, '2.0', 'the taxes for the subscription object rather than the original order. Taxes are stored against the subscription since Subscriptions v2.0 as an order can be used to create multiple different subscriptions with different taxes, so use the subscription object' );
@@ -1641,7 +1634,7 @@ class WC_Subscriptions_Order {
* Returns the proportion of total tax on an order that is recurring for the product specified with $product_id
*
* @param WC_Order|int $order A WC_Order object or ID of a WC_Order order.
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function get_recurring_total_tax( $order, $product_id = '' ) {
_deprecated_function( __METHOD__, '2.0', 'the value for the subscription object rather than the value on the original order. The value is stored against the subscription since Subscriptions v2.0 as an order can be used to create multiple different subscriptions with different amounts, so use the subscription object' );
@@ -1671,7 +1664,7 @@ class WC_Subscriptions_Order {
* Returns the proportion of total before tax on an order that is recurring for the product specified with $product_id
*
* @param WC_Order|int $order A WC_Order object or ID of a WC_Order order.
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function get_recurring_total_ex_tax( $order, $product_id = '' ) {
_deprecated_function( __METHOD__, '2.0', 'the value for the subscription object rather than the value on the original order. The value is stored against the subscription since Subscriptions v2.0 as an order can be used to create multiple different subscriptions with different amounts, so use the subscription object' );
@@ -1683,7 +1676,7 @@ class WC_Subscriptions_Order {
*
* @param mixed $order A WC_Order object or the ID of the order which the subscription was purchased in.
* @param int $product_id (optional) The post ID of the subscription WC_Product object purchased in the order. Defaults to the ID of the first product purchased in the order.
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function get_recurring_total( $order ) {
$recurring_total = 0;
@@ -1713,7 +1706,7 @@ class WC_Subscriptions_Order {
* @param WC_Order $order A WC_Order object.
* @param mixed $deprecated Never used.
* @param mixed $deprecated Never used.
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function get_order_subscription_string( $order, $deprecated_price = '', $deprecated_sign_up_fee = '' ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscription::get_formatted_order_total()' );
@@ -1729,7 +1722,7 @@ class WC_Subscriptions_Order {
* Returns an array of items in an order which are recurring along with their recurring totals.
*
* @param WC_Order|int $order A WC_Order object or ID of a WC_Order order.
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function get_recurring_items( $order ) {
_deprecated_function( __METHOD__, '2.0', 'the items on each individual subscription object (i.e. "shop_subscription")' );
@@ -1773,7 +1766,7 @@ class WC_Subscriptions_Order {
* @param mixed $order A WC_Order object or the ID of the order which the subscription was purchased in.
* @param int $product_id (optional) The post ID of the subscription WC_Product object purchased in the order. Defaults to the ID of the first product purchased in the order.
* @return string A string representation of the period for the subscription, i.e. day, week, month or year.
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function get_subscription_period( $order, $product_id = '' ) {
_deprecated_function( __METHOD__, '2.0', 'the billing period for each individual subscription object. Since Subscriptions v2.0, an order can be used to create multiple different subscriptions with different billing schedules, so use the subscription object' );
@@ -1808,7 +1801,7 @@ class WC_Subscriptions_Order {
* @param mixed $order A WC_Order object or the ID of the order which the subscription was purchased in.
* @param int $product_id (optional) The post ID of the subscription WC_Product object purchased in the order. Defaults to the ID of the first product purchased in the order.
* @return int The billing interval for a each subscription product in an order.
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function get_subscription_interval( $order, $product_id = '' ) {
_deprecated_function( __METHOD__, '2.0', 'the billing interval for each individual subscription object. Since Subscriptions v2.0, an order can be used to create multiple different subscriptions with different billing schedules, so use the subscription object' );
@@ -1843,7 +1836,7 @@ class WC_Subscriptions_Order {
* @param mixed $order A WC_Order object or the ID of the order which the subscription was purchased in.
* @param int $product_id (optional) The post ID of the subscription WC_Product object purchased in the order. Defaults to the ID of the first product purchased in the order.
* @return int The number of periods for which the subscription will recur. For example, a $5/month subscription for one year would return 12. A $10 every 3 month subscription for one year would also return 12.
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function get_subscription_length( $order, $product_id = '' ) {
_deprecated_function( __METHOD__, '2.0', 'the end date each individual subscription object. Since Subscriptions v2.0, an order can be used to create multiple different subscriptions with different billing schedules. The length of a subscription is also no longer stored against the subscription and instead, it is used simply to calculate the end date for the subscription when it is purchased. Therefore, you must use the end date of a subscription object' );
@@ -1860,7 +1853,7 @@ class WC_Subscriptions_Order {
* @param mixed $order A WC_Order object or the ID of the order which the subscription was purchased in.
* @param int $product_id (optional) The post ID of the subscription WC_Product object purchased in the order. Defaults to the ID of the first product purchased in the order.
* @return int The number of periods the trial period lasts for. For no trial, this will return 0, for a 3 period trial, it will return 3.
- * @since 1.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.1
*/
public static function get_subscription_trial_length( $order, $product_id = '' ) {
_deprecated_function( __METHOD__, '2.0', 'the first payment date for each individual subscription object. Since Subscriptions v2.0, an order can be used to create multiple different subscriptions with different billing schedules. The trial length of a subscription is also no longer stored against the subscription and instead, it is used simply to calculate the first payment date for the subscription when it is purchased. Therefore, you must use the first payment date of a subscription object' );
@@ -1877,7 +1870,7 @@ class WC_Subscriptions_Order {
* @param mixed $order A WC_Order object or the ID of the order which the subscription was purchased in.
* @param int $product_id (optional) The post ID of the subscription WC_Product object purchased in the order. Defaults to the ID of the first product purchased in the order.
* @return string A string representation of the period for the subscription, i.e. day, week, month or year.
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function get_subscription_trial_period( $order, $product_id = '' ) {
_deprecated_function( __METHOD__, '2.0', 'the billing period for each individual subscription object. Since Subscriptions v2.0, an order can be used to create multiple different subscriptions with different billing schedules. The trial period of a subscription is also no longer stored against the subscription and instead, it is used simply to calculate the first payment date for the subscription when it is purchased. Therefore, you must use the billing period of a subscription object' );
@@ -1894,8 +1887,8 @@ class WC_Subscriptions_Order {
* @param int $product_id The product/post ID of the subscription
* @param mixed $deprecated Never used.
* @return int If no more payments are due, returns 0, otherwise returns a timestamp of the date the next payment is due.
- * @version 1.2
- * @since 1.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function get_next_payment_timestamp( $order, $product_id, $deprecated = null ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscription::get_time( "next_payment" )' );
@@ -1920,8 +1913,8 @@ class WC_Subscriptions_Order {
* @param int $product_id The product/post ID of the subscription
* @param mixed $deprecated Never used.
* @return mixed If no more payments are due, returns 0, otherwise it returns the MySQL formatted date/time string for the next payment date.
- * @version 1.2
- * @since 1.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function get_next_payment_date( $order, $product_id, $deprecated = null ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscription::get_date( "next_payment" )' );
@@ -1946,8 +1939,8 @@ class WC_Subscriptions_Order {
* @param int $product_id The product/post ID of the subscription
* @param mixed $deprecated Never used.
* @return mixed If no more payments are due, returns 0, otherwise it returns the MySQL formatted date/time string for the next payment date.
- * @version 1.2.1
- * @since 1.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v1.2.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function get_last_payment_date( $order, $product_id ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscription::get_date( "last_payment" )' );
@@ -1980,7 +1973,7 @@ class WC_Subscriptions_Order {
* @param string $type (optional) The format for the Either 'mysql' or 'timestamp'.
* @param mixed $from_date A MySQL formatted date/time string from which to calculate the next payment date, or empty (default), which will use the last payment on the subscription, or today's date/time if no previous payments have been made.
* @return mixed If there is no future payment set, returns 0, otherwise it will return a date of the next payment in the form specified by $type
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function calculate_next_payment_date( $order, $product_id, $type = 'mysql', $from_date = '' ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscription::calculate_date( "next_payment" )' );
@@ -2005,7 +1998,7 @@ class WC_Subscriptions_Order {
* @param WC_Order $order The WC_Order object of the order for which you want to determine the number of failed payments.
* @param product_id int The ID of the subscription product.
* @return string The key representing the given subscription.
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function get_failed_payment_count( $order, $product_id ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscription::get_failed_payment_count()' );
@@ -2028,7 +2021,7 @@ class WC_Subscriptions_Order {
* @param WC_Order $order The WC_Order object of the order for which you want to determine the number of failed payments.
* @param product_id int The ID of the subscription product.
* @return string The key representing the given subscription.
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function get_outstanding_balance( $order, $product_id ) {
_deprecated_function( __METHOD__, '2.0' );
@@ -2045,7 +2038,7 @@ class WC_Subscriptions_Order {
*
* @param int $user_id The id of the user who purchased the subscription
* @param string $subscription_key A subscription key of the form created by @see WC_Subscriptions_Manager::get_subscription_key()
- * @since 1.1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.1.2
*/
public static function safeguard_scheduled_payments( $order_id ) {
_deprecated_function( __METHOD__, '2.0' );
@@ -2054,7 +2047,7 @@ class WC_Subscriptions_Order {
/**
* Appends the subscription period/duration string to order total
*
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function get_formatted_line_total( $formatted_total, $item, $order ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscription::get_formatted_line_subtotal()' );
@@ -2064,7 +2057,7 @@ class WC_Subscriptions_Order {
/**
* Appends the subscription period/duration string to order subtotal
*
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function get_subtotal_to_display( $subtotal, $compound, $order ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscription::get_subtotal_to_display()' );
@@ -2074,7 +2067,7 @@ class WC_Subscriptions_Order {
/**
* Appends the subscription period/duration string to order total
*
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function get_cart_discount_to_display( $discount, $order ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscription::get_discount_to_display()' );
@@ -2084,7 +2077,7 @@ class WC_Subscriptions_Order {
/**
* Appends the subscription period/duration string to order total
*
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function get_order_discount_to_display( $discount, $order ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscription::get_discount_to_display()' );
@@ -2094,7 +2087,7 @@ class WC_Subscriptions_Order {
/**
* Appends the subscription period/duration string to order total
*
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function get_formatted_order_total( $formatted_total, $order ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscription::get_formatted_order_total()' );
@@ -2104,7 +2097,7 @@ class WC_Subscriptions_Order {
/**
* Appends the subscription period/duration string to shipping fee
*
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function get_shipping_to_display( $shipping_to_display, $order ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscription::get_shipping_to_display()' );
@@ -2114,7 +2107,7 @@ class WC_Subscriptions_Order {
/**
* Individual totals are taken care of by filters, but taxes and fees are not, so we need to override them here.
*
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function get_order_item_totals( $total_rows, $order ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscription::get_order_item_totals()' );
@@ -2124,7 +2117,7 @@ class WC_Subscriptions_Order {
/**
* Load Subscription related order data when populating an order
*
- * @since 1.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4
*/
public static function load_order_data( $order_data ) {
_deprecated_function( __METHOD__, '2.0' );
@@ -2134,7 +2127,7 @@ class WC_Subscriptions_Order {
/**
* Add request filter for order types to Woocommerce -> Orders screen
*
- * @since version 1.5.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5.4
*/
public static function order_shipping_method( $shipping_method, $order ) {
_deprecated_function( __METHOD__, '2.0' );
@@ -2146,8 +2139,8 @@ class WC_Subscriptions_Order {
*
* @param WC_Order $order A WC_Order object
* @param int $product_id The product/post ID of a subscription
- * @since 1.2
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_item_sign_up_fee( $order, $product_id = '' ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscription::get_items_sign_up_fee() or WC_Subscriptions_Order::get_sign_up_fee()' );
@@ -2165,8 +2158,8 @@ class WC_Subscriptions_Order {
* It will also set the start date on the subscription to the time the payment is completed.
*
* @param WC_Order|int $order A WC_Order object or ID of a WC_Order order.
- * @since 1.1.2
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.1.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function maybe_record_order_payment( $order ) {
_deprecated_function( __METHOD__, '2.0', __CLASS__ . 'maybe_record_subscription_payment::( $order, $old_status, $new_status )' );
@@ -2189,8 +2182,8 @@ class WC_Subscriptions_Order {
/**
* Wrapper around @see WC_Order::get_order_currency() for versions of WooCommerce prior to 2.1.
*
- * @since version 1.4.9
- * @deprecated 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4.9
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
public static function get_order_currency( $order ) {
_deprecated_function( __METHOD__, '2.2.0', 'wcs_get_objects_property( $order, "currency" ) or $order->get_currency()' );
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-product.php b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-product.php
index ba6ac10..a4da83e 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-product.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-product.php
@@ -8,7 +8,7 @@
* @subpackage WC_Subscriptions_Product
* @category Class
* @author Brent Shepherd
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
class WC_Subscriptions_Product {
@@ -28,7 +28,7 @@ class WC_Subscriptions_Product {
/**
* Set up the class, including it's hooks & filters, when the file is loaded.
*
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
**/
public static function init() {
@@ -94,7 +94,7 @@ class WC_Subscriptions_Product {
* When the received arg is a product object, make sure it is passed into the filter intact in order to retain any properties added on the fly.
*
* @param int|WC_Product $product Either a product object or product's post ID.
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function is_subscription( $product ) {
@@ -118,7 +118,7 @@ class WC_Subscriptions_Product {
* Output subscription string as the price html for grouped products and make sure that
* sign-up fees are taken into account for price.
*
- * @since 1.3.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.3.4
*/
public static function get_grouped_price_html( $price, $grouped_product ) {
@@ -180,7 +180,7 @@ class WC_Subscriptions_Product {
/**
* Output subscription string in Gravity Form fields.
*
- * @since 1.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.1
*/
public static function get_gravity_form_prices( $price, $product ) {
@@ -210,7 +210,7 @@ class WC_Subscriptions_Product {
* 'subscription_length' => true to include subscription's length (default) or false to exclude it
* 'sign_up_fee' => true to include subscription's sign up fee (default) or false to exclude it
* 'price' => string a price to short-circuit the price calculations and use in a string for the product
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function get_price_string( $product, $include = array() ) {
global $wp_locale;
@@ -410,7 +410,7 @@ class WC_Subscriptions_Product {
*
* @param mixed $product A WC_Product object or product ID
* @return string The price charged per period for the subscription, or an empty string if the product is not a subscription.
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function get_price( $product ) {
$product = self::maybe_get_product_instance( $product );
@@ -437,7 +437,7 @@ class WC_Subscriptions_Product {
*
* @param mixed $product A WC_Product object or product ID
* @return string
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
public static function get_regular_price( $product, $context = 'view' ) {
@@ -455,7 +455,7 @@ class WC_Subscriptions_Product {
*
* @param mixed $product A WC_Product object or product ID
* @return string
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
public static function get_sale_price( $product, $context = 'view' ) {
@@ -473,7 +473,7 @@ class WC_Subscriptions_Product {
*
* @param mixed $product A WC_Product object or product ID
* @return string A string representation of the period, either Day, Week, Month or Year, or an empty string if product is not a subscription.
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function get_period( $product ) {
return apply_filters( 'woocommerce_subscriptions_product_period', self::get_meta_data( $product, 'subscription_period', '' ), self::maybe_get_product_instance( $product ) );
@@ -484,7 +484,7 @@ class WC_Subscriptions_Product {
*
* @param mixed $product A WC_Product object or product ID
* @return int An integer representing the subscription interval, or 1 if the product is not a subscription or there is no interval
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function get_interval( $product ) {
return apply_filters( 'woocommerce_subscriptions_product_period_interval', self::get_meta_data( $product, 'subscription_period_interval', 1, 'use_default_value' ), self::maybe_get_product_instance( $product ) );
@@ -495,7 +495,7 @@ class WC_Subscriptions_Product {
*
* @param mixed $product A WC_Product object or product ID
* @return int An integer representing the length of the subscription, or 0 if the product is not a subscription or the subscription continues for perpetuity
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function get_length( $product ) {
return apply_filters( 'woocommerce_subscriptions_product_length', self::get_meta_data( $product, 'subscription_length', 0, 'use_default_value' ), self::maybe_get_product_instance( $product ) );
@@ -506,7 +506,7 @@ class WC_Subscriptions_Product {
*
* @param mixed $product A WC_Product object or product ID
* @return int An integer representing the length of the subscription trial, or 0 if the product is not a subscription or there is no trial
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function get_trial_length( $product ) {
return apply_filters( 'woocommerce_subscriptions_product_trial_length', self::get_meta_data( $product, 'subscription_trial_length', 0, 'use_default_value' ), self::maybe_get_product_instance( $product ) );
@@ -517,7 +517,7 @@ class WC_Subscriptions_Product {
*
* @param mixed $product A WC_Product object or product ID
* @return string A string representation of the period, either Day, Week, Month or Year, or an empty string if product is not a subscription or there is no trial
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function get_trial_period( $product ) {
return apply_filters( 'woocommerce_subscriptions_product_trial_period', self::get_meta_data( $product, 'subscription_trial_period', '' ), self::maybe_get_product_instance( $product ) );
@@ -528,7 +528,7 @@ class WC_Subscriptions_Product {
*
* @param mixed $product A WC_Product object or product ID
* @return int|string The value of the sign-up fee, or 0 if the product is not a subscription or the subscription has no sign-up fee
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function get_sign_up_fee( $product ) {
return apply_filters( 'woocommerce_subscriptions_product_sign_up_fee', self::get_meta_data( $product, 'subscription_sign_up_fee', 0, 'use_default_value' ), self::maybe_get_product_instance( $product ) );
@@ -542,7 +542,7 @@ class WC_Subscriptions_Product {
* @param mixed $from_date A MySQL formatted date/time string from which to calculate the expiration date, or empty (default), which will use today's date/time.
* @param string $type The return format for the date, either 'mysql', or 'timezone'. Default 'mysql'.
* @param string $timezone The timezone for the returned date, either 'site' for the site's timezone, or 'gmt'. Default, 'site'.
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_first_renewal_payment_date( $product, $from_date = '', $timezone = 'gmt' ) {
@@ -565,7 +565,7 @@ class WC_Subscriptions_Product {
* @param mixed $from_date A MySQL formatted date/time string from which to calculate the expiration date, or empty (default), which will use today's date/time.
* @param string $type The return format for the date, either 'mysql', or 'timezone'. Default 'mysql'.
* @param string $timezone The timezone for the returned date, either 'site' for the site's timezone, or 'gmt'. Default, 'site'.
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_first_renewal_payment_time( $product, $from_date = '', $timezone = 'gmt' ) {
@@ -614,7 +614,7 @@ class WC_Subscriptions_Product {
*
* @param int|WC_Product $product The product instance or product/post ID of a subscription product.
* @param mixed $from_date A MySQL formatted date/time string from which to calculate the expiration date, or empty (default), which will use today's date/time.
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function get_expiration_date( $product, $from_date = '' ) {
@@ -648,7 +648,7 @@ class WC_Subscriptions_Product {
*
* @param int|WC_Product $product The product instance or product/post ID of a subscription product.
* @param mixed $from_date A MySQL formatted date/time string from which to calculate the expiration date (in UTC timezone), or empty (default), which will use today's date/time (in UTC timezone).
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function get_trial_expiration_date( $product, $from_date = '' ) {
@@ -677,7 +677,7 @@ class WC_Subscriptions_Product {
* WC_Product_Variation class).
*
* @return string $classname The name of the WC_Product_* class which should be instantiated to create an instance of this product.
- * @since 1.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.3
*/
public static function set_subscription_variation_class( $classname, $product_type, $post_type, $product_id ) {
@@ -702,7 +702,7 @@ class WC_Subscriptions_Product {
* Ensures a price is displayed for subscription variation where WC would normally ignore it (i.e. when prices are equal).
*
* @return array $variation_details Set of name/value pairs representing the subscription.
- * @since 1.3.6
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.3.6
*/
public static function maybe_set_variations_price_html( $variation_details, $variable_product, $variation ) {
@@ -719,7 +719,7 @@ class WC_Subscriptions_Product {
* Those with appropriate capabilities can still trash the product, but they will not be able to permanently
* delete the product if it is associated with an order (i.e. been purchased).
*
- * @since 1.4.9
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4.9
*/
public static function user_can_not_delete_subscription( $allcaps, $caps, $args ) {
global $wpdb;
@@ -754,7 +754,7 @@ class WC_Subscriptions_Product {
*
* @return array $actions Array of actions that can be performed on the post.
* @return array $post Array of post values for the current product (or post object if it is not a product).
- * @since 1.4.9
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4.9
*/
public static function subscription_row_actions( $actions, $post ) {
global $the_product;
@@ -782,7 +782,7 @@ class WC_Subscriptions_Product {
* deletion (or get any more detailed information about which item can't be deleted and why).
*
* @return array $actions Array of actions that can be performed on the post.
- * @since 1.4.9
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4.9
*/
public static function subscription_bulk_actions( $actions ) {
@@ -796,7 +796,7 @@ class WC_Subscriptions_Product {
*
* @param mixed $product A WC_Product object or product ID
* @return bool True if the product requires only one time shipping, false otherwise.
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
public static function needs_one_time_shipping( $product ) {
$product = self::maybe_get_product_instance( $product );
@@ -814,7 +814,7 @@ class WC_Subscriptions_Product {
* purged from the trash. We want to make sure Subscriptions products are not automatically purged (but still want
* to keep a record of when the product was trashed).
*
- * @since 1.4.9
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4.9
*/
public static function prevent_scheduled_deletion() {
global $wpdb;
@@ -838,7 +838,7 @@ class WC_Subscriptions_Product {
* request will either terminate or in the case of bulk deleting, the variation's ID will be removed
* from the $_POST.
*
- * @since 1.4.9
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4.9
*/
public static function remove_variations() {
@@ -884,7 +884,7 @@ class WC_Subscriptions_Product {
* @param array $data An array of data relating to the bulk edit action. $data['value'] represents the new value for the meta.
* @param int $variable_product_id The post ID of the parent variable product.
* @param array $variation_ids An array of post IDs for the variable prodcut's variations.
- * @since 1.5.29
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5.29
*/
public static function bulk_edit_variations( $bulk_action, $data, $variable_product_id, $variation_ids ) {
if ( 'delete_all_no_subscriptions' === $bulk_action && isset( $data['allowed'] ) && 'true' == $data['allowed'] ) {
@@ -959,7 +959,7 @@ class WC_Subscriptions_Product {
* @param int $loop Position of the variation inside the variations loop.
* @param array $variation_data Array of variation data.
* @param WP_Post $variation The variation's WP post.
- * @since 2.2.17
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.17
*/
public static function add_variation_removal_flag( $loop, $variation_data, $variation ) {
@@ -983,7 +983,7 @@ class WC_Subscriptions_Product {
* Processes an AJAX request to check if a product has a variation which is either sync'd or has a trial.
* Once at least one variation with a trial or sync date is found, this will terminate and return true, otherwise false.
*
- * @since 2.0.18
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.18
*/
public static function check_product_variations_for_syncd_or_trial() {
@@ -1024,7 +1024,7 @@ class WC_Subscriptions_Product {
* This function, triggered after saving variations or triggering the trial length bulk action, ensures one time shipping settings
* are updated after determining if one time shipping is still available to the product.
*
- * @since 2.0.18
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.18
*/
public static function maybe_update_one_time_shipping_on_variation_edits() {
@@ -1048,7 +1048,7 @@ class WC_Subscriptions_Product {
*
* @param mixed $product A WC_Product object or product ID
* @return WC_Product
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
private static function maybe_get_product_instance( $product ) {
@@ -1067,7 +1067,7 @@ class WC_Subscriptions_Product {
* @param mixed $default_value The value to return if the meta doesn't exist or isn't set
* @param string $empty_handling (optional) How empty values should be handled -- can be 'use_default_value' or 'allow_empty'. Defaults to 'allow_empty' returning the empty value.
* @return mixed
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
public static function get_meta_data( $product, $meta_key, $default_value, $empty_handling = 'allow_empty' ) {
@@ -1101,7 +1101,7 @@ class WC_Subscriptions_Product {
* sync variable product min/max prices with WC 3.0
*
* @param WC_Product_Variable $product
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
public static function variable_subscription_product_sync( $product ) {
@@ -1150,7 +1150,7 @@ class WC_Subscriptions_Product {
*
* @param WC_Product The product object to get parents from.
* @return array Parent IDs
- * @since 2.2.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.4
*/
public static function get_parent_ids( $product ) {
global $wpdb;
@@ -1177,7 +1177,7 @@ class WC_Subscriptions_Product {
*
* @param WC_Product The product object to get parents from.
* @return array The product's grouped parent IDs.
- * @since 2.3.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.0
*/
public static function get_visible_grouped_parent_product_ids( $product ) {
$parent_product_ids = self::get_parent_ids( $product );
@@ -1197,7 +1197,7 @@ class WC_Subscriptions_Product {
/**
* Gets the add to cart text for subscription products.
*
- * @since 3.0.7
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.0.7
* @return string The add to cart text.
*/
public static function get_add_to_cart_text() {
@@ -1207,7 +1207,7 @@ class WC_Subscriptions_Product {
/**
* Validates an ajax request to delete a subscription variation.
*
- * @since 3.x.x
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.x.x
*/
public static function validate_variation_deletion() {
check_admin_referer( 'wc_subscriptions_admin', 'nonce' );
@@ -1225,8 +1225,8 @@ class WC_Subscriptions_Product {
/**
* Override the WooCommerce "Add to cart" text with "Sign up now".
*
- * @since 1.0
- * @deprecated 3.0.7
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v3.0.7
*/
public static function add_to_cart_text( $button_text, $product_type = '' ) {
_deprecated_function( __METHOD__, '3.0.7', 'WC_Subscriptions_Product::get_add_to_cart_text' );
@@ -1243,7 +1243,7 @@ class WC_Subscriptions_Product {
* If a product is being marked as not purchasable because it is limited and the customer has a subscription,
* but the current request is to resubscribe to the subscription, then mark it as purchasable.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
* @return bool
*/
public static function is_purchasable( $is_purchasable, $product ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-renewal-order.php b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-renewal-order.php
index 6f6e0dd..0b2fe14 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-renewal-order.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-renewal-order.php
@@ -8,14 +8,14 @@
* @subpackage WC_Subscriptions_Order
* @category Class
* @author Brent Shepherd
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
class WC_Subscriptions_Renewal_Order {
/**
* Bootstraps the class and hooks required actions & filters.
*
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function init() {
@@ -39,7 +39,7 @@ class WC_Subscriptions_Renewal_Order {
/**
* Trigger a special hook for payments on a completed renewal order.
*
- * @since 1.5.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5.4
*/
public static function trigger_renewal_payment_complete( $order_id ) {
if ( wcs_order_contains_renewal( $order_id ) ) {
@@ -50,16 +50,28 @@ class WC_Subscriptions_Renewal_Order {
/**
* Check if a given renewal order was created to replace a failed renewal order.
*
- * @since 1.5.12
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5.12
* @param int ID of the renewal order you want to check against
* @return mixed If the renewal order did replace a failed order, the ID of the fail order, else false
*/
public static function get_failed_order_replaced_by( $renewal_order_id ) {
- global $wpdb;
- $failed_order_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_failed_order_replaced_by' AND meta_value = %s", $renewal_order_id ) );
+ // Get orders where order meta '_failed_order_replaced_by' = $renewal_order_id
+ $failed_orders = wcs_get_orders_with_meta_query(
+ [
+ 'limit' => 1,
+ 'return' => 'ids',
+ 'meta_query' => [ // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
+ [
+ 'key' => '_failed_order_replaced_by',
+ 'compare' => '=',
+ 'value' => $renewal_order_id,
+ ],
+ ],
+ ]
+ );
- return ( null === $failed_order_id ) ? false : $failed_order_id;
+ return $failed_orders[0] ?? false;
}
/**
@@ -69,7 +81,7 @@ class WC_Subscriptions_Renewal_Order {
* subscriptions are updated even if payment is processed by a manual payment gateways (which would never trigger the
* 'woocommerce_payment_complete' hook) or by some other means that circumvents that hook.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function maybe_record_subscription_payment( $order_id, $orders_old_status, $orders_new_status ) {
@@ -141,7 +153,7 @@ class WC_Subscriptions_Renewal_Order {
*
* @param WC_Order|int $renewal_order
* @param WC_Subscription|int $subscription
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function add_order_note( $renewal_order, $subscription ) {
if ( ! is_object( $subscription ) ) {
@@ -167,7 +179,7 @@ class WC_Subscriptions_Renewal_Order {
/**
* Do not allow customers to cancel renewal orders.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function prevent_cancelling_renewal_orders() {
if ( isset( $_GET['cancel_order'] ) && isset( $_GET['order'] ) && isset( $_GET['order_id'] ) ) {
@@ -191,7 +203,7 @@ class WC_Subscriptions_Renewal_Order {
/**
* Removes switch line item meta data so it isn't copied to renewal order line items
*
- * @since 2.0.16
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.16
* @param array $order_items
* @return array $order_items
*/
@@ -228,8 +240,8 @@ class WC_Subscriptions_Renewal_Order {
*
* @param int $user_id The id of the user who purchased the subscription
* @param string $subscription_key A subscription key of the form created by @see WC_Subscriptions_Manager::get_subscription_key()
- * @since 1.2
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function generate_paid_renewal_order( $user_id, $subscription_key ) {
_deprecated_function( __METHOD__, '2.0', 'wcs_create_renewal_order( WC_Subscription $subscription )' );
@@ -247,8 +259,8 @@ class WC_Subscriptions_Renewal_Order {
*
* @param int $user_id The id of the user who purchased the subscription
* @param string $subscription_key A subscription key of the form created by @see WC_Subscriptions_Manager::get_subscription_key()
- * @since 1.2
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function generate_failed_payment_renewal_order( $user_id, $subscription_key ) {
_deprecated_function( __METHOD__, '2.0', 'wcs_create_renewal_order( WC_Subscription $subscription )' );
@@ -268,7 +280,7 @@ class WC_Subscriptions_Renewal_Order {
*
* @param int $user_id The id of the user who purchased the subscription
* @param string $subscription_key A subscription key of the form created by @see WC_Subscriptions_Manager::get_subscription_key()
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function maybe_generate_manual_renewal_order( $user_id, $subscription_key ) {
_deprecated_function( __METHOD__, '2.0', __CLASS__ . '::maybe_create_manual_renewal_order( WC_Subscription $subscription )' );
@@ -282,8 +294,8 @@ class WC_Subscriptions_Renewal_Order {
* parent order.
*
* @param WC_Order|int $order The WC_Order object or ID of a WC_Order order.
- * @since 1.2
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_parent_order_id( $renewal_order ) {
_deprecated_function( __METHOD__, '2.0', 'wcs_get_subscriptions_for_renewal_order()' );
@@ -300,8 +312,8 @@ class WC_Subscriptions_Renewal_Order {
* parent order.
*
* @param WC_Order|int $order The WC_Order object or ID of a WC_Order order.
- * @since 1.2
- * @deprecated 2.0 self::get_parent_subscription() is the better function to use now as a renewal order
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0, self::get_parent_subscription() is the better function to use now as a renewal order
*/
public static function get_parent_order( $renewal_order ) {
_deprecated_function( __METHOD__, '2.0', 'wcs_get_subscriptions_for_renewal_order()' );
@@ -326,8 +338,8 @@ class WC_Subscriptions_Renewal_Order {
* Returns the number of renewals for a given parent order
*
* @param int $order_id The ID of a WC_Order object.
- * @since 1.2
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_renewal_order_count( $order_id ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscription::get_related_orders()' );
@@ -358,8 +370,8 @@ class WC_Subscriptions_Renewal_Order {
* Deprecated because the use of a $subscription_key is deprecated.
*
* @param string $subscription_key A subscription key of the form created by @see WC_Subscriptions_Manager::get_subscription_key()
- * @since 1.2
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_users_renewal_link( $subscription_key, $role = 'parent' ) {
_deprecated_function( __METHOD__, '2.0', 'wcs_get_users_resubscribe_link( $subscription )' );
@@ -372,8 +384,8 @@ class WC_Subscriptions_Renewal_Order {
* Deprecated because the use of a $subscription_key is deprecated.
*
* @param string $subscription_key A subscription key of the form created by @see WC_Subscriptions_Manager::get_subscription_key()
- * @since 1.2
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_users_renewal_link_for_product( $product_id ) {
_deprecated_function( __METHOD__, '2.0', 'wcs_get_users_resubscribe_link_for_product( $subscription )' );
@@ -387,8 +399,8 @@ class WC_Subscriptions_Renewal_Order {
*
* @param string $subscription_key A subscription key of the form created by @see WC_Subscriptions_Manager::get_subscription_key()
* @param int $user_id The ID of the user who owns the subscriptions. Although this parameter is optional, if you have the User ID you should pass it to improve performance.
- * @since 1.2
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function can_subscription_be_renewed( $subscription_key, $user_id = '' ) {
_deprecated_function( __METHOD__, '2.0', 'wcs_can_user_resubscribe_to( $subscription, $user_id )' );
@@ -399,8 +411,8 @@ class WC_Subscriptions_Renewal_Order {
* Checks if the current request is by a user to renew their subscription, and if it is
* set up a subscription renewal via the cart for the product/variation that is being renewed.
*
- * @since 1.2
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function maybe_create_renewal_order_for_user() {
_deprecated_function( __METHOD__, '2.0', 'WCS_Cart_Renewal::maybe_setup_resubscribe_via_cart()' );
@@ -411,8 +423,8 @@ class WC_Subscriptions_Renewal_Order {
* a subscription renewal, do not adjust the price because the original order's price will
* be used, and this includes the addons amounts.
*
- * @since 1.5.5
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5.5
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function product_addons_adjust_price( $adjust_price, $cart_item ) {
_deprecated_function( __METHOD__, '2.0', 'WCS_Cart_Renewal::product_addons_adjust_price()' );
@@ -427,8 +439,8 @@ class WC_Subscriptions_Renewal_Order {
* 'new_order_role' string A flag to indicate whether the new order should become the master order for the subscription. Accepts either 'parent' or 'child'. Defaults to 'parent' - replace the existing order.
* 'checkout_renewal' bool Indicates if invoked from an interactive cart/checkout session and certain order items are not set, like taxes, shipping as they need to be set in teh calling function, like @see WC_Subscriptions_Checkout::filter_woocommerce_create_order(). Default false.
* 'failed_order_id' int For checkout_renewal true, indicates order id being replaced
- * @since 1.2
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function generate_renewal_order( $original_order, $product_id, $args = array() ) {
_deprecated_function( __METHOD__, '2.0', 'wcs_create_renewal_order() or wcs_create_resubscribe_order()' );
@@ -461,8 +473,8 @@ class WC_Subscriptions_Renewal_Order {
* If a product is being marked as not purchasable because it is limited and the customer has a subscription,
* but the current request is to resubscribe to the subscription, then mark it as purchasable.
*
- * @since 1.5
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function is_purchasable( $is_purchasable, $product ) {
_deprecated_function( __METHOD__, '2.0', 'WCS_Cart_Renewal::is_purchasable()' );
@@ -476,7 +488,7 @@ class WC_Subscriptions_Renewal_Order {
* @param array $args (optional) An array of name => value flags:
* 'order_role' string (optional) A specific role to check the order against. Either 'parent' or 'child'.
* 'via_checkout' Indicates whether to check if the renewal order was via the cart/checkout process.
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function is_renewal( $order, $args = array() ) {
@@ -508,8 +520,8 @@ class WC_Subscriptions_Renewal_Order {
*
* @param int $order_id The ID of a WC_Order object.
* @param string $output (optional) How you'd like the result. Can be 'ID' for IDs only or 'WC_Order' for order objects.
- * @since 1.2
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_renewal_orders( $order_id, $output = 'ID' ) {
_deprecated_function( __METHOD__, '2.0', 'WC_Subscription::get_related_orders()' );
@@ -535,8 +547,8 @@ class WC_Subscriptions_Renewal_Order {
*
* This is particularly important to ensure renewals of limited subscriptions can be completed.
*
- * @since 1.5.5
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5.5
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_checkout_payment_url( $pay_url, $order ) {
_deprecated_function( __METHOD__, '2.0', 'WCS_Cart_Renewal::get_checkout_payment_url() or WCS_Cart_Resubscribe::get_checkout_payment_url()' );
@@ -546,8 +558,8 @@ class WC_Subscriptions_Renewal_Order {
/**
* Process a renewal payment when a customer has completed the payment for a renewal payment which previously failed.
*
- * @since 1.3
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.3
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function maybe_process_failed_renewal_order_payment( $order_id ) {
_deprecated_function( __METHOD__, '2.0', 'WCS_Cart_Renewal::maybe_change_subscription_status( $order_id, $orders_old_status, $orders_new_status )' );
@@ -559,8 +571,8 @@ class WC_Subscriptions_Renewal_Order {
* never be called. This function makes sure it is called.
*
* @param WC_Order|int $order A WC_Order object or ID of a WC_Order order.
- * @since 1.2
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function process_failed_renewal_order_payment( $order_id ) {
_deprecated_function( __METHOD__, '2.0' );
@@ -579,8 +591,8 @@ class WC_Subscriptions_Renewal_Order {
* Records manual payment of a renewal order against a subscription.
*
* @param WC_Order|int $order A WC_Order object or ID of a WC_Order order.
- * @since 1.2
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function maybe_record_renewal_order_payment( $order_id ) {
_deprecated_function( __METHOD__, '2.0' );
@@ -599,8 +611,8 @@ class WC_Subscriptions_Renewal_Order {
* Records manual payment of a renewal order against a subscription.
*
* @param WC_Order|int $order A WC_Order object or ID of a WC_Order order.
- * @since 1.2
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function maybe_record_renewal_order_payment_failure( $order_id ) {
_deprecated_function( __METHOD__, '2.0' );
@@ -621,8 +633,8 @@ class WC_Subscriptions_Renewal_Order {
*
* @param int $user_id The id of the user who purchased the subscription
* @param string $subscription_key A subscription key of the form created by @see WC_Subscriptions_Manager::get_subscription_key()
- * @since 1.2
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function process_subscription_payment_on_child_order( $order_id, $payment_status = 'completed' ) {
_deprecated_function( __METHOD__, '2.0' );
@@ -650,8 +662,8 @@ class WC_Subscriptions_Renewal_Order {
/**
* Adds a renewal orders section to the Related Orders meta box displayed on subscription orders.
*
- * @deprecated 2.0
- * @since 1.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function renewal_orders_meta_box_section( $order, $post ) {
_deprecated_function( __METHOD__, '2.0' );
@@ -660,7 +672,7 @@ class WC_Subscriptions_Renewal_Order {
/**
* Trigger a hook when a subscription suspended due to a failed renewal payment is reactivated
*
- * @since 1.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.3
*/
public static function trigger_processed_failed_renewal_order_payment_hook( $user_id, $subscription_key ) {
_deprecated_function( __METHOD__, '2.0', __CLASS__ . '::maybe_record_subscription_payment( $order_id, $orders_old_status, $orders_new_status )' );
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-synchroniser.php b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-synchroniser.php
index be95b25..d0bfbb5 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-synchroniser.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-synchroniser.php
@@ -6,7 +6,7 @@
* @subpackage WC_Subscriptions_Sync
* @category Class
* @author Brent Shepherd
- * @since 1.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5
*/
class WC_Subscriptions_Synchroniser {
@@ -38,7 +38,7 @@ class WC_Subscriptions_Synchroniser {
/**
* Bootstraps the class and hooks required actions & filters.
*
- * @since 1.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5
*/
public static function init() {
self::$setting_id = WC_Subscriptions_Admin::$option_prefix . '_sync_payments';
@@ -93,7 +93,7 @@ class WC_Subscriptions_Synchroniser {
add_filter( 'woocommerce_subscriptions_cart_get_price', __CLASS__ . '::set_prorated_price_for_calculation', 10, 2 );
// When creating a subscription check if it contains a synced product and make sure the correct meta is set on the subscription
- add_action( 'save_post', __CLASS__ . '::maybe_add_subscription_meta', 10, 1 );
+ add_action( 'woocommerce_new_subscription', __CLASS__ . '::maybe_add_subscription_meta', 10, 1 );
// When adding an item to a subscription, check if it is for a synced product to make sure the sync meta is set on the subscription. We can't attach to just the 'woocommerce_new_order_item' here because the '_product_id' and '_variation_id' meta are not set before it fires
add_action( 'woocommerce_ajax_add_order_item_meta', __CLASS__ . '::ajax_maybe_add_meta_for_item', 10, 2 );
@@ -173,7 +173,7 @@ class WC_Subscriptions_Synchroniser {
/**
* Check if payment syncing is enabled on the store.
*
- * @since 1.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5
*/
public static function is_syncing_enabled() {
return 'yes' === get_option( self::$setting_id, 'no' );
@@ -182,7 +182,7 @@ class WC_Subscriptions_Synchroniser {
/**
* Check if payments can be prorated on the store.
*
- * @since 1.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5
*/
public static function is_sync_proration_enabled() {
return 'no' !== get_option( self::$setting_id_proration, 'no' );
@@ -191,7 +191,7 @@ class WC_Subscriptions_Synchroniser {
/**
* Add sync settings to the Subscription's settings page.
*
- * @since 1.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5
*/
public static function add_settings( $settings ) {
$synchronisation_settings = array(
@@ -253,7 +253,7 @@ class WC_Subscriptions_Synchroniser {
/**
* Add the sync setting fields to the Edit Product screen
*
- * @since 1.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5
*/
public static function subscription_product_fields() {
global $post, $wp_locale;
@@ -324,7 +324,7 @@ class WC_Subscriptions_Synchroniser {
/**
* Add the sync setting fields to the variation section of the Edit Product screen
*
- * @since 1.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5
*/
public static function variable_subscription_product_fields( $loop, $variation_data, $variation ) {
@@ -357,7 +357,7 @@ class WC_Subscriptions_Synchroniser {
/**
* Save sync options when a subscription product is saved
*
- * @since 1.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5
*/
public static function save_subscription_meta( $post_id ) {
@@ -390,7 +390,7 @@ class WC_Subscriptions_Synchroniser {
/**
* Save sync options when a variable subscription product is saved
*
- * @since 1.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5
*/
public static function process_product_meta_variable_subscription( $post_id ) {
@@ -405,7 +405,7 @@ class WC_Subscriptions_Synchroniser {
/**
* Save sync options when a variable subscription product is saved
*
- * @since 1.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5
*/
public static function save_product_variation( $variation_id, $index ) {
@@ -433,7 +433,7 @@ class WC_Subscriptions_Synchroniser {
/**
* Add translated syncing options for our client side script
*
- * @since 1.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5
*/
public static function admin_script_parameters( $script_parameters ) {
@@ -459,7 +459,7 @@ class WC_Subscriptions_Synchroniser {
* specific day (instead of at the time of sign-up).
*
* @return (bool) True is the product's first payment will be synced to a certain day.
- * @since 1.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5
*/
public static function is_product_synced( $product ) {
@@ -480,7 +480,7 @@ class WC_Subscriptions_Synchroniser {
* Determine whether a product, specified with $product, should have its first payment processed on a
* at the time of sign-up but prorated to the sync day.
*
- * @since 1.5.10
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5.10
*
* @param WC_Product $product
*
@@ -575,7 +575,7 @@ class WC_Subscriptions_Synchroniser {
* synchronised to.
*
* @return int The day the products payments should be processed, or 0 if the payments should not be sync'd to a specific day.
- * @since 1.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5
*/
public static function get_products_payment_day( $product ) {
@@ -596,7 +596,7 @@ class WC_Subscriptions_Synchroniser {
* @param WC_Product $product A subscription product.
* @param string $type (optional) The format to return the first payment date in, either 'mysql' or 'timestamp'. Default 'mysql'.
* @param string $from_date (optional) The date to calculate the first payment from in GMT/UTC timzeone. If not set, it will use the current date. This should not include any trial period on the product.
- * @since 1.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5
*/
public static function calculate_first_payment_date( $product, $type = 'mysql', $from_date = '' ) {
@@ -736,7 +736,7 @@ class WC_Subscriptions_Synchroniser {
/**
* Return an i18n'ified associative array of sync options for 'year' as billing period
*
- * @since 3.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.0.0
*/
public static function get_year_sync_options() {
global $wp_locale;
@@ -750,7 +750,7 @@ class WC_Subscriptions_Synchroniser {
/**
* Return an i18n'ified associative array of all possible subscription periods.
*
- * @since 1.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5
*/
public static function get_billing_period_ranges( $billing_period = '' ) {
global $wp_locale;
@@ -791,7 +791,7 @@ class WC_Subscriptions_Synchroniser {
/**
* Add the first payment date to a products summary section
*
- * @since 1.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5
*/
public static function products_first_payment_date( $echo = false ) {
global $product;
@@ -808,7 +808,7 @@ class WC_Subscriptions_Synchroniser {
/**
* Return a string explaining when the first payment will be completed for the subscription.
*
- * @since 1.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5
*/
public static function get_products_first_payment_date( $product ) {
@@ -845,7 +845,7 @@ class WC_Subscriptions_Synchroniser {
/**
* If a product is synchronised to a date in the future, make sure that is set as the product's first payment date
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function products_first_renewal_payment_time( $first_renewal_timestamp, $product_id, $from_date, $timezone ) {
@@ -868,7 +868,7 @@ class WC_Subscriptions_Synchroniser {
/**
* Make sure a synchronised subscription's price includes a free trial, unless it's first payment is today.
*
- * @since 1.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5
*/
public static function maybe_set_free_trial( $total = '' ) {
@@ -892,7 +892,7 @@ class WC_Subscriptions_Synchroniser {
/**
* Make sure a synchronised subscription's price includes a free trial, unless it's first payment is today.
*
- * @since 1.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5
*/
public static function maybe_unset_free_trial( $total = '' ) {
@@ -917,7 +917,7 @@ class WC_Subscriptions_Synchroniser {
* Check if the cart includes a subscription that needs to be synced.
*
* @return bool Returns true if any item in the cart is a subscription sync request, otherwise, false.
- * @since 1.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5
*/
public static function cart_contains_synced_subscription( $cart = null ) {
$cart = ( empty( $cart ) && isset( WC()->cart ) ) ? WC()->cart : $cart;
@@ -953,7 +953,7 @@ class WC_Subscriptions_Synchroniser {
* @param mixed $trial_expiration_date MySQL formatted date on which the subscription's trial will end, or 0 if it has no trial
* @param mixed $product_id The product object or post ID of the subscription product
* @return mixed MySQL formatted date on which the subscription's trial is set to end, or 0 if it has no trial
- * @since 2.0.13
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.13
*/
public static function recalculate_product_trial_expiration_date( $trial_expiration_date, $product_id ) {
@@ -983,7 +983,7 @@ class WC_Subscriptions_Synchroniser {
* @param string $expiration_date MySQL formatted date on which the subscription is set to expire
* @param mixed $product_id The product/post ID of the subscription
* @param mixed $from_date A MySQL formatted date/time string from which to calculate the expiration date, or empty (default), which will use today's date/time.
- * @since 1.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5
*/
public static function recalculate_product_expiration_date( $expiration_date, $product_id, $from_date ) {
@@ -1019,7 +1019,7 @@ class WC_Subscriptions_Synchroniser {
* @param mixed $order A WC_Order object or the ID of the order which the subscription was purchased in.
* @param int $product_id The post ID of the subscription WC_Product object purchased in the order. Defaults to the ID of the first product purchased in the order.
* @return float The initial sign-up fee charged when the subscription product in the order was first purchased, if any.
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_synced_sign_up_fee( $sign_up_fee, $subscription, $product_id ) {
@@ -1033,7 +1033,7 @@ class WC_Subscriptions_Synchroniser {
/**
* Removes the "set_subscription_prices_for_calculation" filter from the WC Product's woocommerce_get_price hook once
*
- * @since 1.5.10
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5.10
*
* @param int $price The current price.
* @param WC_Product $product The product object.
@@ -1086,7 +1086,7 @@ class WC_Subscriptions_Synchroniser {
* by using 1 (one). So the week starts with 1 (one)
* and ends on Sunday with is fetched by using 7 (seven).
*
- * @since 1.5.8
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5.8
* @access public
*
* @param int $weekday_number 1 for Monday through 7 Sunday
@@ -1133,23 +1133,24 @@ class WC_Subscriptions_Synchroniser {
}
/**
- * Add subscription meta for subscription that contains a synced product.
+ * Adds meta on a subscription that contains a synced product.
*
- * @param WC_Order Parent order for the subscription
- * @param WC_Subscription new subscription
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
+ *
+ * @param WC_Subscription|int Subscription object or ID.
*/
- public static function maybe_add_subscription_meta( $post_id ) {
-
- if ( 'shop_subscription' == get_post_type( $post_id ) && ! self::subscription_contains_synced_product( $post_id ) ) {
-
- $subscription = wcs_get_subscription( $post_id );
+ public static function maybe_add_subscription_meta( $subscription ) {
+ if ( ! is_object( $subscription ) ) {
+ $subscription = wcs_get_subscription( $subscription );
+ }
+ if ( $subscription && ! self::subscription_contains_synced_product( $subscription ) ) {
foreach ( $subscription->get_items() as $item ) {
$product = $item->get_product();
if ( self::is_product_synced( $product ) ) {
- update_post_meta( $subscription->get_id(), '_contains_synced_subscription', 'true' );
+ $subscription->update_meta_data( '_contains_synced_subscription', 'true' );
+ $subscription->save();
break;
}
}
@@ -1162,7 +1163,7 @@ class WC_Subscriptions_Synchroniser {
*
* @param int The order item ID of an item that was just added to the order
* @param array The order item details
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function ajax_maybe_add_meta_for_item( $item_id, $item ) {
@@ -1180,7 +1181,7 @@ class WC_Subscriptions_Synchroniser {
* @param int The post ID of a WC_Order or child object
* @param int The order item ID of an item that was just added to the order
* @param object The WC_Product for which an item was just added
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function maybe_add_meta_for_new_product( $subscription_id, $item_id, $product ) {
if ( self::is_product_synced( $product ) ) {
@@ -1189,25 +1190,25 @@ class WC_Subscriptions_Synchroniser {
}
/**
- * Check if a given subscription is synced to a certain day.
+ * Checks if a given subscription is synced to a certain day.
*
- * @param int|WC_Subscription Accepts either a subscription object of post id
- * @return bool
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
+ *
+ * @param int|WC_Subscription Accepts either a subscription object or ID.
+ * @return bool True if the subscription is synced, false otherwise.
*/
- public static function subscription_contains_synced_product( $subscription_id ) {
-
- if ( is_object( $subscription_id ) ) {
- $subscription_id = $subscription_id->get_id();
+ public static function subscription_contains_synced_product( $subscription ) {
+ if ( ! is_object( $subscription ) ) {
+ $subscription = wcs_get_subscription( $subscription );
}
- return 'true' == get_post_meta( $subscription_id, '_contains_synced_subscription', true );
+ return is_a( $subscription, 'WC_Subscription' ) && 'true' === $subscription->get_meta( '_contains_synced_subscription' );
}
/**
* If the cart item is synced, add a '_synced' string to the recurring cart key.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function add_to_recurring_cart_key( $cart_key, $cart_item ) {
$product = $cart_item['data'];
@@ -1228,7 +1229,7 @@ class WC_Subscriptions_Synchroniser {
* @param int The new line item id
* @param WC_Order_Item
* @param int The post ID of a WC_Subscription
- * @since 2.2.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.3
*/
public static function maybe_add_meta_for_new_line_item( $item_id, $item, $subscription_id ) {
if ( is_callable( array( $item, 'get_product' ) ) ) {
@@ -1251,7 +1252,7 @@ class WC_Subscriptions_Synchroniser {
* @param WC_Order_Item_Product $item The order item object.
* @param string $cart_item_key The hash used to identify the item in the cart
* @param array $cart_item The cart item's data.
- * @since 2.3.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.0
*/
public static function maybe_add_line_item_meta( $item, $cart_item_key, $cart_item ) {
if ( self::is_product_synced( $cart_item['data'] ) && ! self::is_today( self::calculate_first_payment_date( $cart_item['data'], 'timestamp' ) ) ) {
@@ -1266,7 +1267,7 @@ class WC_Subscriptions_Synchroniser {
*
* @param int $item_id The order item ID.
* @param array $cart_item The cart item's data.
- * @since 2.3.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.0
*/
public static function maybe_add_order_item_meta( $item_id, $cart_item ) {
if ( self::is_product_synced( $cart_item['data'] ) && ! self::is_today( self::calculate_first_payment_date( $cart_item['data'], 'timestamp' ) ) ) {
@@ -1277,7 +1278,7 @@ class WC_Subscriptions_Synchroniser {
/**
* Hides synced subscription meta on the edit order and subscription screen on non-debug sites.
*
- * @since 2.6.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.2
* @param array $hidden_meta_keys the list of meta keys hidden on the edit order and subscription screen.
* @return array $hidden_meta_keys
*/
@@ -1293,7 +1294,7 @@ class WC_Subscriptions_Synchroniser {
/**
* Gets the number of sign-up grace period days.
*
- * @since 3.0.6
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.0.6
* @return int The number of days in the grace period. 0 will be returned if the stroe isn't charging the full recurring price on sign-up -- a prerequiste for setting a grace period.
*/
private static function get_number_of_grace_period_days() {
@@ -1306,7 +1307,7 @@ class WC_Subscriptions_Synchroniser {
* Automatically set the order's status to complete if all the subscriptions in an order
* are synced and the order total is zero.
*
- * @since 1.5.17
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5.17
*/
public static function order_autocomplete( $new_order_status, $order_id ) {
_deprecated_function( __METHOD__, '2.1.3', 'WC_Subscriptions_Order::maybe_autocomplete_order' );
@@ -1318,8 +1319,8 @@ class WC_Subscriptions_Synchroniser {
*
* Deprecated because the first renewal date is displayed by default now on recurring totals.
*
- * @since 1.5
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function customise_subscription_price_string( $subscription_string ) {
_deprecated_function( __METHOD__, '2.0' );
@@ -1347,8 +1348,8 @@ class WC_Subscriptions_Synchroniser {
*
* Deprecated because free trials are no longer displayed on cart totals, only the first renewal date is displayed.
*
- * @since 1.5
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function maybe_hide_free_trial( $subscription_details ) {
_deprecated_function( __METHOD__, '2.0' );
@@ -1371,8 +1372,8 @@ class WC_Subscriptions_Synchroniser {
* Let other functions know shipping should not be charged on the initial order when
* the cart contains a synchronised subscription and no other items which need shipping.
*
- * @since 1.5.8
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5.8
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function charge_shipping_up_front( $charge_shipping_up_front ) {
_deprecated_function( __METHOD__, '2.0' );
@@ -1417,8 +1418,8 @@ class WC_Subscriptions_Synchroniser {
* This is necessary as the self::calculate_first_payment_date() is not called when the subscription is active
* (which it isn't until the first payment is completed and the subscription is activated).
*
- * @since 1.5
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_first_payment_date( $first_payment_date, $order, $product_id, $type ) {
_deprecated_function( __METHOD__, '2.0' );
@@ -1446,8 +1447,8 @@ class WC_Subscriptions_Synchroniser {
* to use the synchronised first payment date as the next payment date (if the first
* payment date isn't today, meaning the first payment won't be charged today).
*
- * @since 1.5.14
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5.14
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function maybe_set_payment_date( $payment_date, $order, $product_id, $type ) {
@@ -1469,8 +1470,8 @@ class WC_Subscriptions_Synchroniser {
*
* @param int $order_id The ID or a WC_Order item to check.
* @return bool Returns true if the order contains a synced subscription, otherwise, false.
- * @since 1.5
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function order_contains_synced_subscription( $order_id ) {
_deprecated_function( __METHOD__, '2.0', __CLASS__ . '::subscription_contains_synced_product()' );
@@ -1487,8 +1488,8 @@ class WC_Subscriptions_Synchroniser {
*
* Deprecated because _order_contains_synced_subscription is no longer stored on the order @see self::add_subscription_sync_meta
*
- * @since 1.5
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function add_order_meta( $order_id, $posted ) {
_deprecated_function( __METHOD__, '2.0' );
@@ -1504,8 +1505,8 @@ class WC_Subscriptions_Synchroniser {
*
* Deprecated because editing a subscription's values is now done from the Edit Subscription screen.
*
- * @since 1.5
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function prefill_order_item_meta( $item, $item_id ) {
@@ -1522,13 +1523,13 @@ class WC_Subscriptions_Synchroniser {
* @param mixed $order A WC_Order object or the ID of the order which the subscription was purchased in.
* @param int $product_id The post ID of the subscription WC_Product object purchased in the order. Defaults to the ID of the first product purchased in the order.
* @return float The initial sign-up fee charged when the subscription product in the order was first purchased, if any.
- * @since 1.5.3
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5.3
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_sign_up_fee( $sign_up_fee, $order, $product_id, $non_subscription_total ) {
_deprecated_function( __METHOD__, '2.0', __CLASS__ . '::get_synced_sign_up_fee' );
- if ( 'shop_order' == get_post_type( $order ) && self::order_contains_synced_subscription( wcs_get_objects_property( $order, 'id' ) ) && WC_Subscriptions_Order::get_subscription_trial_length( $order ) < 1 ) {
+ if ( 'shop_order' === WC_Data_Store::load( 'order' )->get_order_type( $order ) && self::order_contains_synced_subscription( wcs_get_objects_property( $order, 'id' ) ) && WC_Subscriptions_Order::get_subscription_trial_length( $order ) < 1 ) {
$sign_up_fee = max( WC_Subscriptions_Order::get_total_initial_payment( $order ) - $non_subscription_total, 0 );
}
@@ -1539,8 +1540,8 @@ class WC_Subscriptions_Synchroniser {
* Check if the cart includes a subscription that needs to be prorated.
*
* @return bool Returns any item in the cart that is synced and requires proration, otherwise, false.
- * @since 1.5
- * @deprecated 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function cart_contains_prorated_subscription() {
_deprecated_function( __METHOD__, '2.0' );
@@ -1559,8 +1560,8 @@ class WC_Subscriptions_Synchroniser {
* Maybe recalculate the trial end date for synced subscription products that contain the unnecessary
* "one day trial" period.
*
- * @since 2.0
- * @deprecated 2.0.14
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.14
*/
public static function recalculate_trial_end_date( $trial_end_date, $recurring_cart, $product ) {
_deprecated_function( __METHOD__, '2.0.14' );
@@ -1576,8 +1577,8 @@ class WC_Subscriptions_Synchroniser {
* Maybe recalculate the end date for synced subscription products that contain the unnecessary
* "one day trial" period.
*
- * @since 2.0.9
- * @deprecated 2.0.14
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.9
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.14
*/
public static function recalculate_end_date( $end_date, $recurring_cart, $product ) {
_deprecated_function( __METHOD__, '2.0.14' );
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-tracker.php b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-tracker.php
index bab628b..81fba94 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-tracker.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-tracker.php
@@ -3,10 +3,9 @@
* Tracker for Subscriptions usage.
*
* @class WC_Subscriptions_Tracker
- * @version 2.6.4
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.4
* @package WooCommerce Subscriptions/Classes
* @category Class
- * @author WooCommerce
*/
defined( 'ABSPATH' ) || exit;
@@ -19,7 +18,7 @@ class WC_Subscriptions_Tracker {
public static function init() {
// Only add data if Tracker enabled
if ( 'yes' === get_option( 'woocommerce_allow_tracking', 'no' ) ) {
- add_filter( 'woocommerce_tracker_data', array( __CLASS__, 'add_subscriptions_tracking_data' ), 10, 1 );
+ add_filter( 'woocommerce_tracker_data', [ __CLASS__, 'add_subscriptions_tracking_data' ], 10, 1 );
}
}
@@ -42,7 +41,7 @@ class WC_Subscriptions_Tracker {
* @return array Subscriptions options data.
*/
private static function get_subscriptions_options() {
- return array(
+ return [
// Staging and live site
'wc_subscriptions_staging' => WCS_Staging::is_duplicate_site() ? 'staging' : 'live',
'wc_subscriptions_live_url' => esc_url( WCS_Staging::get_site_url_from_source( 'subscriptions_install' ) ),
@@ -55,12 +54,12 @@ class WC_Subscriptions_Tracker {
// Renewals
'accept_manual_renewals' => get_option( WC_Subscriptions_Admin::$option_prefix . '_accept_manual_renewals' ),
- 'turn_off_automatic_payments' => 'no' == get_option( WC_Subscriptions_Admin::$option_prefix . '_accept_manual_renewals' ) ? 'none' : get_option( WC_Subscriptions_Admin::$option_prefix . '_turn_off_automatic_payments', 'none' ),
+ 'turn_off_automatic_payments' => 'no' === get_option( WC_Subscriptions_Admin::$option_prefix . '_accept_manual_renewals' ) ? 'none' : get_option( WC_Subscriptions_Admin::$option_prefix . '_turn_off_automatic_payments', 'none' ),
'enable_auto_renewal_toggle' => get_option( WC_Subscriptions_Admin::$option_prefix . '_enable_auto_renewal_toggle' ),
// Early renewal
'enable_early_renewal' => get_option( WC_Subscriptions_Admin::$option_prefix . '_enable_early_renewal' ),
- 'enable_early_renewal_via_modal' => 'no' == get_option( WC_Subscriptions_Admin::$option_prefix . '_enable_early_renewal' ) ? 'none' : get_option( WC_Subscriptions_Admin::$option_prefix . '_enable_early_renewal_via_modal', 'none' ),
+ 'enable_early_renewal_via_modal' => 'no' === get_option( WC_Subscriptions_Admin::$option_prefix . '_enable_early_renewal' ) ? 'none' : get_option( WC_Subscriptions_Admin::$option_prefix . '_enable_early_renewal_via_modal', 'none' ),
// Switching
'allow_switching' => get_option( WC_Subscriptions_Admin::$option_prefix . '_allow_switching' ),
@@ -71,8 +70,8 @@ class WC_Subscriptions_Tracker {
// Synchronization
'sync_payments' => get_option( WC_Subscriptions_Admin::$option_prefix . '_sync_payments' ),
- 'prorate_synced_payments' => $prorate_synced_payments = ( 'no' == get_option( WC_Subscriptions_Admin::$option_prefix . '_sync_payments' ) ? 'none' : get_option( WC_Subscriptions_Admin::$option_prefix . '_prorate_synced_payments', 'none' ) ),
- 'days_no_fee' => 'recurring' == $prorate_synced_payments ? get_option( WC_Subscriptions_Admin::$option_prefix . '_days_no_fee', 'none' ) : 'none',
+ 'prorate_synced_payments' => $prorate_synced_payments = ( 'no' === get_option( WC_Subscriptions_Admin::$option_prefix . '_sync_payments' ) ? 'none' : get_option( WC_Subscriptions_Admin::$option_prefix . '_prorate_synced_payments', 'none' ) ),
+ 'days_no_fee' => 'recurring' === $prorate_synced_payments ? get_option( WC_Subscriptions_Admin::$option_prefix . '_days_no_fee', 'none' ) : 'none',
// Miscellaneous
'max_customer_suspensions' => get_option( WC_Subscriptions_Admin::$option_prefix . '_max_customer_suspensions' ),
@@ -80,7 +79,7 @@ class WC_Subscriptions_Tracker {
'allow_zero_initial_order_without_payment_method' => get_option( WC_Subscriptions_Admin::$option_prefix . '_zero_initial_payment_requires_payment' ),
'drip_downloadable_content_on_renewal' => get_option( WC_Subscriptions_Admin::$option_prefix . '_drip_downloadable_content_on_renewal' ),
'enable_retry' => get_option( WC_Subscriptions_Admin::$option_prefix . '_enable_retry' ),
- );
+ ];
}
/**
@@ -98,71 +97,102 @@ class WC_Subscriptions_Tracker {
/**
* Gets subscription counts.
*
- * @return array
+ * @return array Subscription count by status. Keys are subscription status slugs, values are subscription counts (string).
*/
private static function get_subscription_counts() {
- $subscription_counts = array();
- $subscription_counts_data = wp_count_posts( 'shop_subscription' );
+ $subscription_counts = [];
+ $count_by_status = WC_Data_Store::load( 'subscription' )->get_subscriptions_count_by_status();
foreach ( wcs_get_subscription_statuses() as $status_slug => $status_name ) {
- $subscription_counts[ $status_slug ] = $subscription_counts_data->{ $status_slug };
+ $subscription_counts[ $status_slug ] = $count_by_status[ $status_slug ] ?? 0;
}
+ // Ensure all values are strings.
+ $subscription_counts = array_map( 'strval', $subscription_counts );
return $subscription_counts;
}
/**
* Gets subscription order counts and totals.
*
- * @return array
+ * @return array Subscription order counts and totals by type (initial, switch, renewal, resubscribe). Values are returned as strings.
*/
private static function get_subscription_orders() {
- global $wpdb;
-
- $order_totals = array();
- $relation_types = array(
+ $order_totals = [];
+ $relation_types = [
'switch',
'renewal',
'resubscribe',
- );
+ ];
+ // Get the subtotal and count for each subscription type.
foreach ( $relation_types as $relation_type ) {
+ // Get orders with the given relation type.
+ $relation_orders = wcs_get_orders_with_meta_query(
+ [
+ 'type' => 'shop_order',
+ 'status' => [ 'wc-completed', 'wc-processing', 'wc-refunded' ],
+ 'limit' => -1,
+ 'meta_query' => [ // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
+ [
+ 'key' => '_subscription_' . $relation_type,
+ 'compare' => 'EXISTS',
+ ],
+ ],
+ ]
+ );
- $total_and_count = $wpdb->get_row( sprintf(
- "SELECT
- SUM( order_total.meta_value ) AS 'gross_total', COUNT( orders.ID ) as 'count'
- FROM {$wpdb->prefix}posts AS orders
- LEFT JOIN {$wpdb->prefix}postmeta AS order_relation ON order_relation.post_id = orders.ID
- LEFT JOIN {$wpdb->prefix}postmeta AS order_total ON order_total.post_id = orders.ID
- WHERE order_relation.meta_key = '_subscription_%s'
- AND orders.post_status in ( 'wc-completed', 'wc-processing', 'wc-refunded' )
- AND order_total.meta_key = '_order_total'
- GROUP BY order_total.meta_key
- ", $relation_type
- ), ARRAY_A );
+ // Sum the totals and count the orders.
+ $count = count( $relation_orders );
+ $total = array_reduce(
+ $relation_orders,
+ function( $total, $order ) {
+ return $total + $order->get_total();
+ },
+ 0
+ );
- $order_totals[ $relation_type . '_gross' ] = is_null( $total_and_count ) ? 0 : $total_and_count['gross_total'];
- $order_totals[ $relation_type . '_count' ] = is_null( $total_and_count ) ? 0 : $total_and_count['count'];
+ $order_totals[ $relation_type . '_gross' ] = $total;
+ $order_totals[ $relation_type . '_count' ] = $count;
}
- // Finally get the initial revenue and count
- $total_and_count = $wpdb->get_row(
- "SELECT
- SUM( order_total.meta_value ) AS 'gross_total', COUNT( * ) as 'count'
- FROM {$wpdb->prefix}posts AS orders
- LEFT JOIN {$wpdb->prefix}posts AS subscriptions ON subscriptions.post_parent = orders.ID
- LEFT JOIN {$wpdb->prefix}postmeta AS order_total ON order_total.post_id = orders.ID
- WHERE orders.post_status in ( 'wc-completed', 'wc-processing', 'wc-refunded' )
- AND subscriptions.post_type = 'shop_subscription'
- AND orders.post_type = 'shop_order'
- AND order_total.meta_key = '_order_total'
- GROUP BY order_total.meta_key
- ", ARRAY_A );
+ // Finally, get the initial revenue and count.
+ // Get the orders for all initial subscription orders (no switch, renewal or resubscribe meta key).
+ $initial_subscription_orders = wcs_get_orders_with_meta_query(
+ [
+ 'type' => 'shop_order',
+ 'status' => [ 'wc-completed', 'wc-processing', 'wc-refunded' ],
+ 'limit' => -1,
+ 'meta_query' => [ // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
+ [
+ 'key' => '_subscription_switch',
+ 'compare' => 'NOT EXISTS',
+ ],
+ [
+ 'key' => '_subscription_renewal',
+ 'compare' => 'NOT EXISTS',
+ ],
+ [
+ 'key' => '_subscription_resubscribe',
+ 'compare' => 'NOT EXISTS',
+ ],
+ ],
+ ]
+ );
- $initial_order_total = is_null( $total_and_count ) ? 0 : $total_and_count['gross_total'];
- $initial_order_count = is_null( $total_and_count ) ? 0 : $total_and_count['count'];
+ // Sum the totals and count the orders.
+ $initial_order_count = count( $initial_subscription_orders );
+ $initial_order_total = array_reduce(
+ $initial_subscription_orders,
+ function( $total, $order ) {
+ return $total + $order->get_total();
+ },
+ 0
+ );
- // Don't double count resubscribe revenue and count
- $order_totals['initial_gross'] = $initial_order_total - $order_totals['resubscribe_gross'];
- $order_totals['initial_count'] = $initial_order_count - $order_totals['resubscribe_count'];
+ $order_totals['initial_gross'] = $initial_order_total;
+ $order_totals['initial_count'] = $initial_order_count;
+
+ // Ensure all values are strings.
+ $order_totals = array_map( 'strval', $order_totals );
return $order_totals;
}
@@ -170,28 +200,32 @@ class WC_Subscriptions_Tracker {
/**
* Gets first and last subscription created dates.
*
- * @return array
+ * @return array 'first' and 'last' created subscription dates as a string in the date format 'Y-m-d H:i:s' or '-'.
*/
private static function get_subscription_dates() {
- global $wpdb;
-
- $min_max = $wpdb->get_row(
- "
- SELECT
- MIN( post_date_gmt ) as 'first', MAX( post_date_gmt ) as 'last'
- FROM {$wpdb->prefix}posts
- WHERE post_type = 'shop_subscription'
- AND post_status NOT IN ( 'trash', 'auto-draft' )
- ",
- ARRAY_A
+ // Ignore subscriptions with status 'trash'.
+ $first = wcs_get_subscriptions(
+ [
+ 'subscriptions_per_page' => 1,
+ 'orderby' => 'date',
+ 'order' => 'ASC',
+ 'subscription_status' => [ 'active', 'on-hold', 'pending', 'cancelled', 'expired' ],
+ ]
+ );
+ $last = wcs_get_subscriptions(
+ [
+ 'subscriptions_per_page' => 1,
+ 'orderby' => 'date',
+ 'order' => 'DESC',
+ 'subscription_status' => [ 'active', 'on-hold', 'pending', 'cancelled', 'expired' ],
+ ]
);
- if ( is_null( $min_max ) ) {
- $min_max = array(
- 'first' => '-',
- 'last' => '-',
- );
- }
+ // Return each date in 'Y-m-d H:i:s' format or '-' if no subscriptions found.
+ $min_max = [
+ 'first' => count( $first ) ? array_shift( $first )->get_date( 'date_created' ) : '-',
+ 'last' => count( $last ) ? array_shift( $last )->get_date( 'date_created' ) : '-',
+ ];
return $min_max;
}
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wcs-action-scheduler.php b/vendor/woocommerce/subscriptions-core/includes/class-wcs-action-scheduler.php
index 25171b7..5c7333f 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wcs-action-scheduler.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wcs-action-scheduler.php
@@ -3,7 +3,7 @@
* Scheduler for subscription events that uses the Action Scheduler
*
* @class WCS_Action_Scheduler
- * @version 2.0.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.0
* @package WooCommerce Subscriptions/Classes
* @category Class
* @author Prospress
@@ -15,7 +15,7 @@ class WCS_Action_Scheduler extends WCS_Scheduler {
*
* This variable has been deprecated and will be removed completely in the future. You should use WCS_Action_Scheduler::get_scheduled_action_hook() and WCS_Action_Scheduler::get_date_types_to_schedule() instead.
*
- * @deprecated 2.6.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
* @var array An array of $action_hook => $date_type values
*/
protected $action_hooks = array(
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wcs-blocks-integration.php b/vendor/woocommerce/subscriptions-core/includes/class-wcs-blocks-integration.php
index ebd48db..099d4a6 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wcs-blocks-integration.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wcs-blocks-integration.php
@@ -5,7 +5,7 @@ use Automattic\WooCommerce\Blocks\Integrations\IntegrationInterface;
* Class for integrating with WooCommerce Blocks
*
* @package WooCommerce Subscriptions
- * @since 3.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
*/
class WCS_Blocks_Integration implements IntegrationInterface {
/**
@@ -95,6 +95,6 @@ class WCS_Blocks_Integration implements IntegrationInterface {
if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG && file_exists( $file ) ) {
return filemtime( $file );
}
- return \WC_Subscriptions_Core_Plugin::instance()->get_plugin_version();
+ return \WC_Subscriptions_Core_Plugin::instance()->get_library_version();
}
}
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wcs-cached-data-manager.php b/vendor/woocommerce/subscriptions-core/includes/class-wcs-cached-data-manager.php
index 1c02cf6..040a61f 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wcs-cached-data-manager.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wcs-cached-data-manager.php
@@ -3,8 +3,8 @@
* Subscription Cached Data Manager Class
*
* @class WCS_Cached_Data_Manager
- * @version 2.3.0
- * @since 2.1.2
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1.2
* @package WooCommerce Subscriptions/Classes
* @category Class
* @author Prospress
@@ -73,16 +73,14 @@ class WCS_Cached_Data_Manager extends WCS_Cache_Manager {
public function purge_delete( $post_id, $post = null ) {
wcs_deprecated_function( __METHOD__, '2.3.0' );
- $post_type = get_post_type( $post_id );
-
- if ( 'shop_order' === $post_type ) {
+ if ( 'shop_order' === WC_Data_Store::load( 'order' )->get_order_type( $post_id ) ) {
wcs_deprecated_argument( __METHOD__, '2.3.0', sprintf( __( 'Related order caching is now handled by %1$s.', 'woocommerce-subscriptions' ), 'WCS_Related_Order_Store' ) ); // phpcs:ignore WordPress.WP.I18n.MissingTranslatorsComment
if ( is_callable( array( WCS_Related_Order_Store::instance(), 'delete_related_order_id_from_caches' ) ) ) {
WCS_Related_Order_Store::instance()->delete_related_order_id_from_caches( $post_id );
}
}
- if ( 'shop_subscription' === $post_type ) {
+ if ( 'shop_subscription' === WC_Data_Store::load( 'subscription' )->get_order_type( $post_id ) ) {
wcs_deprecated_argument( __METHOD__, '2.3.0', sprintf( __( 'Customer subscription caching is now handled by %1$s.', 'woocommerce-subscriptions' ), 'WCS_Customer_Store_Cached_CPT' ) ); // phpcs:ignore WordPress.WP.I18n.MissingTranslatorsComment
// Purge wcs_do_subscriptions_exist cache, but only on the before_delete_post hook.
@@ -110,7 +108,7 @@ class WCS_Cached_Data_Manager extends WCS_Cache_Manager {
wcs_deprecated_argument( __METHOD__, '2.3.0', sprintf( __( 'Customer subscription caching is now handled by %1$s and %2$s.', 'woocommerce-subscriptions' ), 'WCS_Customer_Store_Cached_CPT', 'WCS_Post_Meta_Cache_Manager' ) ); // phpcs:ignore WordPress.WP.I18n.MissingTranslatorsComment
// Ensure we're handling a meta key we actually care about.
- if ( '_customer_user' !== $meta_key || 'shop_subscription' !== get_post_type( $object_id ) ) {
+ if ( '_customer_user' !== $meta_key || 'shop_subscription' !== WC_Data_Store::load( 'subscription' )->get_order_type( $object_id ) ) {
return;
}
@@ -121,7 +119,7 @@ class WCS_Cached_Data_Manager extends WCS_Cache_Manager {
* Wrapper function to clear the cache that relates to related orders
*
* @param null $subscription_id
- * @deprecated 2.3.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.0
*/
protected function clear_related_order_cache( $subscription_id ) {
wcs_deprecated_function( __METHOD__, '2.3.0', __( 'new related order methods in WCS_Related_Order_Store', 'woocommerce-subscriptions' ) );
@@ -198,7 +196,7 @@ class WCS_Cached_Data_Manager extends WCS_Cache_Manager {
/**
* Check once each week if the log file has exceeded the limits.
*
- * @since 2.2.9
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.9
*/
public function initialize_cron_check_size() {
@@ -215,7 +213,7 @@ class WCS_Cached_Data_Manager extends WCS_Cache_Manager {
* Add a weekly schedule for clearing up the cache
*
* @param $scheduled array
- * @since 2.2.9
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.9
*/
function add_weekly_cron_schedule( $schedules ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wcs-cart-initial-payment.php b/vendor/woocommerce/subscriptions-core/includes/class-wcs-cart-initial-payment.php
index 8d6fee4..bdc1036 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wcs-cart-initial-payment.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wcs-cart-initial-payment.php
@@ -6,7 +6,7 @@
* @subpackage WCS_Cart_Initial_Payment
* @category Class
* @author Prospress
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
class WCS_Cart_Initial_Payment extends WCS_Cart_Renewal {
@@ -17,7 +17,7 @@ class WCS_Cart_Initial_Payment extends WCS_Cart_Renewal {
/**
* Bootstraps the class and hooks required actions & filters.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function __construct() {
$this->setup_hooks();
@@ -34,7 +34,7 @@ class WCS_Cart_Initial_Payment extends WCS_Cart_Renewal {
/**
* Setup the cart for paying for a delayed initial payment for a subscription.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function maybe_setup_cart() {
global $wp;
@@ -94,7 +94,7 @@ class WCS_Cart_Initial_Payment extends WCS_Cart_Renewal {
* Checks the cart to see if it contains an initial payment item.
*
* @return bool | Array The cart item containing the initial payment, else false.
- * @since 2.0.13
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.13
*/
protected function cart_contains() {
@@ -117,7 +117,7 @@ class WCS_Cart_Initial_Payment extends WCS_Cart_Renewal {
*
* @param Array The initial payment cart item.
* @return WC_Order | The order object
- * @since 2.0.13
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.13
*/
protected function get_order( $cart_item = '' ) {
$order = false;
@@ -136,7 +136,7 @@ class WCS_Cart_Initial_Payment extends WCS_Cart_Renewal {
/**
* Deteremines if the cart should honor the granfathered subscription/order line item total.
*
- * @since 3.0.10
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.0.10
*
* @param array $cart_item The cart item to check.
* @return bool Whether the cart should honor the order's prices.
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wcs-cart-renewal.php b/vendor/woocommerce/subscriptions-core/includes/class-wcs-cart-renewal.php
index ff21b55..e6bf571 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wcs-cart-renewal.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wcs-cart-renewal.php
@@ -9,7 +9,7 @@
* @subpackage WCS_Cart_Renewal
* @category Class
* @author Prospress
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
class WCS_Cart_Renewal {
@@ -20,7 +20,7 @@ class WCS_Cart_Renewal {
/**
* Bootstraps the class and hooks required actions & filters.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function __construct() {
@@ -42,7 +42,7 @@ class WCS_Cart_Renewal {
add_filter( 'woocommerce_create_order', array( &$this, 'update_cart_hash' ), 10, 1 );
// When a user is prevented from paying for a failed/pending renewal order because they aren't logged in, redirect them back after login
- add_filter( 'woocommerce_login_redirect', array( &$this, 'maybe_redirect_after_login' ), 10, 1 );
+ add_filter( 'woocommerce_login_redirect', array( &$this, 'maybe_redirect_after_login' ), 10, 2 );
// Once we have finished updating the renewal order on checkout, update the session cart so the cart changes are honoured.
add_action( 'woocommerce_checkout_order_processed', array( &$this, 'update_session_cart_after_updating_renewal_order' ), 10 );
@@ -73,7 +73,7 @@ class WCS_Cart_Renewal {
/**
* Attach WooCommerce version dependent hooks
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
public function attach_dependant_hooks() {
@@ -112,7 +112,7 @@ class WCS_Cart_Renewal {
/**
* Bootstraps the class and hooks required actions & filters.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function setup_hooks() {
@@ -143,9 +143,6 @@ class WCS_Cart_Renewal {
// When loading checkout address details, use the renewal order address details for renewals
add_filter( 'woocommerce_checkout_get_value', array( &$this, 'checkout_get_value' ), 10, 2 );
- // If the shipping address on a renewal order differs to the order's billing address, check the "Ship to different address" automatically to make sure the renewal order's fields are used by default
- add_filter( 'woocommerce_ship_to_different_address_checked', array( &$this, 'maybe_check_ship_to_different_address' ), 100, 1 );
-
add_filter( 'woocommerce_get_item_data', array( &$this, 'display_line_item_data_in_cart' ), 10, 2 );
// Attach hooks which depend on WooCommerce version constants. Differs from @see attach_dependant_hooks() in that this is hooked inside an inherited function and so extended classes will also inherit these callbacks
@@ -161,7 +158,7 @@ class WCS_Cart_Renewal {
/**
* Attach callbacks dependant on WC versions
*
- * @since 2.2.11
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.11
*/
public function attach_dependant_callbacks() {
@@ -178,7 +175,7 @@ class WCS_Cart_Renewal {
* redirect the order into a cart/checkout payment flow so that the customer can
* choose payment method, apply discounts set shipping and pay for the order.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function maybe_setup_cart() {
global $wp;
@@ -271,7 +268,7 @@ class WCS_Cart_Renewal {
/**
* Set up cart item meta data to complete a subscription renewal via the cart.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*
* @param WC_Abstract_Order $subscription The subscription or Order object to set up the cart from.
* @param array $cart_item_data Additional cart item data to set on the cart items.
@@ -418,7 +415,7 @@ class WCS_Cart_Renewal {
/**
* Restore renewal flag when cart is reset and modify Product object with renewal order related info
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function get_cart_item_from_session( $cart_item_session_data, $cart_item, $key ) {
@@ -515,10 +512,13 @@ class WCS_Cart_Renewal {
* to the order's billing address, tell the checkout to toggle the ship to a different address
* checkbox and make sure the shipping fields are displayed by default.
*
+ * @deprecated subscriptions-core 5.3.0 - This method has moved to the WC_Subscriptions_Checkout class.
+ *
* @param bool $ship_to_different_address Whether the order will ship to a different address
* @return bool $ship_to_different_address
*/
public function maybe_check_ship_to_different_address( $ship_to_different_address ) {
+ wcs_deprecated_function( __METHOD__, '5.3.0', 'WC_Subscriptions_Checkout::maybe_check_ship_to_different_address( $ship_to_different_address )' );
if ( ! $ship_to_different_address && false !== ( $item = $this->cart_contains() ) ) {
@@ -548,7 +548,7 @@ class WCS_Cart_Renewal {
* When completing checkout for a subscription renewal, update the address on the subscription to use
* the shipping/billing address entered in case it has changed since the subscription was first created.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function maybe_update_subscription_customer_data( $update_customer_data, $checkout_object ) {
@@ -585,7 +585,7 @@ class WCS_Cart_Renewal {
* If a product is being marked as not purchasable because it is limited and the customer has a subscription,
* but the current request is to resubscribe to the subscription, then mark it as purchasable.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
* @return bool
*/
public function is_purchasable( $is_purchasable, $product ) {
@@ -599,7 +599,7 @@ class WCS_Cart_Renewal {
*
* This is particularly important to ensure renewals of limited subscriptions can be completed.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function get_checkout_payment_url( $pay_url, $order ) {
@@ -607,13 +607,13 @@ class WCS_Cart_Renewal {
$pay_url = add_query_arg( array( $this->cart_item_key => 'true' ), $pay_url );
}
- return $pay_url;
+ return $pay_url; // nosemgrep: audit.php.wp.security.xss.query-arg -- False positive. $pay_url should be escaped at the point of output or usage. Keep the URL in tact for functions hooked in further down the chain.
}
/**
* Customise which actions are shown against a subscription renewal order on the My Account page.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function filter_my_account_my_orders_actions( $actions, $order ) {
@@ -641,7 +641,7 @@ class WCS_Cart_Renewal {
* so that we can correctly identify the status change in @see self::maybe_change_subscription_status().
*
* @param string Default order status for orders paid for via checkout. Default 'pending'
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function maybe_preserve_order_status( $order_status ) {
@@ -666,7 +666,7 @@ class WCS_Cart_Renewal {
* Removes all the linked renewal/resubscribe items from the cart if a renewal/resubscribe item is removed.
*
* @param string $cart_item_key The cart item key of the item removed from the cart.
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function maybe_remove_items( $cart_item_key ) {
@@ -701,7 +701,7 @@ class WCS_Cart_Renewal {
*
* @see wcs_cart_contains_renewal()
* @return bool | Array The cart item containing the renewal, else false.
- * @since 2.0.10
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.10
*/
protected function cart_contains() {
return wcs_cart_contains_renewal();
@@ -714,7 +714,7 @@ class WCS_Cart_Renewal {
* @param string $product_title
* @param $cart_item
* @return string $product_title
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function items_removed_title( $product_title, $cart_item ) {
@@ -730,7 +730,7 @@ class WCS_Cart_Renewal {
* Restores all linked renewal/resubscribe items to the cart if the customer has restored one.
*
* @param string $cart_item_key The cart item key of the item being restored to the cart.
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function maybe_restore_items( $cart_item_key ) {
@@ -759,7 +759,7 @@ class WCS_Cart_Renewal {
* @param array $data the coupon data
* @param string $code the coupon code that data is being requested for
* @return array the custom coupon data
- * @since 2.0.10
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.10
*/
public function renewal_coupon_data( $data, $code ) {
@@ -803,7 +803,7 @@ class WCS_Cart_Renewal {
*
* @param object WC_Order | WC_Subscription $order
* @return array $product_ids an array of product ids on a subscription/order
- * @since 2.0.10
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.10
*/
protected function get_products( $order ) {
@@ -826,7 +826,7 @@ class WCS_Cart_Renewal {
*
* @param int $subscription_id subscription id
* @param object $coupon coupon
- * @since 2.0.10
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.10
*/
protected function store_coupon( $order_id, $coupon ) {
if ( ! empty( $order_id ) && ! empty( $coupon ) ) {
@@ -888,7 +888,7 @@ class WCS_Cart_Renewal {
/**
* Clear renewal coupons - protects against confusing customer facing notices if customers add one renewal order to the cart with a set of coupons and then decide to add another renewal order with a different set of coupons
*
- * @since 2.0.10
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.10
*/
public function clear_coupons() {
@@ -911,7 +911,7 @@ class WCS_Cart_Renewal {
* Add order/subscription fee line items to the cart when a renewal order, initial order or resubscribe is in the cart.
*
* @param WC_Cart $cart
- * @since 2.0.13
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.13
*/
public function maybe_add_fees( $cart ) {
@@ -925,7 +925,7 @@ class WCS_Cart_Renewal {
*
* @param WC_Order $order is renderd by reference - change meta data of this object
* @param WC_Cart $cart
- * @since 2.2.9
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.9
*/
do_action( 'woocommerce_adjust_order_fees_for_setup_cart_for_' . $this->cart_item_key, $order, $cart );
@@ -942,7 +942,7 @@ class WCS_Cart_Renewal {
* a renewal or resubscribe, do not adjust the price because the original order's price will
* be used, and this includes the addons amounts.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function product_addons_adjust_price( $adjust_price, $cart_item ) {
@@ -958,7 +958,7 @@ class WCS_Cart_Renewal {
*
* @param Array The renewal cart item.
* @return WC_Order | The order object
- * @since 2.0.13
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.13
*/
protected function get_order( $cart_item = '' ) {
$order = false;
@@ -979,7 +979,7 @@ class WCS_Cart_Renewal {
* order items haven't changed by checking for a cart hash on the order, so we need to set
* that here. @see WC_Checkout::create_order()
*
- * @since 2.0.14
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.14
*/
protected function set_cart_hash( $order_id ) {
$order = wc_get_order( $order_id );
@@ -1000,7 +1000,7 @@ class WCS_Cart_Renewal {
*
* @param Mixed | An order generated by third party plugins
* @return Mixed | The unchanged order param
- * @since 2.2.11
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.11
*/
public function update_cart_hash( $order ) {
@@ -1025,16 +1025,23 @@ class WCS_Cart_Renewal {
/**
* Redirect back to pay for an order after successfully logging in.
*
- * @param string | redirect URL after successful login
+ * @param string The redirect URL after successful login.
+ * @param WP_User The newly logged in user object.
* @return string
- * @since 2.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1.0
*/
- function maybe_redirect_after_login( $redirect ) {
- if ( isset( $_GET['wcs_redirect'], $_GET['wcs_redirect_id'] ) && 'pay_for_order' == $_GET['wcs_redirect'] ) {
+ public function maybe_redirect_after_login( $redirect, $user = null ) {
+ /**
+ * Nonce verification is not needed here as it was already checked during the log-in process, see WC_Form_Handler::process_login().
+ */
+ if ( isset( $_GET['wcs_redirect'], $_GET['wcs_redirect_id'] ) && 'pay_for_order' === $_GET['wcs_redirect'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$order = wc_get_order( $_GET['wcs_redirect_id'] );
- if ( $order ) {
+ if ( $order && $order->get_user_id() && user_can( $user, 'pay_for_order', $order->get_id() ) ) {
$redirect = $order->get_checkout_payment_url();
+ } else {
+ // Remove the wcs_redirect query args if the user doesn't have permission to pay for the order.
+ $redirect = remove_query_arg( array( 'wcs_redirect', 'wcs_redirect_id' ), $redirect );
}
}
@@ -1048,7 +1055,7 @@ class WCS_Cart_Renewal {
* WCS_Cart_Renewal->update_line_item_cart_data() for WC < 3.0), are also reflected
* in the session cart.
*
- * @since 2.1.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1.3
*/
public function update_session_cart_after_updating_renewal_order() {
@@ -1066,7 +1073,7 @@ class WCS_Cart_Renewal {
* @param bool Whether to apply the dynamic discount
* @param string The cart item key of the cart item the dynamic discount is being applied to.
* @return bool
- * @since 2.1.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1.4
*/
function prevent_compounding_dynamic_discounts( $adjust_price, $cart_item_key ) {
@@ -1086,7 +1093,7 @@ class WCS_Cart_Renewal {
* @param WC_Order_Item_Product $order_item
* @param string $cart_item_key The hash used to identify the item in the cart
* @param array $cart_item The cart item's data.
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
public function add_line_item_meta( $order_item, $cart_item_key, $cart_item ) {
if ( isset( $cart_item[ $this->cart_item_key ] ) ) {
@@ -1101,7 +1108,7 @@ class WCS_Cart_Renewal {
*
* @param int|WC_Order $order_id
* @param array $checkout_posted_data
- * @since 2.2.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.1
*/
public function set_order_item_id( $order_id, $posted_checkout_data = array() ) {
@@ -1127,7 +1134,7 @@ class WCS_Cart_Renewal {
*
* @param string $cart_item_key
* @param int $order_item_id
- * @since 2.2.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.1
*/
protected function set_cart_item_order_item_id( $cart_item_key, $order_item_id ) {
WC()->cart->cart_contents[ $cart_item_key ][ $this->cart_item_key ]['line_item_id'] = $order_item_id;
@@ -1136,7 +1143,7 @@ class WCS_Cart_Renewal {
/**
* Do not display cart item key order item meta keys unless Subscriptions is in debug mode.
*
- * @since 2.2.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.1
*/
public function hidden_order_itemmeta( $hidden_meta_keys ) {
@@ -1153,28 +1160,31 @@ class WCS_Cart_Renewal {
*
* @param int $customer_id
* @param array $checkout_data the posted checkout data
- * @since 2.2.7
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.7
*/
public function maybe_update_subscription_address_data( $customer_id, $checkout_data ) {
$cart_renewal_item = $this->cart_contains();
if ( false !== $cart_renewal_item ) {
- $subscription = wcs_get_subscription( $cart_renewal_item[ $this->cart_item_key ]['subscription_id'] );
- $billing_address = $shipping_address = array();
- foreach ( array( 'billing', 'shipping' ) as $address_type ) {
+ $subscription = wcs_get_subscription( $cart_renewal_item[ $this->cart_item_key ]['subscription_id'] );
+ $subscription_updated = false;
+
+ foreach ( [ 'billing', 'shipping' ] as $address_type ) {
$checkout_fields = WC()->checkout()->get_checkout_fields( $address_type );
if ( is_array( $checkout_fields ) ) {
foreach ( array_keys( $checkout_fields ) as $field ) {
- if ( isset( $checkout_data[ $field ] ) ) {
- $field_name = str_replace( $address_type . '_', '', $field );
- ${$address_type . '_address'}[ $field_name ] = $checkout_data[ $field ];
+ if ( isset( $checkout_data[ $field ] ) && is_callable( [ $subscription, "set_$field" ] ) ) {
+ $subscription->{"set_$field"}( $checkout_data[ $field ] );
+ $subscription_updated = true;
}
}
}
}
- $subscription->set_address( $billing_address, 'billing' );
- $subscription->set_address( $shipping_address, 'shipping' );
+
+ if ( $subscription_updated ) {
+ $subscription->save();
+ }
}
}
@@ -1198,10 +1208,17 @@ class WCS_Cart_Renewal {
$customer->{"set_billing_$key"}( $value );
}
}
- // Billing address is a required field.
- $subscription->set_address( $request['billing_address'], 'billing' );
- // If shipping address (optional field) was not provided, set it to the given billing address (required field).
- $subscription->set_address( $request['shipping_address'] ?? $request['billing_address'], 'shipping' );
+
+ // Save Billing & Shipping addresses. Billing address is a required field, if shipping address (optional field) was not provided, set it to the given billing address.
+ if ( wcs_is_woocommerce_pre( '7.1' ) ) {
+ $subscription->set_address( $request['billing_address'], 'billing' );
+ $subscription->set_address( $request['shipping_address'] ?? $request['billing_address'], 'shipping' );
+ } else {
+ $subscription->set_billing_address( $request['billing_address'] );
+ $subscription->set_shipping_address( $request['shipping_address'] ?? $request['billing_address'] );
+
+ $subscription->save();
+ }
}
}
@@ -1210,7 +1227,7 @@ class WCS_Cart_Renewal {
*
* @param array $cart_item_data
* @param array $cart_item
- * @since 2.2.11
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.11
*/
public function display_line_item_data_in_cart( $cart_item_data, $cart_item ) {
@@ -1236,7 +1253,7 @@ class WCS_Cart_Renewal {
*
* @param int $item_id
* @param array $cart_item_data
- * @since 2.2.11
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.11
*/
public function add_order_item_meta( $item_id, $cart_item_data ) {
if ( ! empty( $cart_item_data[ $this->cart_item_key ]['custom_line_item_meta'] ) ) {
@@ -1255,7 +1272,7 @@ class WCS_Cart_Renewal {
* @param WC_Order_Item_Product
* @param string $cart_item_key
* @param array $cart_item_data
- * @since 2.2.11
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.11
*/
public function add_order_line_item_meta( $item, $cart_item_key, $cart_item_data ) {
if ( ! empty( $cart_item_data[ $this->cart_item_key ]['custom_line_item_meta'] ) ) {
@@ -1309,7 +1326,7 @@ class WCS_Cart_Renewal {
* Filters the shipping packages to remove subscriptions that have "one time shipping" enabled and, as such,
* shouldn't have a shipping amount associated during a renewal.
*
- * @since 2.3.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.3
*/
public function maybe_update_shipping_packages( $packages ) {
if ( ! $this->cart_contains() ) {
@@ -1337,7 +1354,7 @@ class WCS_Cart_Renewal {
* or add pseudo coupon equivalents if the coupons no longer exist.
*
* @param WC_Order $order The order to copy coupons and discounts from.
- * @since 2.4.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.4.3
*/
public function setup_discounts( $order ) {
$order_discount = $order->get_total_discount();
@@ -1464,7 +1481,7 @@ class WCS_Cart_Renewal {
* Makes sure a renewal order's "created via" meta is not changed to "checkout" by WC during checkout.
*
* @param WC_Order $order
- * @since 2.5.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.4
*/
public function maybe_preserve_order_created_via( $order ) {
$changes = $order->get_changes();
@@ -1479,7 +1496,7 @@ class WCS_Cart_Renewal {
/**
* Deteremines if the cart should honor the granfathered subscription/order line item total.
*
- * @since 3.0.10
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.0.10
*
* @param array $cart_item The cart item to check.
* @return bool Whether the cart should honor the order's prices.
@@ -1491,7 +1508,7 @@ class WCS_Cart_Renewal {
/**
* Disables renewal cart stock validation if the store has switched it off via a filter.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
public function maybe_disable_manual_renewal_stock_validation() {
if ( apply_filters( 'woocommerce_subscriptions_disable_manual_renewal_stock_validation', false ) ) {
@@ -1502,7 +1519,7 @@ class WCS_Cart_Renewal {
/**
* Overrides the place order button text on the checkout when the cart contains renewal order items, exclusively.
*
- * @since 3.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
*
* @param string $place_order_text The place order button text.
* @return string The place order button text. 'Renew subscription' if the cart contains only renewals, otherwise the default.
@@ -1578,7 +1595,7 @@ class WCS_Cart_Renewal {
/**
* For subscription renewal via cart, use original order discount
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function set_renewal_discounts( $cart ) {
_deprecated_function( __METHOD__, '2.0.10', 'Applying original subscription discounts to renewals via cart are now handled within ' . __CLASS__ . '::maybe_setup_cart()' );
@@ -1589,7 +1606,7 @@ class WCS_Cart_Renewal {
*
* No longer required as of 1.3.5 as totals are calculated correctly internally.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function get_discounted_price_for_renewal( $price, $cart_item, $cart ) {
_deprecated_function( __METHOD__, '2.0.10', 'No longer required as of 1.3.5 as totals are calculated correctly internally.' );
@@ -1599,7 +1616,7 @@ class WCS_Cart_Renewal {
* Add subscription fee line items to the cart when a renewal order or resubscribe is in the cart.
*
* @param WC_Cart $cart
- * @since 2.0.10
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.10
*/
public function maybe_add_subscription_fees( $cart ) {
_deprecated_function( __METHOD__, '2.0.13', __CLASS__ . '::maybe_add_fees()' );
@@ -1609,7 +1626,7 @@ class WCS_Cart_Renewal {
* After updating renewal order line items, update the values stored in cart item data
* which would now reference old line item IDs.
*
- * @since 2.1.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1.3
*/
public function update_line_item_cart_data( $item_id, $cart_item_data, $cart_item_key ) {
@@ -1630,8 +1647,8 @@ class WCS_Cart_Renewal {
* Used when WC 3.0 or newer is active. When prior versions are active,
* @see WCS_Cart_Renewal->update_line_item_cart_data()
*
- * @deprecated 2.2.1
- * @since 2.2.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
public function update_order_item_data_in_cart( $order_item, $cart_item_key, $cart_item ) {
_deprecated_function( __METHOD__, '2.2.1', __CLASS__ . '::add_line_item_meta( $order_item, $cart_item_key, $cart_item )' );
@@ -1644,7 +1661,7 @@ class WCS_Cart_Renewal {
*
* @param Mixed | An order generated by third party plugins
* @return Mixed | The unchanged order param
- * @since 2.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1.0
*/
public function set_renewal_order_cart_hash( $order ) {
_deprecated_function( __METHOD__, '2.3', __CLASS__ . '::update_cart_hash( $order )' );
@@ -1658,8 +1675,8 @@ class WCS_Cart_Renewal {
* @param WC_Subscription $subscription subscription
* @param WC_Order $order
*
- * @since 2.0.10
- * @deprecated 2.4.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.10
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.4.3
*/
public function maybe_setup_discounts( $subscription, $order = null ) {
wcs_deprecated_function( __METHOD__, '2.4.3' );
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wcs-cart-resubscribe.php b/vendor/woocommerce/subscriptions-core/includes/class-wcs-cart-resubscribe.php
index 3e6b5ec..d08702e 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wcs-cart-resubscribe.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wcs-cart-resubscribe.php
@@ -10,7 +10,7 @@
* @subpackage WCS_Cart_Resubscribe
* @category Class
* @author Prospress
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
class WCS_Cart_Resubscribe extends WCS_Cart_Renewal {
@@ -21,7 +21,7 @@ class WCS_Cart_Resubscribe extends WCS_Cart_Renewal {
/**
* Bootstraps the class and hooks required actions & filters.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function __construct() {
@@ -55,7 +55,7 @@ class WCS_Cart_Resubscribe extends WCS_Cart_Renewal {
* Checks if the current request is by a user to resubcribe to a subscription, and if it is setup a
* subscription resubcribe process via the cart for the product/variation/s that are being renewed.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function maybe_setup_cart() {
global $wp;
@@ -142,7 +142,7 @@ class WCS_Cart_Resubscribe extends WCS_Cart_Renewal {
* When creating an order at checkout, if the checkout is to resubscribe to an expired or cancelled
* subscription, make sure we record that on the order and new subscription.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function maybe_record_resubscribe( $new_subscription, $order, $recurring_cart ) {
@@ -158,7 +158,7 @@ class WCS_Cart_Resubscribe extends WCS_Cart_Renewal {
/**
* Restore renewal flag when cart is reset and modify Product object with renewal order related info
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function get_cart_item_from_session( $cart_item_session_data, $cart_item, $key ) {
if ( isset( $cart_item[ $this->cart_item_key ]['subscription_id'] ) ) {
@@ -186,7 +186,7 @@ class WCS_Cart_Resubscribe extends WCS_Cart_Renewal {
* If a product is being marked as not purchasable because it is limited and the customer has a subscription,
* but the current request is to resubscribe to the subscription, then mark it as purchasable.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
* @return bool
*/
public function is_purchasable( $is_purchasable, $product ) {
@@ -201,7 +201,7 @@ class WCS_Cart_Resubscribe extends WCS_Cart_Renewal {
* @see wcs_cart_contains_resubscribe()
* @param WC_Cart $cart The cart object to search in.
* @return bool | Array The cart item containing the renewal, else false.
- * @since 2.0.10
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.10
*/
protected function cart_contains( $cart = '' ) {
return wcs_cart_contains_resubscribe( $cart );
@@ -212,7 +212,7 @@ class WCS_Cart_Resubscribe extends WCS_Cart_Renewal {
*
* @param Array The resubscribe cart item.
* @return WC_Subscription | The subscription object.
- * @since 2.0.13
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.13
*/
protected function get_order( $cart_item = '' ) {
$subscription = false;
@@ -231,7 +231,7 @@ class WCS_Cart_Resubscribe extends WCS_Cart_Renewal {
/**
* Make sure that a resubscribe item's cart key is based on the end of the pre-paid term if the user already has a subscription that is pending-cancel, not the date calculated for the product.
*
- * @since 2.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1
*/
public function get_recurring_cart_key( $cart_key, $cart_item ) {
$subscription = $this->get_order( $cart_item );
@@ -248,7 +248,7 @@ class WCS_Cart_Resubscribe extends WCS_Cart_Renewal {
* Make sure when displaying the next payment date for a subscription, the date takes into
* account the end of the pre-paid term if the user is resubscribing to a subscription that is pending-cancel.
*
- * @since 2.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1
*/
public function recurring_cart_next_payment_date( $first_renewal_date, $cart ) {
foreach ( $cart->get_cart() as $cart_item ) {
@@ -266,7 +266,7 @@ class WCS_Cart_Resubscribe extends WCS_Cart_Renewal {
/**
* Make sure resubscribe cart item price doesn't include any recurring amount by setting a free trial.
*
- * @since 2.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1
* @param mixed $total This parameter is unused. Its sole purpose is for returning an unchanged variable while setting the mock trial when hooked onto filters. Optional.
* @return mixed $total The unchanged $total parameter.
*/
@@ -287,7 +287,7 @@ class WCS_Cart_Resubscribe extends WCS_Cart_Renewal {
/**
* Remove mock free trials from resubscribe cart items.
*
- * @since 2.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1
* @param mixed $total This parameter is unused. Its sole purpose is for returning an unchanged variable while unsetting the mock trial when hooked onto filters. Optional.
* @return mixed $total The unchanged $total parameter.
*/
@@ -308,7 +308,7 @@ class WCS_Cart_Resubscribe extends WCS_Cart_Renewal {
/**
* When the user resubscribes to a subscription that is pending-cancel, cancel the existing subscription.
*
- * @since 2.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1
*/
public function maybe_cancel_existing_subscription( $order_id, $old_order_status, $new_order_status ) {
if ( wcs_order_contains_subscription( $order_id ) && wcs_order_contains_resubscribe( $order_id ) ) {
@@ -327,7 +327,7 @@ class WCS_Cart_Resubscribe extends WCS_Cart_Renewal {
/**
* Overrides the place order button text on the checkout when the cart contains only resubscribe requests.
*
- * @since 3.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
*
* @param string $place_order_text The place order button text.
* @return string The place order button text. 'Resubscribe' if the cart contains only resubscribe requests, otherwise the default.
@@ -344,7 +344,7 @@ class WCS_Cart_Resubscribe extends WCS_Cart_Renewal {
/**
* Determines if the customer is resubscribe prior to the subscription being cancelled.
*
- * @since 3.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
*
* @param WC_Subscription $subscription
* @return bool
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wcs-change-payment-method-admin.php b/vendor/woocommerce/subscriptions-core/includes/class-wcs-change-payment-method-admin.php
index 6f2c4c2..e20a1f2 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wcs-change-payment-method-admin.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wcs-change-payment-method-admin.php
@@ -4,7 +4,7 @@
* edit subscription admin page.
*
* @class WCS_Change_Payment_Method_Admin
- * @version 2.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
* @package WooCommerce Subscriptions/Includes
* @category Class
* @author Prospress
@@ -15,7 +15,7 @@ class WCS_Change_Payment_Method_Admin {
/**
* Display the edit payment gateway option under
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function display_fields( $subscription ) {
@@ -103,7 +103,7 @@ class WCS_Change_Payment_Method_Admin {
* Get the new payment data from POST and check the new payment method supports
* the new admin change hook.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
* @param $subscription WC_Subscription
*/
public static function save_meta( $subscription ) {
@@ -157,7 +157,7 @@ class WCS_Change_Payment_Method_Admin {
/**
* Get a list of possible gateways that a subscription could be changed to by admins.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
* @param $subscription int | WC_Subscription
* @return
*/
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wcs-core-autoloader.php b/vendor/woocommerce/subscriptions-core/includes/class-wcs-core-autoloader.php
index 890283e..521ab5a 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wcs-core-autoloader.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wcs-core-autoloader.php
@@ -36,8 +36,6 @@ class WCS_Core_Autoloader {
/**
* Register the autoloader.
- *
- * @author Jeremy Pry
*/
public function register() {
spl_autoload_register( array( $this, 'autoload' ) );
@@ -53,8 +51,6 @@ class WCS_Core_Autoloader {
/**
* Autoload a class.
*
- * @author Jeremy Pry
- *
* @param string $class The class name to autoload.
*/
public function autoload( $class ) {
@@ -67,14 +63,14 @@ class WCS_Core_Autoloader {
$full_path = $this->get_class_base_path( $class ) . $this->get_relative_class_path( $class ) . $this->get_file_name( $class );
if ( is_readable( $full_path ) ) {
- require_once( $full_path );
+ require_once $full_path; // nosemgrep: audit.php.lang.security.file.inclusion-arg -- This is a safe file inclusion, since the autoloader is only used for classes in the includes dir.
}
}
/**
* Gets the base path for a given class.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
* @return string
*/
public function get_class_base_path( $class ) {
@@ -84,8 +80,6 @@ class WCS_Core_Autoloader {
/**
* Determine whether we should autoload a given class.
*
- * @author Jeremy Pry
- *
* @param string $class The class name.
*
* @return bool
@@ -102,8 +96,6 @@ class WCS_Core_Autoloader {
/**
* Convert the class name into an appropriate file name.
*
- * @author Jeremy Pry
- *
* @param string $class The class name.
*
* @return string The file name.
@@ -123,8 +115,6 @@ class WCS_Core_Autoloader {
/**
* Determine if the class is one of our abstract classes.
*
- * @author Jeremy Pry
- *
* @param string $class The class name.
*
* @return bool
@@ -175,12 +165,14 @@ class WCS_Core_Autoloader {
*/
protected function is_class_data_store( $class ) {
static $data_stores = array(
- 'wcs_related_order_store_cached_cpt' => true,
- 'wcs_related_order_store_cpt' => true,
- 'wcs_customer_store_cached_cpt' => true,
- 'wcs_customer_store_cpt' => true,
- 'wcs_product_variable_data_store_cpt' => true,
- 'wcs_subscription_data_store_cpt' => true,
+ 'wcs_orders_table_subscription_data_store' => true,
+ 'wcs_orders_table_data_store_controller' => true,
+ 'wcs_related_order_store_cached_cpt' => true,
+ 'wcs_related_order_store_cpt' => true,
+ 'wcs_customer_store_cached_cpt' => true,
+ 'wcs_customer_store_cpt' => true,
+ 'wcs_product_variable_data_store_cpt' => true,
+ 'wcs_subscription_data_store_cpt' => true,
);
return isset( $data_stores[ $class ] );
@@ -191,8 +183,6 @@ class WCS_Core_Autoloader {
*
* This handles all of the special class locations and exceptions.
*
- * @author Jeremy Pry
- *
* @param string $class The class name.
*
* @return string The relative path (from the plugin root) to the class file.
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wcs-custom-order-item-manager.php b/vendor/woocommerce/subscriptions-core/includes/class-wcs-custom-order-item-manager.php
index d4658db..0545af5 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wcs-custom-order-item-manager.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wcs-custom-order-item-manager.php
@@ -3,7 +3,7 @@
* Subscriptions Custom Order Item Manager
*
* @author Prospress
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
class WCS_Custom_Order_Item_Manager {
@@ -39,7 +39,7 @@ class WCS_Custom_Order_Item_Manager {
/**
* Initialise class hooks & filters when the file is loaded
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
public static function init() {
@@ -53,7 +53,7 @@ class WCS_Custom_Order_Item_Manager {
*
* @param array $type_to_group_list Existing list of types and their groups
* @return array $type_to_group_list
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
public static function add_extra_groups( $type_to_group_list ) {
@@ -70,7 +70,7 @@ class WCS_Custom_Order_Item_Manager {
* @param string $classname
* @param string $item_type
* @return string $classname
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
public static function map_classname_for_extra_items( $classname, $item_type ) {
@@ -86,7 +86,7 @@ class WCS_Custom_Order_Item_Manager {
*
* @param array $data_stores The registered data stores.
* @return array
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
public static function register_data_stores( $data_stores ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wcs-dependent-hook-manager.php b/vendor/woocommerce/subscriptions-core/includes/class-wcs-dependent-hook-manager.php
index 94db026..41e4997 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wcs-dependent-hook-manager.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wcs-dependent-hook-manager.php
@@ -7,7 +7,7 @@
* @package WooCommerce Subscriptions
* @category Class
* @author WooCommerce
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -26,7 +26,7 @@ class WCS_Dependent_Hook_Manager {
/**
* Initialise the class.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
public static function init() {
add_action( 'plugins_loaded', array( __CLASS__, 'attach_woocommerce_dependent_hooks' ) );
@@ -38,7 +38,7 @@ class WCS_Dependent_Hook_Manager {
* This attaches all the hooks registered via @see add_woocommerce_dependent_action()
* if the WooCommerce version requirements are met.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
public static function attach_woocommerce_dependent_hooks() {
if ( ! isset( self::$dependent_callbacks['woocommerce'] ) ) {
@@ -62,7 +62,7 @@ class WCS_Dependent_Hook_Manager {
/**
* Attach function callback if a certain WooCommerce version is present.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*
* @param string $tag The action or filter tag to attach the callback too.
* @param string|array $function The callable function to attach to the hook.
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wcs-download-handler.php b/vendor/woocommerce/subscriptions-core/includes/class-wcs-download-handler.php
index 3f2469e..cdfefcb 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wcs-download-handler.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wcs-download-handler.php
@@ -8,7 +8,7 @@
* @subpackage WCS_Download_Handler
* @category Class
* @author Prospress
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -20,7 +20,7 @@ class WCS_Download_Handler {
/**
* Initialize filters and hooks for class.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function init() {
add_action( 'woocommerce_grant_product_download_permissions', __CLASS__ . '::save_downloadable_product_permissions' );
@@ -31,11 +31,24 @@ class WCS_Download_Handler {
add_action( 'woocommerce_admin_created_subscription', array( __CLASS__, 'grant_download_permissions' ) );
- add_action( 'deleted_post', __CLASS__ . '::delete_subscription_permissions' );
+ add_action( 'woocommerce_loaded', [ __CLASS__, 'attach_wc_dependent_hooks' ] );
add_action( 'woocommerce_process_product_file_download_paths', __CLASS__ . '::grant_new_file_product_permissions', 11, 3 );
}
+ /**
+ * Attach hooks that depend on WooCommerce being loaded.
+ *
+ * @since 5.2
+ */
+ public static function attach_wc_dependent_hooks() {
+ if ( wcs_is_custom_order_tables_usage_enabled() ) {
+ add_action( 'woocommerce_delete_subscription', [ __CLASS__, 'delete_subscription_download_permissions' ] );
+ } else {
+ add_action( 'deleted_post', [ __CLASS__, 'delete_subscription_permissions' ] );
+ }
+ }
+
/**
* Save the download permissions on the individual subscriptions as well as the order. Hooked into
* 'woocommerce_grant_product_download_permissions', which is strictly after the order received all the info
@@ -72,7 +85,8 @@ class WCS_Download_Handler {
}
}
}
- update_post_meta( $subscription->get_id(), '_download_permissions_granted', 1 );
+
+ $subscription->get_data_store()->set_download_permissions_granted( $subscription, true );
}
}
@@ -143,25 +157,31 @@ class WCS_Download_Handler {
* Repairs a glitch in WordPress's save function. You cannot save a null value on update, see
* https://github.com/woocommerce/woocommerce/issues/7861 for more info on this.
*
- * @param integer $post_id The ID of the subscription
+ * @param integer $id The ID of the subscription
*/
- public static function repair_permission_data( $post_id ) {
- if ( absint( $post_id ) !== $post_id ) {
+ public static function repair_permission_data( $id ) {
+ if ( absint( $id ) !== $id ) {
return;
}
- if ( 'shop_subscription' !== get_post_type( $post_id ) ) {
+ if ( 'shop_subscription' !== WC_Data_Store::load( 'subscription' )->get_order_type( $id ) ) {
return;
}
global $wpdb;
- $wpdb->query( $wpdb->prepare( "
- UPDATE {$wpdb->prefix}woocommerce_downloadable_product_permissions
- SET access_expires = null
- WHERE order_id = %d
- AND access_expires = %s
- ", $post_id, '0000-00-00 00:00:00' ) );
+ $wpdb->query(
+ $wpdb->prepare(
+ "
+ UPDATE {$wpdb->prefix}woocommerce_downloadable_product_permissions
+ SET access_expires = null
+ WHERE order_id = %d
+ AND access_expires = %s
+ ",
+ $id,
+ '0000-00-00 00:00:00'
+ )
+ );
}
/**
@@ -169,7 +189,7 @@ class WCS_Download_Handler {
* Hooked into 'woocommerce_admin_created_subscription' to grant permissions to admin created subscriptions.
*
* @param WC_Subscription $subscription
- * @since 2.4.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.4.2
*/
public static function grant_download_permissions( $subscription ) {
wc_downloadable_product_permissions( $subscription->get_id() );
@@ -178,16 +198,28 @@ class WCS_Download_Handler {
/**
* Remove download permissions attached to a subscription when it is permenantly deleted.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
+ *
+ * @param $id The ID of the subscription whose downloadable product permission being deleted.
*/
- public static function delete_subscription_permissions( $post_id ) {
- global $wpdb;
-
- if ( 'shop_subscription' == get_post_type( $post_id ) ) {
- $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions WHERE order_id = %d", $post_id ) );
+ public static function delete_subscription_permissions( $id ) {
+ if ( 'shop_subscription' === WC_Data_Store::load( 'subscription' )->get_order_type( $id ) ) {
+ self::delete_subscription_download_permissions( $id );
}
}
+ /**
+ * Remove download permissions attached to a subscription when it is permenantly deleted.
+ *
+ * @since 5.2.0
+ *
+ * @param $id The ID of the subscription whose downloadable product permission being deleted.
+ */
+ public static function delete_subscription_download_permissions( $id ) {
+ global $wpdb;
+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions WHERE order_id = %d", $id ) );
+ }
+
/**
* Grant downloadable file access to any newly added files on any existing subscriptions
* which don't have existing permissions pre WC3.0 and all subscriptions post WC3.0.
@@ -195,7 +227,7 @@ class WCS_Download_Handler {
* @param int $product_id
* @param int $variation_id
* @param array $downloadable_files product downloadable files
- * @since 2.0.18
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.18
*/
public static function grant_new_file_product_permissions( $product_id, $variation_id, $downloadable_files ) {
global $wpdb;
@@ -242,14 +274,14 @@ class WCS_Download_Handler {
* When adding new downloadable content to a subscription product, check if we don't
* want to automatically add the new downloadable files to the subscription or initial and renewal orders.
*
- * @deprecated 4.0.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*
* @param bool $grant_access
* @param string $download_id
* @param int $product_id
* @param WC_Order $order
* @return bool
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function maybe_revoke_immediate_access( $grant_access, $download_id, $product_id, $order ) {
wcs_deprecated_function( __METHOD__, '4.0.0', 'WCS_Drip_Downloads_Manager::maybe_revoke_immediate_access() if available' );
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wcs-failed-scheduled-action-manager.php b/vendor/woocommerce/subscriptions-core/includes/class-wcs-failed-scheduled-action-manager.php
index 963b9a0..6945e26 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wcs-failed-scheduled-action-manager.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wcs-failed-scheduled-action-manager.php
@@ -2,7 +2,7 @@
/**
* Failed Scheduled Action Manager for subscription events
*
- * @version 2.2.19
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.19
* @package WooCommerce Subscriptions
* @category Class
* @author Prospress
@@ -39,7 +39,7 @@ class WCS_Failed_Scheduled_Action_Manager {
*
* @param WC_Logger_Interface $logger The WC Logger instance.
*
- * @since 2.2.19
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.19
*/
public function __construct( WC_Logger_Interface $logger ) {
$this->logger = $logger;
@@ -48,7 +48,7 @@ class WCS_Failed_Scheduled_Action_Manager {
/**
* Attach callbacks.
*
- * @since 2.2.19
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.19
*/
public function init() {
add_action( 'action_scheduler_failed_action', array( $this, 'log_action_scheduler_failure' ), 10, 2 );
@@ -61,7 +61,7 @@ class WCS_Failed_Scheduled_Action_Manager {
* Log a message to the failed-scheduled-actions log.
*
* @param string $message the message to be written to the log.
- * @since 2.2.19
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.19
*/
protected function log( $message ) {
$this->logger->add( 'failed-scheduled-actions', $message );
@@ -72,7 +72,7 @@ class WCS_Failed_Scheduled_Action_Manager {
*
* @param int $action_id The ID of the action which failed.
* @param int|Exception|array $error The number of seconds an action timeouts out after or the exception/error that caused the error/shutdown.
- * @since 2.2.19
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.19
*/
public function log_action_scheduler_failure( $action_id, $error ) {
$action = $this->get_action( $action_id );
@@ -111,7 +111,7 @@ class WCS_Failed_Scheduled_Action_Manager {
/**
* Display an admin notice when a scheduled action failure has occurred.
*
- * @since 2.2.19
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.19
*/
public function maybe_show_admin_notice() {
@@ -139,7 +139,7 @@ class WCS_Failed_Scheduled_Action_Manager {
}
if ( $id ) {
- $subject = '
#' . $id . ' ';
+ $subject = '
#' . $id . ' ';
} else {
$subject = 'unknown';
}
@@ -171,7 +171,7 @@ class WCS_Failed_Scheduled_Action_Manager {
/**
* Handle requests to disable the failed scheduled actions admin notice.
*
- * @since 2.2.19
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.19
*/
protected function maybe_disable_admin_notice() {
if ( isset( $_GET['_wcsnonce'] ) && wp_verify_nonce( $_GET['_wcsnonce'], 'wcs_scheduled_action_timeout_error_notice' ) && isset( $_GET['wcs_scheduled_action_timeout_error_notice'] ) ) {
@@ -184,7 +184,7 @@ class WCS_Failed_Scheduled_Action_Manager {
*
* @param string $hook the scheduled action hook
* @return string
- * @since 2.2.19
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.19
*/
protected function get_action_hook_label( $hook ) {
return str_replace( array( 'woocommerce_scheduled_', '_' ), array( '', ' ' ), $hook );
@@ -195,7 +195,7 @@ class WCS_Failed_Scheduled_Action_Manager {
*
* @param mixed $args the scheduled action args
* @return string
- * @since 2.2.19
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.19
*/
protected function get_action_args_string( $args ) {
$args_string = $separator = '';
@@ -215,7 +215,7 @@ class WCS_Failed_Scheduled_Action_Manager {
*
* @param int $action_id the scheduled action ID
* @return ActionScheduler_Action
- * @since 2.2.19
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.19
*/
protected function get_action( $action_id ) {
$store = ActionScheduler_Store::instance();
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wcs-initial-cart-stock-manager.php b/vendor/woocommerce/subscriptions-core/includes/class-wcs-initial-cart-stock-manager.php
index 2d29267..84546eb 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wcs-initial-cart-stock-manager.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wcs-initial-cart-stock-manager.php
@@ -8,7 +8,7 @@
* @package WooCommerce Subscriptions
* @category Class
* @author Automattic
- * @since 3.0.6
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.0.6
*/
defined( 'ABSPATH' ) || exit;
@@ -18,7 +18,7 @@ class WCS_Initial_Cart_Stock_Manager extends WCS_Renewal_Cart_Stock_Manager {
/**
* Bootstraps the class and hooks required actions & filters.
*
- * @since 3.0.6
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.0.6
*/
public static function attach_callbacks() {
parent::attach_callbacks();
@@ -31,7 +31,7 @@ class WCS_Initial_Cart_Stock_Manager extends WCS_Renewal_Cart_Stock_Manager {
/**
* Gets the parent order from the cart.
*
- * @since 3.0.6
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.0.6
* @return WC_Order|bool Parent order obtained from the cart contents or false if the cart doesn't contain a parent order which has handled stock.
*/
protected static function get_order_from_cart() {
@@ -56,7 +56,7 @@ class WCS_Initial_Cart_Stock_Manager extends WCS_Renewal_Cart_Stock_Manager {
/**
* Gets the parent order from order-pay query vars.
*
- * @since 3.0.6
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.0.6
* @return WC_Order|bool Parent order obtained from query vars or false if not set or if no handling is required.
*/
protected static function get_order_from_query_vars() {
@@ -77,7 +77,7 @@ class WCS_Initial_Cart_Stock_Manager extends WCS_Renewal_Cart_Stock_Manager {
/**
* Checks if an order has already reduced stock.
*
- * @since 3.0.6
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.0.6
* @param WC_Order $order
* @return bool Whether the order has reduced stock.
*/
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wcs-limiter.php b/vendor/woocommerce/subscriptions-core/includes/class-wcs-limiter.php
index 7651700..f5bcd22 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wcs-limiter.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wcs-limiter.php
@@ -4,7 +4,7 @@
*
* @package WooCommerce Subscriptions
* @category Class
- * @since 2.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1
*/
class WCS_Limiter {
@@ -32,7 +32,7 @@ class WCS_Limiter {
/**
* Adds limit options to 'Edit Product' screen.
*
- * @since 2.1 Moved from WC_Subscriptions_Admin
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1, Moved from WC_Subscriptions_Admin
*/
public static function admin_edit_product_fields() {
global $post;
@@ -61,7 +61,7 @@ class WCS_Limiter {
/**
* Canonical is_purchasable method to be called by product classes.
*
- * @since 2.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1
* @param bool $purchasable Whether the product is purchasable as determined by parent class
* @param mixed $product The product in question to be checked if it is purchasable.
*
@@ -102,7 +102,7 @@ class WCS_Limiter {
/**
* If a product is limited and the customer already has a subscription, mark it as not purchasable.
*
- * @since 2.1 Moved from WC_Subscriptions_Product
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1, Moved from WC_Subscriptions_Product
* @return bool
*/
public static function is_purchasable_product( $is_purchasable, $product ) {
@@ -131,7 +131,7 @@ class WCS_Limiter {
* If a product is being marked as not purchasable because it is limited and the customer has a subscription,
* but the current request is to switch the subscription, then mark it as purchasable.
*
- * @since 2.1 Moved from WC_Subscriptions_Switcher::is_purchasable
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1, Moved from WC_Subscriptions_Switcher::is_purchasable
* @return bool
*/
public static function is_purchasable_switch( $is_purchasable, $product ) {
@@ -192,7 +192,7 @@ class WCS_Limiter {
/**
* Determines whether a product is purchasable based on whether the cart is to resubscribe or renew.
*
- * @since 2.1 Combines WCS_Cart_Renewal::is_purchasable and WCS_Cart_Resubscribe::is_purchasable
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1, Combines WCS_Cart_Renewal::is_purchasable and WCS_Cart_Resubscribe::is_purchasable
* @return bool
*/
public static function is_purchasable_renewal( $is_purchasable, $product ) {
@@ -227,7 +227,7 @@ class WCS_Limiter {
/**
* Check if the current session has an order awaiting payment for a subscription to a specific product line item.
*
- * @since 2.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1.0
* @param int $product_id The product to look for a subscription awaiting payment.
* @return bool
**/
@@ -280,7 +280,7 @@ class WCS_Limiter {
*
* This function will return no statuses if the order contains non purchasable or limited products.
*
- * @since 3.0.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.0.2
*
* @param array $statuses The order statuses that enable the order again button.
* @return array $statuses An empty array if the order contains limited products, otherwise the default statuses are returned.
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wcs-modal.php b/vendor/woocommerce/subscriptions-core/includes/class-wcs-modal.php
index a329b5d..6d2ea96 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wcs-modal.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wcs-modal.php
@@ -4,7 +4,7 @@
*
* @package WooCommerce Subscriptions
* @category Class
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
@@ -56,7 +56,7 @@ class WCS_Modal {
*
* The required files will only be enqueued once. Subsequent calls will do nothing.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
public static function register_scripts_and_styles() {
static $registered = false;
@@ -80,17 +80,17 @@ class WCS_Modal {
/**
* Enqueues the modal scripts and styles.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
public static function enqueue_scripts_and_styles() {
- wp_enqueue_script( 'wcs-modal-scripts', WC_Subscriptions_Core_Plugin::instance()->get_subscriptions_core_directory_url( 'assets/js/modal.js' ), array( 'jquery' ), WC_Subscriptions_Core_Plugin::instance()->get_plugin_version(), true );
- wp_enqueue_style( 'wcs-modal-styles', WC_Subscriptions_Core_Plugin::instance()->get_subscriptions_core_directory_url( 'assets/css/modal.css' ), array( 'dashicons' ), WC_Subscriptions_Core_Plugin::instance()->get_plugin_version() );
+ wp_enqueue_script( 'wcs-modal-scripts', WC_Subscriptions_Core_Plugin::instance()->get_subscriptions_core_directory_url( 'assets/js/modal.js' ), array( 'jquery' ), WC_Subscriptions_Core_Plugin::instance()->get_library_version(), true );
+ wp_enqueue_style( 'wcs-modal-styles', WC_Subscriptions_Core_Plugin::instance()->get_subscriptions_core_directory_url( 'assets/css/modal.css' ), array( 'dashicons' ), WC_Subscriptions_Core_Plugin::instance()->get_library_version() );
}
/**
* Constructor.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*
* @param string|callable $content The content to display in the modal. This should be a string when $content_type is either 'plain-text' or 'html',
* a WooCommerce template filename when $content_type is 'template' or a function that echoes out the content when $content_type is 'callback'.
@@ -121,7 +121,7 @@ class WCS_Modal {
/**
* Prints the modal HTML.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
public function print_html() {
wc_get_template( 'html-modal.php', array( 'modal' => $this ), '', WC_Subscriptions_Core_Plugin::instance()->get_subscriptions_core_directory( 'templates/' ) );
@@ -130,7 +130,7 @@ class WCS_Modal {
/**
* Prints the modal inner content.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
public function print_content() {
switch ( $this->content_type ) {
@@ -152,7 +152,7 @@ class WCS_Modal {
/**
* Determines if the modal has a heading.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*
* @return bool
*/
@@ -163,7 +163,7 @@ class WCS_Modal {
/**
* Determines if the modal has actions.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*
* @return bool
*/
@@ -174,7 +174,7 @@ class WCS_Modal {
/**
* Adds a button or link action which will be printed in the modal footer.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*
* @param array $action_args {
* Action button or link details.
@@ -199,7 +199,7 @@ class WCS_Modal {
/**
* Returns the modal heading.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*
* @return string
*/
@@ -210,7 +210,7 @@ class WCS_Modal {
/**
* Returns the array of actions.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*
* @return array The modal actions.
*/
@@ -221,7 +221,7 @@ class WCS_Modal {
/**
* Returns the modal's trigger selector.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*
* @return string The trigger element's selector.
*/
@@ -232,7 +232,7 @@ class WCS_Modal {
/**
* Returns a flattened string of HTML element attributes from an array of attributes and values.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*
* @param array $attributes An array of attributes in a array( 'attribute' => 'value' ) or array( 'attribute' => array( 'value', 'value ) ).
* @return string
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wcs-my-account-auto-renew-toggle.php b/vendor/woocommerce/subscriptions-core/includes/class-wcs-my-account-auto-renew-toggle.php
index 24aa1c1..8fd707f 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wcs-my-account-auto-renew-toggle.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wcs-my-account-auto-renew-toggle.php
@@ -5,7 +5,7 @@
* @package WooCommerce Subscriptions
* @category Class
* @author Prospress
- * @since 2.5.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.0
*/
class WCS_My_Account_Auto_Renew_Toggle {
@@ -19,7 +19,7 @@ class WCS_My_Account_Auto_Renew_Toggle {
/**
* Initialize filters and hooks for class.
*
- * @since 2.5.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.0
*/
public static function init() {
self::$setting_id = WC_Subscriptions_Admin::$option_prefix . '_enable_auto_renewal_toggle';
@@ -34,7 +34,7 @@ class WCS_My_Account_Auto_Renew_Toggle {
*
* @param WC_Subscription $subscription The subscription for which the checks for auto-renewal needs to be made
* @return boolean
- * @since 2.5.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.0
*/
public static function can_subscription_auto_renewal_be_changed( $subscription ) {
@@ -65,7 +65,7 @@ class WCS_My_Account_Auto_Renew_Toggle {
/**
* Determines if a subscription is eligible for toggling auto renewal and whether the user, or current user has permission to do so.
*
- * @since 3.0.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.0.1
*
* @param WC_Subscription $subscription The subscription to check if auto renewal is allowed.
* @param int $user_id The user ID to check if they have permission. Optional. Default is current user.
@@ -83,7 +83,7 @@ class WCS_My_Account_Auto_Renew_Toggle {
/**
* Disable auto renewal of subscription
*
- * @since 2.5.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.0
*/
public static function disable_auto_renew() {
@@ -107,7 +107,7 @@ class WCS_My_Account_Auto_Renew_Toggle {
/**
* Enable auto renewal of subscription
*
- * @since 2.5.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.0
*/
public static function enable_auto_renew() {
@@ -145,7 +145,7 @@ class WCS_My_Account_Auto_Renew_Toggle {
*
* @param array $settings
* @return array
- * @since 2.5.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.0
*/
public static function add_setting( $settings ) {
WC_Subscriptions_Admin::insert_setting_after( $settings, 'woocommerce_subscriptions_turn_off_automatic_payments', array(
@@ -164,7 +164,7 @@ class WCS_My_Account_Auto_Renew_Toggle {
* Checks if the store has enabled the auto-renewal toggle.
*
* @return bool true if the toggle is enabled, otherwise false.
- * @since 2.5.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.0
*/
public static function is_enabled() {
return 'yes' === get_option( self::$setting_id, 'no' );
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wcs-my-account-payment-methods.php b/vendor/woocommerce/subscriptions-core/includes/class-wcs-my-account-payment-methods.php
index 6b20c7e..330b4f0 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wcs-my-account-payment-methods.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wcs-my-account-payment-methods.php
@@ -5,14 +5,14 @@
* @package WooCommerce Subscriptions
* @category Class
* @author Prospress
- * @since 2.2.7
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.7
*/
class WCS_My_Account_Payment_Methods {
/**
* Initialize filters and hooks for class.
*
- * @since 2.2.7
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.7
*/
public static function init() {
// Only hook class functions if the payment token object exists
@@ -35,7 +35,7 @@ class WCS_My_Account_Payment_Methods {
* @param array data about the token including a list of actions which can be triggered by the customer from their my account page
* @param WC_Payment_Token payment token object
* @return array payment token data
- * @since 2.2.7
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.7
*/
public static function flag_subscription_payment_token_deletions( $payment_token_data, $payment_token ) {
@@ -59,7 +59,7 @@ class WCS_My_Account_Payment_Methods {
*
* Gateways can use this filter to make their own checks to allow deletion.
*
- * @since 3.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
*
* @param bool Whether the delete button should be shown for tokens linked to a subscription. true - show, false - not shown (default).
* @param WC_Payment_Token The payment token in question.
@@ -84,7 +84,7 @@ class WCS_My_Account_Payment_Methods {
}
}
- return $payment_token_data;
+ return $payment_token_data; // nosemgrep: audit.php.wp.security.xss.query-arg -- False positive. This URL is escaped in the WC template when the token links are outputted.
}
/**
@@ -94,7 +94,7 @@ class WCS_My_Account_Payment_Methods {
*
* @param int $deleted_token_id The deleted token id.
* @param WC_Payment_Token $deleted_token The deleted token object.
- * @since 2.2.7
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.7
*/
public static function maybe_update_subscriptions_payment_meta( $deleted_token_id, $deleted_token ) {
if ( ! isset( $_GET['delete_subscription_token'] ) || empty( $_GET['wcs_nonce'] ) || ! wp_verify_nonce( $_GET['wcs_nonce'], 'delete_subscription_token_' . $_GET['delete_subscription_token'] ) ) {
@@ -142,11 +142,11 @@ class WCS_My_Account_Payment_Methods {
/**
* Get a WC_Payment_Token label. eg Visa ending in 1234
*
- * @deprecated 2.7.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.7.2
*
* @param WC_Payment_Token payment token object
* @return string WC_Payment_Token label
- * @since 2.2.7
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.7
*/
public static function get_token_label( $token ) {
wcs_deprecated_function( __METHOD__, '2.7.2', '$token->get_display_name()' );
@@ -158,7 +158,7 @@ class WCS_My_Account_Payment_Methods {
*
* @param int $default_token_id The default token id.
* @param WC_Payment_Token $default_token The default token object.
- * @since 2.3.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.3
*/
public static function display_default_payment_token_change_notice( $default_token_id, $default_token ) {
global $wp;
@@ -202,7 +202,7 @@ class WCS_My_Account_Payment_Methods {
/**
* Update the customer's subscription tokens if they opted to from their My Account page.
*
- * @since 2.3.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.3
*/
public static function update_subscription_tokens() {
if ( ! isset( $_GET['update-subscription-tokens'], $_GET['token-id'], $_GET['_wcsnonce'] ) || ! wp_verify_nonce( $_GET['_wcsnonce'], 'wcs-update-subscription-tokens' ) ) {
@@ -238,7 +238,7 @@ class WCS_My_Account_Payment_Methods {
/**
* Enqueues the frontend scripts for the My account > Payment methods page.
*
- * @since 3.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
*/
public static function enqueue_frontend_scripts() {
if ( 'payment-methods' !== WC()->query->get_current_endpoint() ) {
@@ -261,7 +261,7 @@ class WCS_My_Account_Payment_Methods {
),
);
- wp_enqueue_script( 'wc-subscriptions-payment-methods', WC_Subscriptions_Core_Plugin::instance()->get_subscriptions_core_directory_url( 'assets/js/frontend/payment-methods.js' ), array( 'jquery' ), WC_Subscriptions_Core_Plugin::instance()->get_plugin_version(), true );
+ wp_enqueue_script( 'wc-subscriptions-payment-methods', WC_Subscriptions_Core_Plugin::instance()->get_subscriptions_core_directory_url( 'assets/js/frontend/payment-methods.js' ), array( 'jquery' ), WC_Subscriptions_Core_Plugin::instance()->get_library_version(), true );
wp_localize_script( 'wc-subscriptions-payment-methods', 'wcs_payment_methods', $script_params );
}
@@ -271,7 +271,7 @@ class WCS_My_Account_Payment_Methods {
* @see self::enqueue_frontend_scripts() For the error message content.
* @see self::flag_subscription_payment_token_deletions() For the determination of when a token cannot be deleted.
*
- * @since 3.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
*/
public static function print_deleting_notices() {
// The notice is hidden on load, and only shown when a token delete request is made.
@@ -284,8 +284,8 @@ class WCS_My_Account_Payment_Methods {
* Get subscriptions by a WC_Payment_Token. All automatic subscriptions with the token's payment method,
* customer id and token value stored in post meta will be returned.
*
- * @since 2.2.7
- * @deprecated 2.5.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.7
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.0
*/
public static function get_subscriptions_by_token( $payment_token ) {
_deprecated_function( __METHOD__, '2.5.0', 'WCS_Payment_Tokens::get_subscriptions_from_token()' );
@@ -295,8 +295,8 @@ class WCS_My_Account_Payment_Methods {
/**
* Get a list of customer payment tokens. Caches results to avoid multiple database queries per request
*
- * @since 2.2.7
- * @deprecated 2.5.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.7
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.0
*/
public static function get_customer_tokens( $gateway_id = '', $customer_id = '' ) {
_deprecated_function( __METHOD__, '2.5.0', 'WCS_Payment_Tokens::get_customer_tokens()' );
@@ -306,8 +306,8 @@ class WCS_My_Account_Payment_Methods {
/**
* Get the customer's alternative token.
*
- * @since 2.2.7
- * @deprecated 2.5.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.7
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.0
*/
public static function get_customers_alternative_token( $token ) {
_deprecated_function( __METHOD__, '2.5.0', 'WCS_Payment_Tokens::get_customers_alternative_token()' );
@@ -317,8 +317,8 @@ class WCS_My_Account_Payment_Methods {
/**
* Determine if the customer has an alternative token.
*
- * @since 2.2.7
- * @deprecated 2.5.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.7
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.0
*/
public static function customer_has_alternative_token( $token ) {
_deprecated_function( __METHOD__, '2.5.0', 'WCS_Payment_Tokens::customer_has_alternative_token()' );
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wcs-object-data-cache-manager-many-to-one.php b/vendor/woocommerce/subscriptions-core/includes/class-wcs-object-data-cache-manager-many-to-one.php
new file mode 100644
index 0000000..648d744
--- /dev/null
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wcs-object-data-cache-manager-many-to-one.php
@@ -0,0 +1,38 @@
+trigger_update_cache_hook( $change['type'], $object->get_id(), $key, $change['new'], $previous_value );
+ }
+}
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wcs-object-data-cache-manager.php b/vendor/woocommerce/subscriptions-core/includes/class-wcs-object-data-cache-manager.php
new file mode 100644
index 0000000..94439a6
--- /dev/null
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wcs-object-data-cache-manager.php
@@ -0,0 +1,333 @@
+object_type = $object_type;
+ $this->data_keys = $data_keys;
+ }
+
+ /**
+ * Attaches callbacks to keep the caches up-to-date.
+ */
+ public function init() {
+ add_action( "woocommerce_before_{$this->object_type}_object_save", [ $this, 'prepare_object_changes' ] );
+ add_action( "woocommerce_after_{$this->object_type}_object_save", [ $this, 'action_object_cache_changes' ] );
+
+ add_action( "woocommerce_before_delete_{$this->object_type}", [ $this, 'prepare_object_to_be_deleted' ], 10, 2 );
+ add_action( "woocommerce_delete_{$this->object_type}", [ $this, 'deleted' ] );
+
+ add_action( "woocommerce_before_trash_{$this->object_type}", [ $this, 'prepare_object_to_be_deleted' ], 10, 2 );
+ add_action( "woocommerce_trash_{$this->object_type}", [ $this, 'trashed' ] );
+
+ add_action( "woocommerce_untrash_{$this->object_type}", [ $this, 'untrashed' ] );
+ }
+
+ /**
+ * Generates a set of changes for tracked meta keys and properties.
+ *
+ * This method is hooked onto an action which is fired before the object is saved.
+ * Relevant changes to the object's data is stored in the $this->object_changes property
+ * to be processed after the object is saved. See $this->action_object_cache_changes().
+ *
+ * @param WC_Data $object The object which is being saved.
+ * @param string $generate_type Optional. The data to generate the changes from. Defaults to 'changes_only' which will generate the data from changes to the object. 'all_fields' will fetch data from the object for all tracked data keys.
+ */
+ public function prepare_object_changes( $object, $generate_type = 'changes_only' ) {
+ // If the object hasn't been created yet, we can't do anything yet. We'll have to wait until after the object is saved.
+ if ( ! $object->get_id() ) {
+ return;
+ }
+
+ $force_all_fields = 'all_fields' === $generate_type;
+ $changes = $object->get_changes();
+ $base_data = $object->get_base_data();
+ $meta_data = $object->get_meta_data();
+
+ // Deleted meta won't be included in the changes, so we need to fetch the previous value via the raw meta data.
+ $data_store = $object->get_data_store();
+ $raw_meta_data = $data_store->read_meta( $object );
+ $raw_meta_key_map = wp_list_pluck( $raw_meta_data, 'meta_key' );
+
+ // Record the object ID so we know that it has been handled in $this->action_object_cache_changes().
+ $this->object_changes[ $object->get_id() ] = [];
+
+ foreach ( $this->data_keys as $data_key ) {
+
+ // Check if the data key is a base property and if it has changed.
+ if ( isset( $changes[ $data_key ] ) ) {
+ $this->object_changes[ $object->get_id() ][ $data_key ] = [
+ 'new' => $changes[ $data_key ],
+ 'previous' => isset( $base_data[ $data_key ] ) ? $base_data[ $data_key ] : null,
+ 'type' => 'update',
+ ];
+
+ continue;
+ } elseif ( isset( $base_data[ $data_key ] ) && $force_all_fields ) {
+ // If we're forcing all fields, fetch the base data as the new value.
+ $this->object_changes[ $object->get_id() ][ $data_key ] = [
+ 'new' => $base_data[ $data_key ],
+ 'type' => 'add',
+ ];
+
+ continue;
+ }
+
+ // Check if the data key is stored as meta.
+ foreach ( $meta_data as $meta ) {
+ if ( $meta->key !== $data_key ) {
+ continue;
+ }
+
+ $previous_meta = $meta->get_data();
+
+ if ( empty( $meta->id ) ) {
+ // If the value is being added.
+ $this->object_changes[ $object->get_id() ][ $data_key ] = [
+ 'new' => $meta->value,
+ 'type' => 'add',
+ ];
+ } elseif ( $meta->get_changes() ) {
+ // If the value is being updated.
+ $this->object_changes[ $object->get_id() ][ $data_key ] = [
+ 'new' => $meta->value,
+ 'previous' => isset( $previous_meta['value'] ) ? $previous_meta['value'] : null,
+ 'type' => 'update',
+ ];
+ } elseif ( $force_all_fields ) {
+ // If we're forcing all fields to be recorded.
+ $this->object_changes[ $object->get_id() ][ $data_key ] = [
+ 'new' => $meta->value,
+ 'type' => 'add',
+ ];
+ }
+
+ // We've found the meta data for this data key, so we can move on to the next data key.
+ break 2;
+ }
+
+ // If we got this far, then the data key is stored as meta and has been deleted.
+ // When meta is deleted it won't be returned by $object->get_meta_data(). So we need to check the raw meta data.
+ if ( in_array( $data_key, $raw_meta_key_map, true ) ) {
+ $previous_meta = $raw_meta_data[ array_search( $data_key, $raw_meta_key_map, true ) ]->meta_value;
+ $this->object_changes[ $object->get_id() ][ $data_key ] = [
+ 'previous' => $previous_meta,
+ 'type' => 'delete',
+ ];
+ }
+ }
+ }
+
+ /**
+ * Actions all the tracked data changes that were made to the object by triggering the update cache hook.
+ *
+ * This method is hooked onto an action which is fired after the object is saved.
+ *
+ * @param WC_Data $object The object which was saved.
+ */
+ public function action_object_cache_changes( $object ) {
+ if ( ! $object->get_id() ) {
+ return;
+ }
+
+ /**
+ * If the object ID hasn't been recorded, this object must have just been created.
+ * Without an ID $this->prepare_object_changes() (ran pre-save) would have skipped it.
+ *
+ * Now that we have an ID, generate the data now and fetch all fields.
+ */
+ if ( ! isset( $this->object_changes[ $object->get_id() ] ) ) {
+ $this->prepare_object_changes( $object, 'all_fields' );
+ }
+
+ if ( empty( $this->object_changes[ $object->get_id() ] ) ) {
+ // No changes to record. Unset the object ID to 'reset' $this->object_changes' state.
+ unset( $this->object_changes[ $object->get_id() ] );
+ return;
+ }
+
+ $object_changes = $this->object_changes[ $object->get_id() ];
+ unset( $this->object_changes[ $object->get_id() ] );
+
+ foreach ( $object_changes as $key => $change ) {
+ $this->trigger_update_cache_hook_from_change( $object, $key, $change );
+ }
+ }
+
+ /**
+ * When an object is restored from the trash, action on object changes.
+ *
+ * @param int $object_id The object id being restored.
+ */
+ public function untrashed( $object_id ) {
+ $object = $this->get_object( $object_id );
+ if ( null === $object ) {
+ return;
+ }
+
+ $this->action_object_cache_changes( $object );
+ }
+
+ /**
+ * When an object is to be deleted, prepare object changes to update all fields
+ * and mark those changes as deletes.
+ *
+ * @param int $object_id The id of the object being deleted.
+ * @param mixed $object The object being deleted.
+ */
+ public function prepare_object_to_be_deleted( $object_id, $object ) {
+ if ( ! $object->get_id() ) {
+ return;
+ }
+
+ $this->prepare_object_changes( $object, 'all_fields' );
+
+ if ( ! isset( $this->object_changes[ $object->get_id() ] ) ) {
+ return;
+ }
+
+ // If the object is being deleted, we want to record all the changes as deletes.
+ foreach ( $this->object_changes[ $object->get_id() ] as $data_key => $data ) {
+ $this->object_changes[ $object->get_id() ][ $data_key ]['type'] = 'delete';
+
+ if ( ! isset( $this->object_changes[ $object->get_id() ][ $data_key ]['previous'] ) ) {
+ $this->object_changes[ $object->get_id() ][ $data_key ]['previous'] = $data['new'];
+ }
+
+ if ( isset( $this->object_changes[ $object->get_id() ][ $data_key ]['new'] ) ) {
+ unset( $this->object_changes[ $object->get_id() ][ $data_key ]['new'] );
+ }
+ }
+ }
+
+ /**
+ * When an object is trashed, action on object changes.
+ *
+ * @param int $object_id The id of object being restored.
+ */
+ public function trashed( $object_id ) {
+ $object = $this->get_object( $object_id );
+ if ( null === $object ) {
+ return;
+ }
+
+ $this->action_object_cache_changes( $object );
+ }
+
+ /**
+ * When an object has been deleted, trigger update cache hook on all the object changes.
+ * We cannot use action_object_cache_changes(), which requires an object, here because
+ * object has been deleted.
+ *
+ * @param int $object_id The id of the object being deleted.
+ */
+ public function deleted( $object_id ) {
+ if ( ! isset( $this->object_changes[ $object_id ] ) ) {
+ return;
+ }
+
+ $object_changes = $this->object_changes[ $object_id ];
+ unset( $this->object_changes[ $object_id ] );
+
+ foreach ( $object_changes as $key => $change ) {
+ $this->trigger_update_cache_hook( $change['type'], $object_id, $key, $change['previous'] );
+ }
+ }
+
+ /**
+ * Triggers the update cache hook for an object change.
+ *
+ * @param WC_Data $object The object that was changed.
+ * @param string $key The object's key that was changed. Can be a base property ('customer_id') or a meta key ('_subscription_renewal').
+ * @param array $change {
+ * Data about the change that was made to the object.
+ *
+ * @type mixed $new The new value.
+ * @type mixed $previous The previous value before it was changed.
+ * @type string $type The type of change. Can be 'update', 'add' or 'delete'.
+ * }
+ */
+ protected function trigger_update_cache_hook_from_change( $object, $key, $change ) {
+ switch ( $change['type'] ) {
+ case 'update':
+ $this->trigger_update_cache_hook( $change['type'], $object->get_id(), $key, $change['new'], $change['previous'] );
+ break;
+ case 'delete':
+ $this->trigger_update_cache_hook( $change['type'], $object->get_id(), $key, $change['previous'] );
+ break;
+ default:
+ $this->trigger_update_cache_hook( $change['type'], $object->get_id(), $key, $change['new'] );
+ break;
+ }
+ }
+
+ /**
+ * Fetches an instance of the object with the given ID.
+ *
+ * @param int $object_id The ID of the object to fetch.
+ *
+ * @return mixed The object instance, or null if it doesn't exist.
+ */
+ private function get_object( $id ) {
+ switch ( $this->object_type ) {
+ case 'order':
+ return wc_get_order( $id );
+ case 'subscription':
+ return wcs_get_subscription( $id );
+ default:
+ return apply_filters( "wcs_object_data_cache_manager_get_{$this->object_type}_object", null, $id );
+ }
+ }
+}
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wcs-object-sorter.php b/vendor/woocommerce/subscriptions-core/includes/class-wcs-object-sorter.php
index feba431..792a86c 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wcs-object-sorter.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wcs-object-sorter.php
@@ -5,7 +5,7 @@
* @author Prospress
* @category Class
* @package WooCommerce Subscriptions
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
class WCS_Object_Sorter {
@@ -22,7 +22,7 @@ class WCS_Object_Sorter {
/**
* Constructor.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*
* @param string $property The object property to use in comparisons. This will be used to generate the object getter by prepending 'get_'.
*/
@@ -35,7 +35,7 @@ class WCS_Object_Sorter {
*
* Designed to be used by uasort(), usort() or uksort() functions.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*
* @param object $object_one
* @param object $object_two
@@ -63,7 +63,7 @@ class WCS_Object_Sorter {
*
* Designed to be used by uasort(), or usort() style functions.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*
* @param object $object_one
* @param object $object_two
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wcs-payment-tokens.php b/vendor/woocommerce/subscriptions-core/includes/class-wcs-payment-tokens.php
index 85338dd..93fd6f1 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wcs-payment-tokens.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wcs-payment-tokens.php
@@ -7,7 +7,7 @@
* @package WooCommerce Subscriptions
* @category Class
* @author Prospress
- * @since 2.5.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -78,7 +78,7 @@ class WCS_Payment_Tokens extends WC_Payment_Tokens {
* @param WC_Subscription $subscription The subscription to update.
* @param string $gateway_id The target gateway ID.
* @return bool|array Payment meta data. False if no meta is found.
- * @since 2.5.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.0
*/
public static function get_subscription_payment_meta( $subscription, $gateway_id ) {
$payment_method_meta = apply_filters( 'woocommerce_subscription_payment_meta', array(), $subscription );
@@ -95,36 +95,33 @@ class WCS_Payment_Tokens extends WC_Payment_Tokens {
*
* @param WC_Payment_Token $payment_token Payment token object.
* @return array subscription posts
- * @since 2.5.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.0
*/
public static function get_subscriptions_from_token( $payment_token ) {
$user_subscriptions = array();
$users_subscription_ids = WCS_Customer_Store::instance()->get_users_subscription_ids( $payment_token->get_user_id() );
if ( ! empty( $users_subscription_ids ) ) {
- $meta_query = array(
- array(
- 'key' => '_payment_method',
- 'value' => $payment_token->get_gateway_id(),
- ),
- array(
- 'key' => '_requires_manual_renewal',
- 'value' => 'false',
- ),
- array(
- 'value' => $payment_token->get_token(),
- ),
+ $subscription_ids = wcs_get_orders_with_meta_query(
+ [
+ 'type' => 'shop_subscription',
+ 'status' => [ 'wc-pending', 'wc-active', 'wc-on-hold' ],
+ 'payment_method' => $payment_token->get_gateway_id(),
+ 'meta_query' => [ // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
+ [
+ 'key' => '_requires_manual_renewal',
+ 'value' => 'false',
+ ],
+ [
+ 'value' => $payment_token->get_token(),
+ ],
+ ],
+ 'limit' => -1,
+ 'return' => 'ids',
+ 'post__in' => $users_subscription_ids,
+ ]
);
- $subscription_ids = get_posts( array(
- 'post_type' => 'shop_subscription',
- 'post_status' => array( 'wc-pending', 'wc-active', 'wc-on-hold' ),
- 'meta_query' => $meta_query,
- 'posts_per_page' => -1,
- 'fields' => 'ids',
- 'post__in' => $users_subscription_ids,
- ) );
-
if ( has_filter( 'woocommerce_subscriptions_by_payment_token' ) ) {
wcs_deprecated_function( 'The "woocommerce_subscriptions_by_payment_token" hook should no longer be used. It previously filtered post objects and in moving to CRUD and Subscription APIs the "woocommerce_subscriptions_by_payment_token"', '2.5.0', 'woocommerce_subscriptions_from_payment_token' );
@@ -146,7 +143,7 @@ class WCS_Payment_Tokens extends WC_Payment_Tokens {
* @param int (optional) The customer id - defaults to the current user.
* @param string (optional) Gateway ID for getting tokens for a specific gateway.
* @return array of WC_Payment_Token objects.
- * @since 2.2.7
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.7
*/
public static function get_customer_tokens( $customer_id = '', $gateway_id = '' ) {
if ( '' === $customer_id ) {
@@ -165,7 +162,7 @@ class WCS_Payment_Tokens extends WC_Payment_Tokens {
*
* @param WC_Payment_Token $token The token to find an alternative for.
* @return WC_Payment_Token The customer's alternative token.
- * @since 2.2.7
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.7
*/
public static function get_customers_alternative_token( $token ) {
$payment_tokens = self::get_customer_tokens( $token->get_user_id(), $token->get_gateway_id() );
@@ -194,7 +191,7 @@ class WCS_Payment_Tokens extends WC_Payment_Tokens {
*
* @param WC_Payment_Token $token Payment token object.
* @return bool
- * @since 2.2.7
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.7
*/
public static function customer_has_alternative_token( $token ) {
return self::get_customers_alternative_token( $token ) !== null;
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wcs-permalink-manager.php b/vendor/woocommerce/subscriptions-core/includes/class-wcs-permalink-manager.php
index f80d07e..43ad43b 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wcs-permalink-manager.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wcs-permalink-manager.php
@@ -7,7 +7,7 @@
* @package WooCommerce Subscriptions
* @category Class
* @author Prospress
- * @since 2.5.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.3
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -22,7 +22,7 @@ class WCS_Permalink_Manager {
* If the notice has been trigger, set to true to avoid duplicate notices.
*
* @var bool
- * @since 2.5.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.3
*/
protected static $notice_triggered = false;
@@ -30,7 +30,7 @@ class WCS_Permalink_Manager {
* The options saved in DB related to permalinks.
*
* @var array
- * @since 2.5.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.3
*/
protected static $permalink_options = array(
'woocommerce_myaccount_subscriptions_endpoint',
@@ -41,7 +41,7 @@ class WCS_Permalink_Manager {
/**
* Hooks.
*
- * @since 2.5.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.3
*/
public static function init() {
add_filter( 'pre_update_option', array( __CLASS__, 'maybe_allow_permalink_update' ), 10, 3 );
@@ -55,7 +55,7 @@ class WCS_Permalink_Manager {
* @param mixed $old_value The previous option value.
*
* @return mixed
- * @since 2.5.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.3
*/
public static function maybe_allow_permalink_update( $value, $option, $old_value ) {
// If is updating a permalink option.
@@ -79,7 +79,7 @@ class WCS_Permalink_Manager {
/**
* Display a warning informing that the endpoints changes has been ignored.
*
- * @since 2.5.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.3
*/
protected static function show_duplicate_permalink_notice() {
if ( ! self::$notice_triggered ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wcs-post-meta-cache-manager-many-to-one.php b/vendor/woocommerce/subscriptions-core/includes/class-wcs-post-meta-cache-manager-many-to-one.php
index e908b0d..43ed68c 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wcs-post-meta-cache-manager-many-to-one.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wcs-post-meta-cache-manager-many-to-one.php
@@ -8,7 +8,7 @@ if ( ! defined( 'ABSPATH' ) ) {
* only one cache should exist for the meta value. This differs to WCS_Post_Meta_Cache_Manager
* which allows multiple caches for the same meta value i.e. a many-to-many relationship.
*
- * @version 2.3.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.0
* @category Class
* @author Prospress
*/
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wcs-post-meta-cache-manager.php b/vendor/woocommerce/subscriptions-core/includes/class-wcs-post-meta-cache-manager.php
index 494b4e9..eef58ed 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wcs-post-meta-cache-manager.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wcs-post-meta-cache-manager.php
@@ -2,13 +2,14 @@
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
-
/**
- * Class for managing caches of post meta
+ * Class for managing caches of post meta.
*
- * @version 2.3.0
+ * This class is intended to be used on stores using WP post architecture.
+ * Post related APIs and references in this class are expected, and shouldn't be replaced with CRUD equivalents.
+ *
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.0
* @category Class
- * @author Prospress
*/
class WCS_Post_Meta_Cache_Manager {
@@ -168,7 +169,7 @@ class WCS_Post_Meta_Cache_Manager {
* When a post object is restored from the trash, check if this class instance cares about updating its cache
* to reflect the change.
*
- * @param int $post_id The post being restroed.
+ * @param int $post_id The post being restored.
*/
public function post_untrashed( $post_id ) {
$this->maybe_update_for_post_change( 'add', $post_id );
@@ -178,7 +179,7 @@ class WCS_Post_Meta_Cache_Manager {
* When a post object is deleted or trashed, check if this class instance cares about updating its cache
* to reflect the change.
*
- * @param int $post_id The post being restroed.
+ * @param int $post_id The post being restored.
*/
public function post_deleted( $post_id ) {
$this->maybe_update_for_post_change( 'delete', $post_id );
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wcs-query.php b/vendor/woocommerce/subscriptions-core/includes/class-wcs-query.php
index 535a5f0..5e37dc3 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wcs-query.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wcs-query.php
@@ -2,7 +2,7 @@
/**
* WooCommerce Subscriptions Query Handler
*
- * @version 2.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
* @author Prospress
*/
class WCS_Query extends WC_Query {
@@ -48,7 +48,7 @@ class WCS_Query extends WC_Query {
/**
* Init query vars by loading options.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function init_query_vars() {
$this->query_vars = array(
@@ -89,7 +89,7 @@ class WCS_Query extends WC_Query {
* @param string $endpoint
* @return string
*
- * @since 3.0.10
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.0.10
*/
public function change_my_account_endpoint_title( $title, $endpoint ) {
global $wp;
@@ -146,7 +146,7 @@ class WCS_Query extends WC_Query {
/**
* Changes the URL for the subscriptions endpoint when there's only one user subscription.
*
- * @since 2.2.17
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.17
* @param string $url
* @param string $endpoint
* @return string
@@ -224,7 +224,7 @@ class WCS_Query extends WC_Query {
* Redirect to order-pay flow for Subscription Payment Method endpoint.
*
* @param WP_Query $query WordPress query object
- * @since 2.5.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.0
*/
public function maybe_redirect_payment_methods( $query ) {
@@ -259,7 +259,7 @@ class WCS_Query extends WC_Query {
* Reset the woocommerce_myaccount_view_subscriptions_endpoint option name to woocommerce_myaccount_view_subscription_endpoint
*
* @return mixed Value set for the option
- * @since 2.2.18
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.18
*/
private function get_view_subscription_endpoint() {
$value = get_option( 'woocommerce_myaccount_view_subscriptions_endpoint', null );
@@ -342,7 +342,7 @@ class WCS_Query extends WC_Query {
*
* @param array $query_vars
* @return array
- * @since 2.3.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.0
*/
public function add_wcs_query_vars( $query_vars ) {
return array_merge( $query_vars, $this->query_vars );
@@ -355,7 +355,7 @@ class WCS_Query extends WC_Query {
* @param string $endpoint The endpoint/label we're filtering.
*
* @return array
- * @since 2.5.6
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.6
*/
public function maybe_add_active_class( $classes, $endpoint ) {
if ( ! isset( $classes['is-active'] ) && 'subscriptions' === $endpoint && wcs_is_view_subscription_page() ) {
@@ -374,7 +374,7 @@ class WCS_Query extends WC_Query {
* @param array $crumbs already assembled breadcrumb data
* @return array $crumbs if we're on a view-subscription page, then augmented breadcrumb data
*
- * @deprecated 3.0.10
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v3.0.10
*/
public function add_breadcrumb( $crumbs ) {
_deprecated_function( __METHOD__, '3.0.10' );
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wcs-remove-item.php b/vendor/woocommerce/subscriptions-core/includes/class-wcs-remove-item.php
index 6cb7fbf..0906d5f 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wcs-remove-item.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wcs-remove-item.php
@@ -4,14 +4,14 @@
*
*
* @author Prospress
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
class WCS_Remove_Item {
/**
* Initialise class hooks & filters when the file is loaded
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function init() {
@@ -24,7 +24,7 @@ class WCS_Remove_Item {
*
* @param int $subscription_id
* @param int $order_item_id
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_remove_url( $subscription_id, $order_item_id ) {
@@ -45,7 +45,7 @@ class WCS_Remove_Item {
* @param int $subscription_id
* @param int $order_item_id
* @param string $base_url
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_undo_remove_url( $subscription_id, $order_item_id, $base_url ) {
@@ -64,7 +64,7 @@ class WCS_Remove_Item {
/**
* Process the remove or re-add a line item from a subscription request.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function maybe_remove_or_add_item_to_subscription() {
@@ -160,7 +160,7 @@ class WCS_Remove_Item {
* Validate the incoming request to either remove an item or add and item back to a subscription that was previously removed.
* Add an descriptive notice to the page whether or not the request was validated or not.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
* @param WC_Subscription $subscription
* @param int $order_item_id
* @param bool $undo_request bool
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wcs-renewal-cart-stock-manager.php b/vendor/woocommerce/subscriptions-core/includes/class-wcs-renewal-cart-stock-manager.php
index 9a08f3c..93443a2 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wcs-renewal-cart-stock-manager.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wcs-renewal-cart-stock-manager.php
@@ -7,7 +7,7 @@
* @package WooCommerce Subscriptions
* @category Class
* @author Prospress
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
defined( 'ABSPATH' ) || exit;
@@ -17,7 +17,7 @@ class WCS_Renewal_Cart_Stock_Manager {
/**
* Bootstraps the class and hooks required actions & filters.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
public static function attach_callbacks() {
add_action( 'wcs_before_renewal_setup_cart_subscription', array( get_called_class(), 'maybe_adjust_stock_cart' ), 10, 2 );
@@ -31,7 +31,7 @@ class WCS_Renewal_Cart_Stock_Manager {
*
* Hooked onto 'wcs_before_renewal_setup_cart_subscription'.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*
* @param WC_Subscription $subscription The subscription object. This param is unused. It is the first parameter of the hook.
* @param WC_Order $order The renewal order object.
@@ -43,7 +43,7 @@ class WCS_Renewal_Cart_Stock_Manager {
/**
* Attaches filters that allow manual renewal carts to pass checkout validity checks for an otherwise out of stock product.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
public static function maybe_adjust_stock_checkout() {
$renewal_order = static::get_order_from_cart();
@@ -61,7 +61,7 @@ class WCS_Renewal_Cart_Stock_Manager {
/**
* Attaches stock override filters for out of stock renewal products.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
* @param WC_Order $order Renewal order.
*/
protected static function maybe_attach_stock_filters( $order ) {
@@ -94,7 +94,7 @@ class WCS_Renewal_Cart_Stock_Manager {
/**
* Adjusts the stock status of a product that is an out-of-stock renewal.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*
* @param bool $is_in_stock Whether the product is in stock or not
* @param WC_Product $product The product which stock is being checked
@@ -113,7 +113,7 @@ class WCS_Renewal_Cart_Stock_Manager {
/**
* Adjusts whether backorders are allowed so out-of-stock renewal item products bypass stock validation.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*
* @param bool $backorders_allowed If the product has backorders enabled.
* @param int $product_id The product ID.
@@ -132,7 +132,7 @@ class WCS_Renewal_Cart_Stock_Manager {
/**
* Removes the filters that adjust stock on out of stock renewals items.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
public static function remove_filters() {
remove_filter( 'woocommerce_product_is_in_stock', array( get_called_class(), 'adjust_is_in_stock' ) );
@@ -142,7 +142,7 @@ class WCS_Renewal_Cart_Stock_Manager {
/**
* Determines if the cart contains a renewal order with a specific product.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
* @param WC_Product $product The product object to look for.
* @return bool Whether the cart contains a renewal order to the given product.
*/
@@ -164,7 +164,7 @@ class WCS_Renewal_Cart_Stock_Manager {
/**
* Gets the renewal order from the cart.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
* @return WC_Order|bool Renewal order obtained from the cart contents or false if the cart doesn't contain a renewal order.
*/
protected static function get_order_from_cart() {
@@ -181,7 +181,7 @@ class WCS_Renewal_Cart_Stock_Manager {
/**
* Gets the renewal order from order-pay query vars.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
* @return WC_Order|bool Renewal order obtained from query vars or false if not set.
*/
protected static function get_order_from_query_vars() {
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wcs-select2.php b/vendor/woocommerce/subscriptions-core/includes/class-wcs-select2.php
index 014b4d8..2e42227 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wcs-select2.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wcs-select2.php
@@ -2,7 +2,7 @@
/**
* Simple class to generate the HTML for a Select2 element in a WC version compatible way.
*
- * @since 2.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2
* @category Class
* @author Prospress
* @package WooCommerce Subscriptions
@@ -26,7 +26,7 @@ class WCS_Select2 {
* Constructor.
*
* @param array $attributes The attributes that make up the Select2 element
- * @since 2.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2
*/
public function __construct( array $attributes ) {
$this->attributes = array_merge( $this->default_attributes, $attributes );
@@ -36,7 +36,7 @@ class WCS_Select2 {
* Render a select2 element given an array of attributes.
*
* @param array $attributes Select2 attributes
- * @since 2.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2
*/
public static function render( array $attributes ) {
$select2 = new self( $attributes );
@@ -48,7 +48,7 @@ class WCS_Select2 {
*
* @param string $property
* @return string class, name, id or data-$property;
- * @since 2.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2
*/
protected function get_property_name( $property ) {
$data_properties = wcs_is_woocommerce_pre( '3.0' ) ? array( 'placeholder', 'selected', 'allow_clear' ) : array( 'placeholder', 'allow_clear' );
@@ -61,7 +61,7 @@ class WCS_Select2 {
*
* @param $attributes List of HTML attributes with values
* @return string
- * @since 2.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2
*/
protected function attributes_to_html( array $attributes ) {
@@ -81,7 +81,7 @@ class WCS_Select2 {
/**
* Prints the HTML to show the Select2 field.
*
- * @since 2.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2
*/
public function print_html() {
$allowed_attributes = array_map( array( $this, 'get_property_name' ), array_keys( $this->attributes ) );
@@ -101,7 +101,7 @@ class WCS_Select2 {
* Returns the HTML needed to show the Select2 field
*
* @return string
- * @since 2.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2
*/
public function get_html() {
$html = "\n\n";
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wcs-sql-transaction.php b/vendor/woocommerce/subscriptions-core/includes/class-wcs-sql-transaction.php
index 4030f8c..25b9f86 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wcs-sql-transaction.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wcs-sql-transaction.php
@@ -6,7 +6,7 @@
* @package WooCommerce Subscriptions
* @category Class
* @author Automattic
- * @since 3.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
*/
defined( 'ABSPATH' ) || exit;
@@ -37,7 +37,7 @@ class WCS_SQL_Transaction {
/**
* Constructor
*
- * @since 3.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
*
* @param string $on_fatal Optional. The type of query to run on fatal shutdown if this transaction is still active. Can be 'rollback' or 'commit'. Default is 'rollback'.
* @param string $on_shutdown Optional. The type of query to run if a non-error shutdown occurs but there's still an active transaction. Can be 'rollback' or 'commit'. Default is 'commit'.
@@ -63,7 +63,7 @@ class WCS_SQL_Transaction {
/**
* Starts a MYSQL Transction.
*
- * @since 3.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
*/
public function start() {
wc_transaction_query( 'start' );
@@ -73,7 +73,7 @@ class WCS_SQL_Transaction {
/**
* Commits the MYSQL Transction.
*
- * @since 3.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
*/
public function commit() {
wc_transaction_query( 'commit' );
@@ -83,7 +83,7 @@ class WCS_SQL_Transaction {
/**
* Rolls back any changes made during the MYSQL Transction.
*
- * @since 3.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
*/
public function rollback() {
wc_transaction_query( 'rollback' );
@@ -96,7 +96,7 @@ class WCS_SQL_Transaction {
* Shutdowns caused by a fatal will be rolledback or commited @see $this->on_fatal.
* Shutdowns caused by a natural PHP termination (no error) will be rolledback or commited. @see $this->on_shutdown.
*
- * @since 3.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
*/
public function handle_shutdown() {
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wcs-staging.php b/vendor/woocommerce/subscriptions-core/includes/class-wcs-staging.php
index 55c6d5d..4240137 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wcs-staging.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wcs-staging.php
@@ -4,7 +4,7 @@
*
* @package WooCommerce Subscriptions
* @author Prospress
- * @since 2.3.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.0
*/
class WCS_Staging {
@@ -23,7 +23,7 @@ class WCS_Staging {
* Add an order note to a renewal order to record when it was created under staging site conditions.
*
* @param int $renewal_order_id The renewal order ID.
- * @since 2.3.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.0
*/
public static function maybe_record_staging_site_renewal( $renewal_order_id ) {
@@ -48,7 +48,7 @@ class WCS_Staging {
* Add a badge to the Subscriptions submenu when a site is operating under a staging site lock.
*
* @param array $subscription_order_type_data The WC_Subscription register order type data.
- * @since 2.3.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.0
*/
public static function maybe_add_menu_badge( $subscription_order_type_data ) {
@@ -62,7 +62,7 @@ class WCS_Staging {
/**
* Handles admin requests to redisplay the staging site admin notice.
*
- * @since 2.5.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.5
*/
public static function maybe_reset_admin_notice() {
if ( isset( $_REQUEST['wcs_display_staging_notice'] ) && is_admin() && current_user_can( 'manage_options' ) ) {
@@ -75,7 +75,7 @@ class WCS_Staging {
* Displays a note under the edit subscription payment method field to explain why the subscription is set to Manual Renewal.
*
* @param WC_Subscription $subscription
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
public static function maybe_add_payment_method_note( $subscription ) {
if ( wcs_is_subscription( $subscription ) && WCS_Staging::is_duplicate_site() && $subscription->has_payment_gateway() && ! $subscription->get_requires_manual_renewal() ) {
@@ -91,7 +91,7 @@ class WCS_Staging {
*
* @param WC_Subscription $subscription
* @return string HTML content for a tooltip.
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
public static function get_payment_method_tooltip( $subscription ) {
// translators: placeholder is a payment method title.
@@ -101,7 +101,7 @@ class WCS_Staging {
/**
* Displays a notice when Subscriptions is being run on a different site, like a staging or testing site.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*/
public static function handle_site_change_notice() {
@@ -166,7 +166,7 @@ class WCS_Staging {
* We don't use a hash because keeping the URL in the value allows for viewing and editing the URL
* directly in the database.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
* @return string The duplicate lock key.
*/
public static function get_duplicate_site_lock_key() {
@@ -174,7 +174,12 @@ class WCS_Staging {
$scheme = parse_url( $site_url, PHP_URL_SCHEME ) . '://';
$site_url = str_replace( $scheme, '', $site_url );
- return $scheme . substr_replace( $site_url, '_[wc_subscriptions_siteurl]_', strlen( $site_url ) / 2, 0 );
+ return $scheme . substr_replace(
+ $site_url,
+ '_[wc_subscriptions_siteurl]_',
+ intval( strlen( $site_url ) / 2 ),
+ 0
+ );
}
/**
@@ -184,7 +189,7 @@ class WCS_Staging {
*
* @see self::get_duplicate_site_lock_key() which generates the key.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*/
public static function set_duplicate_site_url_lock() {
update_option( 'wc_subscriptions_siteurl', self::get_duplicate_site_lock_key() );
@@ -196,7 +201,7 @@ class WCS_Staging {
* Checks if the WordPress site URL is the same as the URL subscriptions considers
* the live URL (@see self::set_duplicate_site_url_lock()).
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
* @return bool Whether the site is a duplicate URL or not.
*/
public static function is_duplicate_site() {
@@ -232,7 +237,7 @@ class WCS_Staging {
*
* This URL is set by @see WCS_Staging::set_duplicate_site_url_lock(). This function removes the obfuscation to get a raw URL.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*
* @param int|null $blog_id The blog to get the URL for. Optional. Default is null. Used for multisites only.
* @param string $path The URL path to append. Optional. Default is ''.
@@ -265,7 +270,7 @@ class WCS_Staging {
* WordPress - This is typically the URL the current site is accessable via.
* Subscriptions is the URL Subscritpions considers to be the URL to process live payments on. It may differ to the WP URL if the site has moved.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*
* @param string $source The URL source to get. Optional. Takes values 'current_wp_site' or 'subscriptions_install'. Default is 'current_wp_site' - the URL WP considers to be the site's.
* @return string The URL.
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wcs-template-loader.php b/vendor/woocommerce/subscriptions-core/includes/class-wcs-template-loader.php
index 4170a7d..f1c918f 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wcs-template-loader.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wcs-template-loader.php
@@ -2,7 +2,7 @@
/**
* WC Subscriptions Template Loader
*
- * @version 2.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
* @author Prospress
*/
class WCS_Template_Loader {
@@ -96,7 +96,7 @@ class WCS_Template_Loader {
* Get the view subscription template.
*
* @param int $subscription_id Subscription ID.
- * @since 2.0.17
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.17
*/
public static function get_view_subscription_template( $subscription_id ) {
$subscription = wcs_get_subscription( absint( $subscription_id ) );
@@ -113,7 +113,7 @@ class WCS_Template_Loader {
* Get the subscription details template, which is part of the view subscription page.
*
* @param WC_Subscription $subscription Subscription object
- * @since 2.2.19
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.19
*/
public static function get_subscription_details_template( $subscription ) {
wc_get_template( 'myaccount/subscription-details.php', array( 'subscription' => $subscription ), '', WC_Subscriptions_Core_Plugin::instance()->get_subscriptions_core_directory( 'templates/' ) );
@@ -123,7 +123,7 @@ class WCS_Template_Loader {
* Get the subscription totals template, which is part of the view subscription page.
*
* @param WC_Subscription $subscription Subscription object
- * @since 2.2.19
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.19
*/
public static function get_subscription_totals_template( $subscription ) {
wc_get_template( 'myaccount/subscription-totals.php', array( 'subscription' => $subscription ), '', WC_Subscriptions_Core_Plugin::instance()->get_subscriptions_core_directory( 'templates/' ) );
@@ -133,7 +133,7 @@ class WCS_Template_Loader {
* Get the order downloads template, which is part of the view subscription page.
*
* @param WC_Subscription $subscription Subscription object
- * @since 2.5.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.0
*/
public static function get_order_downloads_template( $subscription ) {
if ( $subscription->has_downloadable_item() && $subscription->is_download_permitted() ) {
@@ -150,7 +150,7 @@ class WCS_Template_Loader {
/**
* Gets the subscription totals table.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*
* @param WC_Subscription $subscription The subscription to print the totals table for.
* @param bool $include_item_removal_links Whether the remove line item links should be included.
@@ -184,7 +184,7 @@ class WCS_Template_Loader {
/**
* Gets the subscription receipt template content.
*
- * @since 3.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.0.0
*
* @param WC_Subscription $subscription The subscription to display the receipt for.
*/
@@ -195,7 +195,7 @@ class WCS_Template_Loader {
/**
* Gets the recurring totals subtotal rows content.
*
- * @since 3.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
*
* @param array $recurring_carts The recurring carts.
*/
@@ -207,7 +207,7 @@ class WCS_Template_Loader {
/**
* Gets the recurring totals coupon rows content.
*
- * @since 3.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
*
* @param array $recurring_carts The recurring carts.
*/
@@ -220,7 +220,7 @@ class WCS_Template_Loader {
/**
* Gets the recurring totals shipping rows content.
*
- * @since 3.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
*/
public static function get_recurring_cart_shipping() {
if ( WC()->cart->show_shipping() && WC_Subscriptions_Cart::cart_contains_subscriptions_needing_shipping() ) {
@@ -231,7 +231,7 @@ class WCS_Template_Loader {
/**
* Gets the recurring totals fee rows content.
*
- * @since 3.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
*
* @param array $recurring_carts The recurring carts.
*/
@@ -244,7 +244,7 @@ class WCS_Template_Loader {
/**
* Gets the recurring totals tax rows content.
*
- * @since 3.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
*
* @param array $recurring_carts The recurring carts.
*/
@@ -268,7 +268,7 @@ class WCS_Template_Loader {
/**
* Gets the recurring subscription total rows content.
*
- * @since 3.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
*
* @param array $recurring_carts The recurring carts.
*/
@@ -281,7 +281,7 @@ class WCS_Template_Loader {
/**
* Loads the my-subscriptions.php template on the My Account page.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
* @param int $current_page The My Account Subscriptions page.
*/
public static function get_my_subscriptions( $current_page = 1 ) {
@@ -310,7 +310,7 @@ class WCS_Template_Loader {
* Use the same cart template for subscription as that which is used for simple products. Reduce code duplication
* and is made possible by the friendly actions & filters found through WC.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*/
public static function get_subscription_add_to_cart() {
wc_get_template( 'single-product/add-to-cart/subscription.php', array(), '', WC_Subscriptions_Core_Plugin::instance()->get_subscriptions_core_directory( 'templates/' ) );
@@ -321,7 +321,7 @@ class WCS_Template_Loader {
*
* Use a very similar cart template as that of a variable product with added functionality.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*/
public static function get_variable_subscription_add_to_cart() {
global $product;
@@ -351,7 +351,7 @@ class WCS_Template_Loader {
* Variable subscription products will be handled automatically because they identify as "variable" in response to is_type() method calls,
* which OPC uses.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*/
public static function get_opc_subscription_add_to_cart() {
global $product;
diff --git a/vendor/woocommerce/subscriptions-core/includes/class-wcs-user-change-status-handler.php b/vendor/woocommerce/subscriptions-core/includes/class-wcs-user-change-status-handler.php
index d2bc42f..cd919cd 100644
--- a/vendor/woocommerce/subscriptions-core/includes/class-wcs-user-change-status-handler.php
+++ b/vendor/woocommerce/subscriptions-core/includes/class-wcs-user-change-status-handler.php
@@ -3,7 +3,7 @@
* WooCommerce Subscriptions User Change Status Handler Class
*
* @author Prospress
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -21,7 +21,7 @@ class WCS_User_Change_Status_Handler {
* Checks if the current request is by a user to change the status of their subscription, and if it is,
* validate the request and proceed to change to the subscription.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function maybe_change_users_subscription() {
@@ -42,7 +42,7 @@ class WCS_User_Change_Status_Handler {
/**
* Change the status of a subscription and show a notice to the user if there was an issue.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function change_users_subscription( $subscription, $new_status ) {
$subscription = ( ! is_object( $subscription ) ) ? wcs_get_subscription( $subscription ) : $subscription;
@@ -87,7 +87,7 @@ class WCS_User_Change_Status_Handler {
/**
* Validates a user change status change request.
*
- * @since 2.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.0
*
* @param int $user_id The ID of the user performing the request.
* @param WC_Subscription $subscription The Subscription to update.
diff --git a/vendor/woocommerce/subscriptions-core/includes/data-stores/class-wcs-customer-store-cached-cpt.php b/vendor/woocommerce/subscriptions-core/includes/data-stores/class-wcs-customer-store-cached-cpt.php
index 64611c1..ee8dab6 100644
--- a/vendor/woocommerce/subscriptions-core/includes/data-stores/class-wcs-customer-store-cached-cpt.php
+++ b/vendor/woocommerce/subscriptions-core/includes/data-stores/class-wcs-customer-store-cached-cpt.php
@@ -11,19 +11,18 @@ if ( ! defined( 'ABSPATH' ) ) {
*
* Cache is based on the current blog in case of a multisite environment.
*
- * @version 2.3.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.0
* @category Class
- * @author Prospress
*/
class WCS_Customer_Store_Cached_CPT extends WCS_Customer_Store_CPT implements WCS_Cache_Updater {
/**
- * Keep cache up-to-date with changes to our meta data via WordPress post meta APIs
- * by using a post meta cache manager.
+ * Keep the cache up-to-date with changes to our meta data via WordPress post meta APIs
+ * or WC CRUD APIs by using a data cache manager.
*
- * @var WCS_Post_Meta_Cache_Manager_Many_To_One
+ * @var WCS_Post_Meta_Cache_Manager_Many_To_One|WCS_Object_Data_Cache_Manager_Many_To_One Depending on the HPOS environment.
*/
- protected $post_meta_cache_manager;
+ protected $object_data_cache_manager;
/**
* Meta key used to store all of a customer's subscription IDs in their user meta.
@@ -32,11 +31,36 @@ class WCS_Customer_Store_Cached_CPT extends WCS_Customer_Store_CPT implements WC
*/
const _CACHE_META_KEY = '_wcs_subscription_ids_cache';
+ /**
+ * Gets the legacy protected variables for backwards compatibility.
+ *
+ * Throws a deprecated warning if accessing the now deprecated variables.
+ *
+ * @param string $name The variable name.
+ * @return WCS_Post_Meta_Cache_Manager_Many_To_One|WCS_Object_Data_Cache_Manager_Many_To_One Depending on the HPOS environment.
+ */
+ public function __get( $name ) {
+ if ( 'post_meta_cache_manager' !== $name ) {
+ return;
+ }
+
+ $old = get_class( $this ) . '::post_meta_cache_manager';
+ $replacement = get_class( $this ) . '::object_data_cache_manager';
+
+ wcs_doing_it_wrong( $old, "$old has been deprecated, use $replacement instead.", '5.2.0' );
+
+ return $this->object_data_cache_manager;
+ }
+
/**
* Constructor
*/
public function __construct() {
- $this->post_meta_cache_manager = new WCS_Post_Meta_Cache_Manager_Many_To_One( 'shop_subscription', array( $this->get_meta_key() ) );
+ if ( wcs_is_custom_order_tables_usage_enabled() ) {
+ $this->object_data_cache_manager = new WCS_Object_Data_Cache_Manager_Many_To_One( 'subscription', array( $this->get_data_key() ) );
+ } else {
+ $this->object_data_cache_manager = new WCS_Post_Meta_Cache_Manager_Many_To_One( 'shop_subscription', array( $this->get_data_key() ) );
+ }
}
/**
@@ -44,7 +68,7 @@ class WCS_Customer_Store_Cached_CPT extends WCS_Customer_Store_CPT implements WC
*/
protected function init() {
- $this->post_meta_cache_manager->init();
+ $this->object_data_cache_manager->init();
// When a user is first added, make sure the subscription cache is empty because it can not have any data yet, and we want to avoid running the query needlessly
add_filter( 'user_register', array( $this, 'set_empty_cache' ) );
@@ -205,15 +229,15 @@ class WCS_Customer_Store_Cached_CPT extends WCS_Customer_Store_CPT implements WC
/**
* If there is a change to a subscription's post meta key, update the user meta cache.
*
- * @param string $update_type The type of update to check. Can be 'add', 'update' or 'delete'.
- * @param int $subscription_id The subscription's post ID where the customer is being changed.
- * @param string $meta_key The post meta key being changed.
- * @param mixed $user_id The meta value, which will be subscriber's user ID when $meta_key is '_customer_user'.
- * @param mixed $old_user_id The previous value stored in the database for the subscription's '_customer_user'. Optional.
+ * @param string $update_type The type of update to check. Can be 'add', 'update' or 'delete'.
+ * @param int $subscription_id The subscription's ID where the customer is being changed.
+ * @param string $updated_data_key The object's data key being changed. Can be a post meta key or a property name.
+ * @param mixed $user_id The new value stored in the database for the subscription's customer. This could be any type of value but is a user ID when the customer is being changed.
+ * @param mixed $old_user_id The previous value stored in the database for the subscription's customer ID. Optional.
*/
- public function maybe_update_for_post_meta_change( $update_type, $subscription_id, $meta_key, $user_id, $old_user_id = '' ) {
+ public function maybe_update_for_post_meta_change( $update_type, $subscription_id, $updated_data_key, $user_id, $old_user_id = '' ) {
- if ( $this->get_meta_key() !== $meta_key ) {
+ if ( $this->get_data_key() !== $updated_data_key ) {
return;
}
@@ -301,7 +325,7 @@ class WCS_Customer_Store_Cached_CPT extends WCS_Customer_Store_CPT implements WC
*
* On multi-site installations, the current site ID is appended.
*
- * @since 3.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
* @return string
*/
public function get_cache_meta_key() {
diff --git a/vendor/woocommerce/subscriptions-core/includes/data-stores/class-wcs-customer-store-cpt.php b/vendor/woocommerce/subscriptions-core/includes/data-stores/class-wcs-customer-store-cpt.php
index 8ce2940..6269765 100644
--- a/vendor/woocommerce/subscriptions-core/includes/data-stores/class-wcs-customer-store-cpt.php
+++ b/vendor/woocommerce/subscriptions-core/includes/data-stores/class-wcs-customer-store-cpt.php
@@ -4,34 +4,50 @@ if ( ! defined( 'ABSPATH' ) ) {
}
/**
- * Customer data store for subscriptions stored in Custom Post Types.
+ * Customer data store for subscriptions.
*
- * Gets subscriptions for users via the '_customer_user' post meta value.
+ * This class is responsible for getting subscriptions for users.
*
- * @version 2.3.0
- * @category Class
- * @author Prospress
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.0
*/
class WCS_Customer_Store_CPT extends WCS_Customer_Store {
/**
- * The meta key used to link a customer with a subscription.
+ * The post meta key used to link a customer with a subscription.
*
* @var string
*/
private $meta_key = '_customer_user';
/**
- * Get the meta key used to link a customer with a subscription.
+ * The object data key (property) used to link a customer with a subscription.
*
- * @return string
+ * @var string
+ */
+ private $data_key = 'customer_id';
+
+ /**
+ * Gets the post meta key used to link a customer with a subscription.
+ *
+ * @return string The customer user post meta key.
*/
protected function get_meta_key() {
return $this->meta_key;
}
/**
- * Get the IDs for a given user's subscriptions by querying post meta.
+ * Gets the data key used to link the customer with a subscription.
+ *
+ * This can be the post meta key on stores using the WP Post architecture and the property name on HPOS architecture.
+ *
+ * @return string The customer user post meta key or the customer ID property key.
+ */
+ protected function get_data_key() {
+ return wcs_is_custom_order_tables_usage_enabled() ? $this->data_key : $this->meta_key;
+ }
+
+ /**
+ * Get the IDs for a given user's subscriptions.
*
* @param int $user_id The id of the user whose subscriptions you want.
* @return array
@@ -42,25 +58,16 @@ class WCS_Customer_Store_CPT extends WCS_Customer_Store {
return array();
}
- $query = new WP_Query();
-
- return $query->query( array(
- 'post_type' => 'shop_subscription',
- 'posts_per_page' => -1,
- 'post_status' => 'any',
- 'orderby' => array(
- 'date' => 'DESC',
- 'ID' => 'DESC',
- ),
- 'fields' => 'ids',
- 'no_found_rows' => true,
- 'ignore_sticky_posts' => true,
- 'meta_query' => array(
- array(
- 'key' => $this->get_meta_key(),
- 'value' => $user_id,
- ),
- ),
- ) );
+ return wcs_get_orders_with_meta_query(
+ [
+ 'type' => 'shop_subscription',
+ 'customer_id' => $user_id,
+ 'limit' => -1,
+ 'status' => 'any',
+ 'return' => 'ids',
+ 'orderby' => 'ID',
+ 'order' => 'DESC',
+ ]
+ );
}
}
diff --git a/vendor/woocommerce/subscriptions-core/includes/data-stores/class-wcs-orders-table-data-store-controller.php b/vendor/woocommerce/subscriptions-core/includes/data-stores/class-wcs-orders-table-data-store-controller.php
new file mode 100644
index 0000000..02a159a
--- /dev/null
+++ b/vendor/woocommerce/subscriptions-core/includes/data-stores/class-wcs-orders-table-data-store-controller.php
@@ -0,0 +1,65 @@
+init_hooks();
+ }
+
+ /**
+ * Initialise WCS_Orders_Table_Data_Store_Controller class hooks.
+ *
+ * @return void
+ */
+ public function init_hooks() {
+ add_filter( 'woocommerce_subscription_data_store', array( $this, 'get_orders_table_data_store' ), 10, 2 );
+ }
+
+ /**
+ * Returns an instance of the Subscriptions Order Table data store object to use.
+ * If an instance doesn't exist, create one.
+ *
+ * @return WCS_Orders_Table_Subscription_Data_Store
+ */
+ private function get_data_store_instance() {
+ if ( ! isset( $this->data_store ) ) {
+ $this->data_store = new WCS_Orders_Table_Subscription_Data_Store();
+ $this->data_store->init(
+ wc_get_container()->get( \Automattic\WooCommerce\Internal\DataStores\Orders\OrdersTableDataStoreMeta::class ),
+ wc_get_container()->get( \Automattic\WooCommerce\Internal\Utilities\DatabaseUtil::class ),
+ wc_get_container()->get( \Automattic\WooCommerce\Proxies\LegacyProxy::class )
+ );
+ }
+
+ return $this->data_store;
+ }
+
+ /**
+ * When the custom_order_tables feature is enabled, return the subscription datastore class.
+ *
+ * @param string $default_data_store The data store class name.
+ *
+ * @return string
+ */
+ public function get_orders_table_data_store( $default_data_store ) {
+ return wcs_is_custom_order_tables_usage_enabled() ? $this->get_data_store_instance() : $default_data_store;
+ }
+}
diff --git a/vendor/woocommerce/subscriptions-core/includes/data-stores/class-wcs-orders-table-subscription-data-store.php b/vendor/woocommerce/subscriptions-core/includes/data-stores/class-wcs-orders-table-subscription-data-store.php
new file mode 100644
index 0000000..c66aa4a
--- /dev/null
+++ b/vendor/woocommerce/subscriptions-core/includes/data-stores/class-wcs-orders-table-subscription-data-store.php
@@ -0,0 +1,880 @@
+ prop_key
+ *
+ * Used to read/update props on the subscription.
+ *
+ * @var array
+ */
+ protected $subscription_meta_keys_to_props = array(
+ '_billing_period' => 'billing_period',
+ '_billing_interval' => 'billing_interval',
+ '_suspension_count' => 'suspension_count',
+ '_cancelled_email_sent' => 'cancelled_email_sent',
+ '_requires_manual_renewal' => 'requires_manual_renewal',
+ '_trial_period' => 'trial_period',
+
+ '_schedule_trial_end' => 'schedule_trial_end',
+ '_schedule_next_payment' => 'schedule_next_payment',
+ '_schedule_cancelled' => 'schedule_cancelled',
+ '_schedule_end' => 'schedule_end',
+ '_schedule_payment_retry' => 'schedule_payment_retry',
+ '_schedule_start' => 'schedule_start',
+
+ '_subscription_switch_data' => 'switch_data',
+ );
+
+ /**
+ * Table column to WC_Subscription mapping for wc_orders table.
+ *
+ * All columns are inherited from orders except the `transaction_id` column isn't used for subscriptions.
+ *
+ * @var \string[][]
+ */
+ protected $order_column_mapping = array(
+ 'id' => array(
+ 'type' => 'int',
+ 'name' => 'id',
+ ),
+ 'status' => array(
+ 'type' => 'string',
+ 'name' => 'status',
+ ),
+ 'type' => array(
+ 'type' => 'string',
+ 'name' => 'type',
+ ),
+ 'currency' => array(
+ 'type' => 'string',
+ 'name' => 'currency',
+ ),
+ 'tax_amount' => array(
+ 'type' => 'decimal',
+ 'name' => 'cart_tax',
+ ),
+ 'total_amount' => array(
+ 'type' => 'decimal',
+ 'name' => 'total',
+ ),
+ 'customer_id' => array(
+ 'type' => 'int',
+ 'name' => 'customer_id',
+ ),
+ 'billing_email' => array(
+ 'type' => 'string',
+ 'name' => 'billing_email',
+ ),
+ 'date_created_gmt' => array(
+ 'type' => 'date',
+ 'name' => 'date_created',
+ ),
+ 'date_updated_gmt' => array(
+ 'type' => 'date',
+ 'name' => 'date_modified',
+ ),
+ 'parent_order_id' => array(
+ 'type' => 'int',
+ 'name' => 'parent_id',
+ ),
+ 'payment_method' => array(
+ 'type' => 'string',
+ 'name' => 'payment_method',
+ ),
+ 'payment_method_title' => array(
+ 'type' => 'string',
+ 'name' => 'payment_method_title',
+ ),
+ 'ip_address' => array(
+ 'type' => 'string',
+ 'name' => 'customer_ip_address',
+ ),
+ 'user_agent' => array(
+ 'type' => 'string',
+ 'name' => 'customer_user_agent',
+ ),
+ 'customer_note' => array(
+ 'type' => 'string',
+ 'name' => 'customer_note',
+ ),
+ );
+
+ /**
+ * Table column to WC_Subscription mapping for wc_operational_data table.
+ *
+ * For subscriptions, all columns are inherited from orders except for the following columns:
+ *
+ * - cart_hash
+ * - new_order_email_sent
+ * - order_stock_reduced
+ * - date_paid_gmt
+ * - recorded_sales
+ * - date_completed_gmt
+ *
+ * @var \string[][]
+ */
+ protected $operational_data_column_mapping = array(
+ 'id' => array( 'type' => 'int' ),
+ 'order_id' => array( 'type' => 'int' ),
+ 'created_via' => array(
+ 'type' => 'string',
+ 'name' => 'created_via',
+ ),
+ 'woocommerce_version' => array(
+ 'type' => 'string',
+ 'name' => 'version',
+ ),
+ 'prices_include_tax' => array(
+ 'type' => 'bool',
+ 'name' => 'prices_include_tax',
+ ),
+ 'coupon_usages_are_counted' => array(
+ 'type' => 'bool',
+ 'name' => 'recorded_coupon_usage_counts',
+ ),
+ 'download_permission_granted' => array(
+ 'type' => 'bool',
+ 'name' => 'download_permissions_granted',
+ ),
+ 'order_key' => array(
+ 'type' => 'string',
+ 'name' => 'order_key',
+ ),
+ 'shipping_tax_amount' => array(
+ 'type' => 'decimal',
+ 'name' => 'shipping_tax',
+ ),
+ 'shipping_total_amount' => array(
+ 'type' => 'decimal',
+ 'name' => 'shipping_total',
+ ),
+ 'discount_tax_amount' => array(
+ 'type' => 'decimal',
+ 'name' => 'discount_tax',
+ ),
+ 'discount_total_amount' => array(
+ 'type' => 'decimal',
+ 'name' => 'discount_total',
+ ),
+ );
+
+ /**
+ * Constructor.
+ */
+ public function __construct() {
+ // Register any custom date types as internal meta keys and props.
+ foreach ( wcs_get_subscription_date_types() as $date_type => $date_name ) {
+ // The last payment date is derived from other sources and shouldn't be stored on a subscription.
+ if ( 'last_payment' === $date_type ) {
+ continue;
+ }
+
+ $meta_key = wcs_get_date_meta_key( $date_type );
+
+ // Skip any dates which are already core date types. We don't want custom date types to override them.
+ if ( isset( $this->subscription_meta_keys_to_props[ $meta_key ] ) ) {
+ continue;
+ }
+
+ $this->subscription_meta_keys_to_props[ $meta_key ] = wcs_maybe_prefix_key( $date_type, 'schedule_' );
+ $this->subscription_internal_meta_keys[] = $meta_key;
+ }
+
+ // Exclude the subscription related meta data we set and manage manually from the objects "meta" data.
+ $this->internal_meta_keys = array_merge( $this->internal_meta_keys, $this->subscription_internal_meta_keys );
+ }
+
+ /**
+ * Returns data store object to use backfilling.
+ *
+ * @return \WCS_Subscription_Data_Store_CPT
+ */
+ protected function get_post_data_store_for_backfill() {
+ return new \WCS_Subscription_Data_Store_CPT();
+ }
+
+ /**
+ * Gets amount refunded for all related orders.
+ *
+ * @param \WC_Subscription $subscription
+ *
+ * @return string
+ */
+ public function get_total_refunded( $subscription ) {
+ $total = 0;
+
+ foreach ( $subscription->get_related_orders( 'all' ) as $order ) {
+ $total += parent::get_total_refunded( $order );
+ }
+
+ return $total;
+ }
+
+ /**
+ * Gets the total tax refunded for all related orders.
+ *
+ * @param \WC_Subscription $subscription
+ *
+ * @return float
+ */
+ public function get_total_tax_refunded( $subscription ) {
+ $total = 0;
+
+ foreach ( $subscription->get_related_orders() as $order ) {
+ $total += parent::get_total_tax_refunded( $order );
+ }
+
+ return abs( $total );
+ }
+
+ /**
+ * Gets the total shipping refunded for all related orders.
+ *
+ * @param \WC_Subscription $subscription The subscription object.
+ *
+ * @return float
+ */
+ public function get_total_shipping_refunded( $subscription ) {
+ $total = 0;
+
+ foreach ( $subscription->get_related_orders( 'all' ) as $order ) {
+ $total += parent::get_total_shipping_refunded( $order );
+ }
+
+ return abs( $total );
+ }
+
+ /**
+ * Returns count of subscriptions with a specific status.
+ *
+ * @param string $status Subscription status. The wcs_get_subscription_statuses() function returns a list of valid statuses.
+ *
+ * @return int The number of subscriptions with a specific status.
+ */
+ public function get_order_count( $status ) {
+ global $wpdb;
+ $orders_table = self::get_orders_table_name();
+
+ return absint( $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$orders_table} WHERE type = 'shop_subscription' AND status = %s", $status ) ) ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
+ }
+
+ /**
+ * Get all subscriptions matching the passed in args.
+ *
+ * @param array $args
+ *
+ * @return array of orders
+ */
+ public function get_orders( $args = [] ) {
+ $args = wp_parse_args(
+ $args,
+ [
+ 'type' => 'shop_subscription',
+ 'return' => 'objects',
+ ]
+ );
+ $parent_args = $args;
+
+ // We only want IDs from the parent method
+ $parent_args['return'] = 'ids';
+
+ $subscriptions = wc_get_orders( $parent_args );
+
+ if ( isset( $args['paginate'] ) && $args['paginate'] ) {
+
+ if ( 'objects' === $args['return'] ) {
+ $return = array_map( 'wcs_get_subscription', $subscriptions->orders );
+ } else {
+ $return = $subscriptions->orders;
+ }
+
+ return (object) [
+ 'orders' => $return,
+ 'total' => $subscriptions->total,
+ 'max_num_pages' => $subscriptions->max_num_pages,
+ ];
+
+ } else {
+
+ if ( 'objects' === $args['return'] ) {
+ $return = array_map( 'wcs_get_subscription', $subscriptions );
+ } else {
+ $return = $subscriptions;
+ }
+
+ return $return;
+ }
+ }
+
+ /**
+ * Attempts to restore the specified subscription back to its original status (after having been trashed).
+ *
+ * @param \WC_Subscription $order The order to be untrashed.
+ *
+ * @return bool If the operation was successful.
+ */
+ public function untrash_order( WC_Order $subscription ): bool {
+ $id = $subscription->get_id();
+ $status = $subscription->get_status();
+
+ if ( 'trash' !== $status ) {
+ wc_get_logger()->warning(
+ sprintf(
+ /* translators: 1: subscription ID, 2: subscription status */
+ __( 'Subscription %1$d cannot be restored from the trash: it has already been restored to status "%2$s".', 'woocommerce-subscriptions' ),
+ $id,
+ $status
+ )
+ );
+ return false;
+ }
+
+ $previous_status = $subscription->get_meta( '_wp_trash_meta_status' );
+ $valid_statuses = wcs_get_subscription_statuses();
+ $previous_state_is_invalid = ! array_key_exists( $previous_status, $valid_statuses );
+ $pending_is_valid_status = array_key_exists( 'wc-pending', $valid_statuses );
+
+ if ( $previous_state_is_invalid && $pending_is_valid_status ) {
+ // If the previous status is no longer valid, let's try to restore it to "pending" instead.
+ wc_get_logger()->warning(
+ sprintf(
+ /* translators: 1: subscription ID, 2: subscription status */
+ __( 'The previous status of subscription %1$d ("%2$s") is invalid. It has been restored to "pending" status instead.', 'woocommerce-subscriptions' ),
+ $id,
+ $previous_status
+ )
+ );
+
+ $previous_status = 'pending';
+ } elseif ( $previous_state_is_invalid ) {
+ // If we cannot restore to pending, we should probably stand back and let the merchant intervene some other way.
+ wc_get_logger()->warning(
+ sprintf(
+ /* translators: 1: subscription ID, 2: subscription status */
+ __( 'The previous status of subscription %1$d ("%2$s") is invalid. It could not be restored.', 'woocommerce-subscriptions' ),
+ $id,
+ $previous_status
+ )
+ );
+
+ return false;
+ }
+
+ /**
+ * Fires before a subscription is restored from the trash.
+ *
+ * @since 5.2.0
+ *
+ * @param int $subscription_id Subscription ID.
+ * @param string $previous_status The status of the subscription before it was trashed.
+ */
+ do_action( 'woocommerce_untrash_subscription', $subscription->get_id(), $previous_status );
+
+ $subscription->set_status( $previous_status );
+ $subscription->save();
+
+ // Was the status successfully restored? Let's clean up the meta and indicate success...
+ if ( 'wc-' . $subscription->get_status() === $previous_status ) {
+ $subscription->delete_meta_data( '_wp_trash_meta_status' );
+ $subscription->delete_meta_data( '_wp_trash_meta_time' );
+ $subscription->delete_meta_data( '_wp_trash_meta_comments_status' );
+ $subscription->save_meta_data();
+
+ $data_synchronizer = wc_get_container()->get( \Automattic\WooCommerce\Internal\DataStores\Orders\DataSynchronizer::class );
+ if ( $data_synchronizer->data_sync_is_enabled() ) {
+ //The previous $subscription->save() will have forced a sync to the posts table,
+ //this implies that the post status is not "trash" anymore, and thus
+ //wp_untrash_post would do nothing.
+ wp_update_post(
+ array(
+ 'ID' => $id,
+ 'post_status' => 'trash',
+ )
+ );
+
+ wp_untrash_post( $id );
+ }
+
+ return true;
+ }
+
+ // ...Or log a warning and bail.
+ wc_get_logger()->warning(
+ sprintf(
+ /* translators: 1: subscription ID, 2: subscription status */
+ __( 'Something went wrong when trying to restore subscription %d from the trash. It could not be restored.', 'woocommerce-subscriptions' ),
+ $id
+ )
+ );
+
+ return false;
+ }
+
+ /**
+ * Method to delete a subscription from the database.
+ *
+ * @param \WC_Subscription $subscription Subscription object.
+ * @param array $args Array of args to pass to the delete method.
+ *
+ * @return void
+ */
+ public function delete( &$subscription, $args = array() ) {
+ $subscription_id = $subscription->get_id();
+
+ if ( ! $subscription_id ) {
+ return;
+ }
+
+ if ( ! empty( $args['force_delete'] ) ) {
+
+ /**
+ * Fires immediately before a subscription is deleted from the database.
+ *
+ * @since 5.2.0
+ *
+ * @param int $subscription_id ID of the subscription about to be deleted.
+ * @param WC_Subscription $subscription Instance of the subscription that is about to be deleted.
+ */
+ do_action( 'woocommerce_before_delete_subscription', $subscription_id, $subscription );
+
+ $this->delete_order_data_from_custom_order_tables( $subscription_id );
+
+ $subscription->set_id( 0 );
+
+ // If this datastore method is called while the posts table is authoritative, refrain from deleting post data.
+ if ( $subscription->get_data_store()->get_current_class_name() !== self::class ) {
+ return;
+ }
+
+ // Delete the associated post, which in turn deletes the subscription items, etc. through {@see WC_Post_Data}.
+ // Once we stop creating placehold_order in posts, we should do the cleanup here instead.
+ wp_delete_post( $subscription_id );
+
+ /**
+ * Fires immediately after a subscription is deleted from the database.
+ *
+ * Also calls `woocommerce_subscription_deleted` hook for backwards compatibility @see WC_Subscriptions_Manager::trigger_subscription_deleted_hook()
+ *
+ * @since 5.2.0
+ *
+ * @param int $subscription_id ID of the subscription about to be deleted.
+ */
+ do_action( 'woocommerce_delete_subscription', $subscription_id );
+ do_action( 'woocommerce_subscription_deleted', $subscription_id );
+ } else {
+ /**
+ * Fires immediately before a subscription is trashed.
+ *
+ * @since 5.2.0
+ *
+ * @param int $subscription_id ID of the subscription about to be trashed.
+ * @param WC_Subscription $subscription Instance of the subscription that is about to be trashed.
+ */
+ do_action( 'woocommerce_before_trash_subscription', $subscription_id, $subscription );
+
+ $this->trash_order( $subscription );
+
+ /**
+ * Fires immediately after a subscription is trashed.
+ *
+ * Also calls `woocommerce_subscription_trashed` for backwards compatibility @see WC_Subscriptions_Manager::trigger_subscription_trashed_hook()
+ *
+ * @since 5.2.0
+ *
+ * @param int $subscription_id ID of the order about to be deleted.
+ */
+ do_action( 'woocommerce_trash_subscription', $subscription_id );
+ do_action( 'woocommerce_subscription_trashed', $subscription_id );
+ }
+ }
+
+ /**
+ * Creates a new subscription in the database.
+ *
+ * @param \WC_Subscription $subscription Subscription object.
+ */
+ public function create( &$subscription ) {
+ parent::create( $subscription );
+ do_action( 'woocommerce_new_subscription', $subscription->get_id() );
+ }
+
+ /**
+ * Updates a subscription in the database.
+ *
+ * @param \WC_Subscription $subscription Subscription object
+ */
+ public function update( &$subscription ) {
+ // We don't want to call parent::update() here because OrdersTableDataStore includes a JIT setting of the paid date which is not needed for subscriptions, and also very resource intensive due to needed to search related orders to get the latest orders paid date.
+ if ( null === $subscription->get_date_created( 'edit' ) ) {
+ $subscription->set_date_created( time() );
+ }
+
+ $subscription->set_version( \Automattic\Jetpack\Constants::get_constant( 'WC_VERSION' ) );
+
+ // Fetch changes.
+ $changes = $subscription->get_changes();
+ $this->persist_updates( $subscription );
+
+ // Update download permissions if necessary.
+ if ( array_key_exists( 'billing_email', $changes ) || array_key_exists( 'customer_id', $changes ) ) {
+ $data_store = \WC_Data_Store::load( 'customer-download' );
+ $data_store->update_user_by_order_id( $subscription->get_id(), $subscription->get_customer_id(), $subscription->get_billing_email() );
+ }
+
+ // Mark user account as active.
+ if ( array_key_exists( 'customer_id', $changes ) ) {
+ wc_update_user_last_active( $subscription->get_customer_id() );
+ }
+
+ $subscription->apply_changes();
+ $this->clear_caches( $subscription );
+
+ // For backwards compatibility we trigger the `woocommerce_update_order` hook.
+ do_action( 'woocommerce_update_order', $subscription->get_id(), $subscription );
+
+ do_action( 'woocommerce_update_subscription', $subscription->get_id(), $subscription );
+ }
+
+ /**
+ * Saves a subscription to the database.
+ *
+ * When a subscription is saved to the database we need to ensure we also save core subscription properties. The
+ * parent::persist_order_to_db() will create and save the WC_Order inherited data, this method will save the
+ * subscription core properties.
+ *
+ * @param WC_Subscription $subscription The subscription to save.
+ * @param bool $force_all_fields Optional. Whether to force all fields to be saved. Default false.
+ */
+ protected function persist_order_to_db( &$subscription, bool $force_all_fields = false ) {
+ $is_update = ( 0 !== absint( $subscription->get_id() ) );
+
+ // Call the parent function first so WC can get an ID if this a new subscription.
+ parent::persist_order_to_db( $subscription, $force_all_fields );
+
+ // Get the subscription's current raw metadata.
+ $subscription_meta_data = array_column( $this->data_store_meta->read_meta( $subscription ), null, 'meta_key' );
+
+ // Determine what fields need to be saved. Forcing all fields to be saved is only allowed when updating.
+ if ( $force_all_fields && $is_update ) {
+ $props_to_save = $this->subscription_meta_keys_to_props;
+ } else {
+ $props_to_save = $this->get_props_to_update( $subscription, $this->subscription_meta_keys_to_props );
+ }
+
+ foreach ( $props_to_save as $meta_key => $prop ) {
+ $is_date_prop = ( 'schedule_' === substr( $prop, 0, 9 ) );
+
+ if ( $is_date_prop ) {
+ $meta_value = $subscription->get_date( $prop );
+ } else {
+ $meta_value = $subscription->{"get_$prop"}( 'edit' );
+ }
+
+ // Store as a string of the boolean for backward compatibility (yep, it's gross)
+ if ( 'requires_manual_renewal' === $prop ) {
+ $meta_value = wc_string_to_bool( $meta_value ) ? 'true' : 'false';
+ }
+
+ $existing_meta_data = $subscription_meta_data[ $meta_key ] ?? false;
+ $new_meta_data = [
+ 'key' => $meta_key,
+ 'value' => $meta_value,
+ ];
+
+ if ( empty( $existing_meta_data ) ) {
+ $this->data_store_meta->add_meta( $subscription, (object) $new_meta_data );
+ } elseif ( $existing_meta_data->meta_value !== $new_meta_data['value'] ) {
+ $new_meta_data['id'] = $existing_meta_data->meta_id;
+ $this->data_store_meta->update_meta( $subscription, (object) $new_meta_data );
+ }
+ }
+ }
+
+ /**
+ * Initializes the subscription based on data received from the database.
+ *
+ * @param WC_Abstract_Order $subscription The subscription object.
+ * @param int $subscription_id The subscription's ID.
+ * @param stdClass $subscription_data All the subscription's data, retrieved from the database.
+ */
+ protected function init_order_record( \WC_Abstract_Order &$subscription, int $subscription_id, \stdClass $subscription_data ) {
+ // Call the parent version of this function which will set all the core order properties that a subscription inherits.
+ parent::init_order_record( $subscription, $subscription_id, $subscription_data );
+
+ if ( empty( $subscription_data->meta_data ) ) {
+ return;
+ }
+
+ // Flag the subscription as still being read from the database while we set our subscription properties.
+ $subscription->set_object_read( false );
+
+ // Set subscription specific properties that we store in meta.
+ $meta_data = wp_list_pluck( $subscription_data->meta_data, 'meta_value', 'meta_key' );
+ $dates_to_set = [];
+ $props_to_set = [];
+
+ foreach ( $this->subscription_meta_keys_to_props as $meta_key => $prop_key ) {
+ $is_scheduled_date = 0 === strpos( $prop_key, 'schedule' );
+ $is_internal_meta = in_array( $meta_key, $this->internal_meta_keys, true );
+
+ // We only need to set props that are internal meta keys or dates. Everything else is treated as meta.
+ if ( ! $is_scheduled_date && ! $is_internal_meta ) {
+ continue;
+ }
+
+ // If we're setting the start date and it's missing, we set it to the created date.
+ if ( 'schedule_start' === $prop_key && empty( $meta_data[ $meta_key ] ) ) {
+ $meta_data[ $meta_key ] = $subscription->get_date( 'date_created' );
+ }
+
+ // If there's no meta data, we don't need to set anything.
+ if ( ! isset( $meta_data[ $meta_key ] ) ) {
+ continue;
+ }
+
+ if ( $is_scheduled_date ) {
+ $dates_to_set[ $prop_key ] = $meta_data[ $meta_key ];
+ } else {
+ $props_to_set[ $prop_key ] = maybe_unserialize( $meta_data[ $meta_key ] );
+ }
+ }
+
+ // Set the dates and props.
+ if ( $dates_to_set ) {
+ $subscription->update_dates( $dates_to_set );
+ }
+
+ $subscription->set_props( $props_to_set );
+
+ // Flag the subscription as read.
+ $subscription->set_object_read( true );
+ }
+
+ /**
+ * Updates subscription dates in the database.
+ *
+ * @param \WC_Subscription $subscription Subscription object.
+ *
+ * @return DateTime[] The date properties which were saved to the database in array format: [ $prop_name => DateTime Object ]
+ */
+ public function save_dates( $subscription ) {
+ $dates_to_save = [];
+ $changes = $subscription->get_changes();
+ $date_meta_keys = [
+ '_schedule_payment_retry' => 'schedule_payment_retry', // This is the only date potentially missing from wcs_get_subscription_date_types().
+ ];
+
+ // Add any custom date types to the date meta keys we need to save.
+ foreach ( wcs_get_subscription_date_types() as $date_type => $date_name ) {
+ if ( 'last_payment' === $date_type ) {
+ continue;
+ }
+
+ $date_meta_keys[ wcs_get_date_meta_key( $date_type ) ] = wcs_maybe_prefix_key( $date_type, 'schedule_' );
+ }
+
+ $date_meta_keys_to_props = array_intersect_key( $this->subscription_meta_keys_to_props, $date_meta_keys );
+
+ // Save the changes to scheduled dates.
+ foreach ( $this->get_props_to_update( $subscription, $date_meta_keys_to_props ) as $prop ) {
+ $dates_to_save[] = $prop;
+ }
+
+ // Record any changes to the created date.
+ if ( isset( $changes['date_created'] ) ) {
+ $dates_to_save[] = 'date_created';
+ }
+
+ // Record any changes to the modified date.
+ if ( isset( $changes['date_modified'] ) ) {
+ $dates_to_save[] = 'date_modified';
+ }
+
+ // Backfill the saved dates if syncing is enabled.
+ $data_synchronizer = wc_get_container()->get( Automattic\WooCommerce\Internal\DataStores\Orders\DataSynchronizer::class );
+ if ( $data_synchronizer && $data_synchronizer->data_sync_is_enabled() ) {
+ $this->get_post_data_store_for_backfill()->write_dates_to_database( $subscription, $dates_to_save );
+ }
+
+ return $this->write_dates_to_database( $subscription, $dates_to_save );
+ }
+
+ /**
+ * Writes subscription dates to the database.
+ *
+ * @param WC_Subscription $subscription The subscription to write date changes for.
+ * @param array $dates_to_save The dates to write to the database.
+ *
+ * @return WC_DateTime[] The date properties saved to the database in the format: array( $prop_name => WC_DateTime Object ).
+ */
+ public function write_dates_to_database( $subscription, $dates_to_save ) {
+ global $wpdb;
+ $dates_to_save = array_flip( $dates_to_save );
+ $dates_saved = [];
+ $order_update_query = [];
+
+ if ( isset( $dates_to_save['date_created'] ) ) {
+ $order_update_query[] = $wpdb->prepare( '`date_created_gmt` = %s', gmdate( 'Y-m-d H:i:s', $subscription->get_date_created( 'edit' )->getTimestamp() ) );
+
+ // Mark the created date as saved.
+ unset( $dates_to_save['date_created'] );
+ $dates_saved['date_created'] = $subscription->get_date_created();
+ }
+
+ if ( isset( $dates_to_save['date_modified'] ) ) {
+ $order_update_query[] = $wpdb->prepare( '`date_updated_gmt` = %s', gmdate( 'Y-m-d H:i:s', $subscription->get_date_modified( 'edit' )->getTimestamp() ) );
+
+ // Mark the modified date as saved.
+ unset( $dates_to_save['date_modified'] );
+ $dates_saved['date_modified'] = $subscription->get_date_modified();
+ }
+
+ // Manually update the order's created and/or modified date if it has changed.
+ if ( ! empty( $order_update_query ) ) {
+ $table_name = self::get_orders_table_name();
+ $set = implode( ', ', $order_update_query );
+
+ $wpdb->query(
+ $wpdb->prepare(
+ "UPDATE {$table_name} SET {$set} WHERE id = %d", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
+ $subscription->get_id()
+ )
+ );
+ }
+
+ $subscription_meta_data = array_column( $this->data_store_meta->read_meta( $subscription ), null, 'meta_key' );
+
+ // Write the remaining dates to meta.
+ foreach ( $dates_to_save as $date_prop => $index ) {
+ $date_type = wcs_normalise_date_type_key( $date_prop );
+ $meta_key = wcs_get_date_meta_key( $date_type );
+ $existing_meta_data = $subscription_meta_data[ $meta_key ] ?? false;
+ $new_meta_data = [
+ 'key' => $meta_key,
+ 'value' => $subscription->get_date( $date_type ),
+ ];
+
+ if ( ! empty( $existing_meta_data ) ) {
+ $new_meta_data['id'] = $existing_meta_data->meta_id;
+ $this->data_store_meta->update_meta( $subscription, (object) $new_meta_data );
+ } else {
+ $this->data_store_meta->add_meta( $subscription, (object) $new_meta_data );
+ }
+
+ $dates_saved[ $date_prop ] = wcs_get_datetime_from( $subscription->get_time( $date_type ) );
+ }
+
+ return $dates_saved;
+ }
+
+ /**
+ * Searches subscription data for a term and returns subscription IDs.
+ *
+ * @param string $term Term to search.
+ *
+ * @return array A list of subscriptions IDs that match the search term.
+ */
+ public function search_subscriptions( $term ) {
+ add_filter( 'woocommerce_order_table_search_query_meta_keys', [ $this, 'get_subscription_order_table_search_fields' ] );
+
+ $subscription_ids = wc_get_orders(
+ [
+ 's' => $term,
+ 'type' => 'shop_subscription',
+ 'status' => array_keys( wcs_get_subscription_statuses() ),
+ 'return' => 'ids',
+ 'limit' => -1,
+ ]
+ );
+
+ remove_filter( 'woocommerce_order_table_search_query_meta_keys', [ $this, 'get_subscription_order_table_search_fields' ] );
+
+ return apply_filters( 'woocommerce_shop_subscription_search_results', $subscription_ids, $term, $this->get_subscription_order_table_search_fields() );
+ }
+
+ /**
+ * Gets the subscription search fields.
+ *
+ * This function is hooked onto the 'woocommerce_order_table_search_query_meta_keys' filter.
+ *
+ * @param array The default order search fields.
+ *
+ * @return array The subscription search fields.
+ */
+ public function get_subscription_order_table_search_fields( $search_fields = [] ) {
+ return array_map(
+ 'wc_clean',
+ apply_filters(
+ 'woocommerce_shop_subscription_search_fields',
+ [
+ '_billing_address_index',
+ '_shipping_address_index',
+ ]
+ )
+ );
+ }
+
+ /**
+ * Gets user IDs for customers who have a subscription.
+ *
+ * @return array An array of user IDs.
+ */
+ public function get_subscription_customer_ids() {
+ global $wpdb;
+ $table_name = self::get_orders_table_name();
+
+ return $wpdb->get_col( "SELECT DISTINCT customer_id FROM {$table_name} WHERE type = 'shop_subscription'" ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
+ }
+
+ /**
+ * Deletes all rows in the postmeta table with the given meta key.
+ *
+ * @param string $meta_key The meta key to delete.
+ */
+ public function delete_all_metadata_by_key( $meta_key ) {
+ global $wpdb;
+
+ $wpdb->delete( self::get_meta_table_name(), [ 'meta_key' => $meta_key ], [ '%s' ] ); // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key
+ }
+
+ /**
+ * Count subscriptions by status.
+ *
+ * @return array
+ */
+ public function get_subscriptions_count_by_status() {
+ global $wpdb;
+
+ $table = self::get_orders_table_name();
+ $results = $wpdb->get_results( "SELECT status, COUNT(*) AS cnt FROM {$table} WHERE type = 'shop_subscription' GROUP BY status", ARRAY_A ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
+
+ return $results ? array_combine( array_column( $results, 'status' ), array_map( 'absint', array_column( $results, 'cnt' ) ) ) : array();
+ }
+}
diff --git a/vendor/woocommerce/subscriptions-core/includes/data-stores/class-wcs-product-variable-data-store-cpt.php b/vendor/woocommerce/subscriptions-core/includes/data-stores/class-wcs-product-variable-data-store-cpt.php
index 620a68c..bf78370 100644
--- a/vendor/woocommerce/subscriptions-core/includes/data-stores/class-wcs-product-variable-data-store-cpt.php
+++ b/vendor/woocommerce/subscriptions-core/includes/data-stores/class-wcs-product-variable-data-store-cpt.php
@@ -6,7 +6,7 @@ if ( ! defined( 'ABSPATH' ) ) {
/**
* WCS Variable Product Data Store: Stored in CPT.
*
- * @version 2.3.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.0
* @author Prospress
*/
class WCS_Product_Variable_Data_Store_CPT extends WC_Product_Variable_Data_Store_CPT {
diff --git a/vendor/woocommerce/subscriptions-core/includes/data-stores/class-wcs-related-order-store-cached-cpt.php b/vendor/woocommerce/subscriptions-core/includes/data-stores/class-wcs-related-order-store-cached-cpt.php
index f55214f..d8a2974 100644
--- a/vendor/woocommerce/subscriptions-core/includes/data-stores/class-wcs-related-order-store-cached-cpt.php
+++ b/vendor/woocommerce/subscriptions-core/includes/data-stores/class-wcs-related-order-store-cached-cpt.php
@@ -4,33 +4,48 @@ if ( ! defined( 'ABSPATH' ) ) {
}
/**
- * Related order data store for orders and subscriptions stored in Custom Post Types, with caching.
+ * Related order data store for orders and subscriptions with caching.
*
- * Adds a persistent caching layer on top of WCS_Related_Order_Store_CPT for more
- * performant queries on related orders.
+ * Subscription related orders (renewals, switch and resubscribe orders) record their relationship in order meta.
+ * Historically finding subscription-related orders was costly as it required querying the database for all orders with specific meta key and meta value.
+ * This required a performance heavy postmeta query and wp_post join. To fix this, in WC Subscriptions 2.3.0 we introduced a persistent caching layer. In
+ * subscription metadata we now store a single key to keep track of the subscription's related orders.
*
- * @version 2.3.0
- * @category Class
- * @author Prospress
+ * This class adds a persistent caching layer on top of WCS_Related_Order_Store_CPT for more
+ * performant queries on related orders. This class contains the methods to fetch, update and delete the meta caches.
+ *
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.0
*/
class WCS_Related_Order_Store_Cached_CPT extends WCS_Related_Order_Store_CPT implements WCS_Cache_Updater {
/**
- * Keep cache up-to-date with changes to our meta data via WordPress post meta APIs
- * by using a post meta cache manager.
+ * Keep cache up-to-date with changes to our meta data using a meta cache manager.
*
- * @var WCS_Post_Meta_Cache_Manager
+ * @var WCS_Post_Meta_Cache_Manager|WCS_Object_Data_Cache_Manager
*/
- protected $post_meta_cache_manager;
+ protected $object_data_cache_manager;
/**
- * Store order relations using post meta keys as the array key for more performant searches
+ * Store order relations using meta keys as the array key for more performant searches
* in @see $this->get_relation_type_for_meta_key() than using array_search().
*
- * @var array $relation_keys Post meta key => Order Relationship
+ * @var array $relation_keys meta key => Order Relationship
*/
private $relation_keys;
+ /**
+ * A flag to indicate whether the related order cache keys should be ignored.
+ *
+ * By default the related order cache keys are ignored via $this->add_related_order_cache_props(). In order to fetch the subscription's
+ * meta with this cache's keys present, we need a way to bypass that function.
+ *
+ * Important: We use a static variable here because it is possible to have multiple instances of this class in memory, and we want to make sure we bypass
+ * the function in all instances. This is especially true in unit tests. We can't make add_related_order_cache_props static because it uses $this in scope.
+ *
+ * @var bool $override_ignored_props True if the related order cache keys should be ignored otherwise false.
+ */
+ private static $override_ignored_props = false;
+
/**
* Constructor
*/
@@ -42,29 +57,53 @@ class WCS_Related_Order_Store_Cached_CPT extends WCS_Related_Order_Store_CPT imp
$this->relation_keys[ $meta_key ] = $relation_type;
}
- $this->post_meta_cache_manager = new WCS_Post_Meta_Cache_Manager( 'shop_order', $this->get_meta_keys() );
+ if ( wcs_is_custom_order_tables_usage_enabled() ) {
+ $this->object_data_cache_manager = new WCS_Object_Data_Cache_Manager( 'order', $this->get_meta_keys() );
+ } else {
+ $this->object_data_cache_manager = new WCS_Post_Meta_Cache_Manager( 'shop_order', $this->get_meta_keys() );
+ }
}
/**
- * Attach callbacks to keep related order caches up-to-date and make sure
- * the cache doesn't mess with other data stores.
+ * Gets the legacy protected variables for backwards compatibility.
+ *
+ * Throws a deprecated warning if accessing the now deprecated variables.
+ *
+ * @param string $name The variable name.
+ * @return WCS_Post_Meta_Cache_Manager_Many_To_One|WCS_Object_Data_Cache_Manager_Many_To_One Depending on the HPOS environment.
+ */
+ public function __get( $name ) {
+ if ( 'post_meta_cache_manager' !== $name ) {
+ return;
+ }
+
+ $old = get_class( $this ) . '::post_meta_cache_manager';
+ $replacement = get_class( $this ) . '::object_data_cache_manager';
+
+ wcs_doing_it_wrong( $old, "$old has been deprecated, use $replacement instead.", '5.2.0' );
+
+ return $this->object_data_cache_manager;
+ }
+
+ /**
+ * Attaches callbacks to keep related order caches up-to-date.
*/
protected function init() {
- $this->post_meta_cache_manager->init();
+ $this->object_data_cache_manager->init();
- // Don't load cached related order meta data into subscriptions
+ // When a subscription is being read from the database, don't load cached related order meta data into subscriptions.
add_filter( 'wcs_subscription_data_store_props_to_ignore', array( $this, 'add_related_order_cache_props' ), 10, 2 );
- // When a subscription is first created, make sure its renewal order cache is empty because it can not have any renewals yet, and we want to avoid running the query needlessly
+ // When a subscription is first created, make sure its renewal order cache is empty because it can not have any renewals yet, and we want to avoid running the query needlessly.
add_filter( 'wcs_created_subscription', array( $this, 'set_empty_renewal_order_cache' ), -1000 );
- // When the post for a related order is deleted or untrashed, make sure the corresponding related order cache is updated
+ // When the post for a related order is deleted or untrashed, make sure the corresponding related order cache is updated.
add_action( 'wcs_update_post_meta_caches', array( $this, 'maybe_update_for_post_meta_change' ), 10, 5 );
add_action( 'wcs_delete_all_post_meta_caches', array( $this, 'maybe_delete_all_for_post_meta_change' ), 10, 1 );
// When copying meta from a subscription to a renewal order, don't copy cache related order meta keys.
- add_filter( 'wcs_renewal_order_meta', array( $this, 'remove_related_order_cache_keys' ), 10, 1 );
+ add_filter( 'wc_subscriptions_renewal_order_data', array( $this, 'remove_related_order_cache_keys' ), 10, 1 );
WCS_Debug_Tool_Factory::add_cache_tool( 'generator', __( 'Generate Related Order Cache', 'woocommerce-subscriptions' ), __( 'This will generate the persistent cache of all renewal, switch, resubscribe and other order types for all subscriptions in your store. The caches will be generated overtime in the background (via Action Scheduler).', 'woocommerce-subscriptions' ), self::instance() );
WCS_Debug_Tool_Factory::add_cache_tool( 'eraser', __( 'Delete Related Order Cache', 'woocommerce-subscriptions' ), __( 'This will clear the persistent cache of all renewal, switch, resubscribe and other order types for all subscriptions in your store. Expect slower performance of checkout, renewal and other subscription related functions after taking this action. The caches will be regenerated overtime as related order queries are run.', 'woocommerce-subscriptions' ), self::instance() );
@@ -73,165 +112,232 @@ class WCS_Related_Order_Store_Cached_CPT extends WCS_Related_Order_Store_CPT imp
/* Public methods required by WCS_Related_Order_Store */
/**
- * Find orders related to a given subscription in a given way.
+ * Finds orders related to a given subscription.
*
- * Wrapper to support getting related orders regardless of whether they are cached or not yet,
+ * This function is a wrapper to support getting related orders regardless of whether they are cached or not yet,
* either in the old transient cache, or new persistent cache.
*
- * @param WC_Order $subscription The ID of the subscription for which calling code wants the related orders.
- * @param string $relation_type The relationship between the subscription and the orders. Must be 'renewal', 'switch' or 'resubscribe.
+ * @param WC_Order $subscription The ID of the subscription for which calling code wants the related orders.
+ * @param string $relation_type The relationship between the subscription and the orders. Must be 'renewal', 'switch' or 'resubscribe.
*
- * @return array
+ * @return array An array of related order IDs.
*/
public function get_related_order_ids( WC_Order $subscription, $relation_type ) {
- $subscription_id = wcs_get_objects_property( $subscription, 'id' ); // We can't rely on $subscription->get_id() being available because we only require a WC_Order, not a WC_Subscription, and WC_Order does not have get_id() available with WC < 3.0
- $related_order_ids = $this->get_related_order_ids_from_cache( $subscription_id, $relation_type );
+ $related_order_ids = $this->get_related_order_ids_from_cache( $subscription, $relation_type );
- // get_post_meta returns false if the post ID is invalid. This can arise when the subscription hasn't been created yet. In any case, the related IDs should be an empty array to avoid a boolean return from this function.
+ // get_related_order_ids_from_cache() returns false if the ID is invalid. This can arise when the subscription hasn't been created yet. In any case, the related IDs should be an empty array to avoid a boolean return from this function.
if ( false === $related_order_ids ) {
$related_order_ids = array();
}
- // get post meta returns an empty string when no matching row is found for the given key, meaning it's not set yet
+ // get_related_order_ids_from_cache() returns an empty string when no matching row is found for the given key, meaning it's not set yet.
if ( '' === $related_order_ids ) {
+ // If the cache is empty attempt to get the renewal order IDs from the old transient cache.
if ( 'renewal' === $relation_type ) {
- $transient_key = "wcs-related-orders-to-{$subscription_id}"; // despite the name, this transient only stores renewal orders, not all related orders, so we can only use it for finding renewal orders
+ $transient_key = "wcs-related-orders-to-{$subscription->get_id()}"; // Despite the name, this transient only stores renewal orders, not all related orders, so we can only use it for finding renewal orders.
- // We do this here rather than in get_related_order_ids_from_cache(), because we want to make sure the new persistent cache is updated too
+ // We do this here rather than in get_related_order_ids_from_cache(), because we want to make sure the new persistent cache is updated too.
$related_order_ids = get_transient( $transient_key );
} else {
$related_order_ids = false;
}
if ( false === $related_order_ids ) {
- $related_order_ids = parent::get_related_order_ids( $subscription, $relation_type ); // no data in transient, query directly
+ $related_order_ids = parent::get_related_order_ids( $subscription, $relation_type ); // No data in transient, query directly.
} else {
- rsort( $related_order_ids ); // queries are ordered from newest ID to oldest, so make sure the transient value is too
- delete_transient( $transient_key ); // we migrate the data to our new cache so want to remote this cache
+ rsort( $related_order_ids ); // Queries are ordered from newest ID to oldest, so make sure the transient value is too.
+ delete_transient( $transient_key ); // We migrate the data to our new cache so can delete the old one.
}
- $this->update_related_order_id_cache( $subscription_id, $related_order_ids, $relation_type );
+ $this->update_related_order_id_cache( $subscription, $related_order_ids, $relation_type );
}
return $related_order_ids;
}
/**
- * Helper function for linking an order to a subscription via a given relationship.
+ * Links an order to a subscription via a given relationship.
*
- * @param WC_Order $order The order to link with the subscription.
- * @param WC_Order $subscription The order or subscription to link the order to.
- * @param string $relation_type The relationship between the subscription and the order. Must be 'renewal', 'switch' or 'resubscribe' unless custom relationships are implemented.
+ * @param WC_Order $order The order to link with the subscription.
+ * @param WC_Order $subscription The order or subscription to link the order to.
+ * @param string $relation_type The relationship between the subscription and the order. Must be 'renewal', 'switch' or 'resubscribe' unless custom relationships are implemented.
*/
public function add_relation( WC_Order $order, WC_Order $subscription, $relation_type ) {
- $this->add_related_order_id_to_cache( wcs_get_objects_property( $order, 'id' ), wcs_get_objects_property( $subscription, 'id' ), $relation_type );
+ $this->add_related_order_id_to_cache( $order->get_id(), $subscription, $relation_type );
parent::add_relation( $order, $subscription, $relation_type );
}
/**
- * Remove the relationship between a given order and subscription.
+ * Removes the relationship between a given order and subscription.
*
- * @param WC_Order $order An order that may be linked with subscriptions.
- * @param WC_Order $subscription A subscription or order to unlink the order with, if a relation exists.
- * @param string $relation_type The relationship between the subscription and the order. Must be 'renewal', 'switch' or 'resubscribe' unless custom relationships are implemented.
+ * @param WC_Order $order An order that may be linked with subscriptions.
+ * @param WC_Order $subscription A subscription or order to unlink the order with, if a relation exists.
+ * @param string $relation_type The relationship between the subscription and the order. Must be 'renewal', 'switch' or 'resubscribe' unless custom relationships are implemented.
*/
public function delete_relation( WC_Order $order, WC_Order $subscription, $relation_type ) {
- $this->delete_related_order_id_from_cache( wcs_get_objects_property( $order, 'id' ), wcs_get_objects_property( $subscription, 'id' ), $relation_type );
+ $this->delete_related_order_id_from_cache( $order->get_id(), $subscription, $relation_type );
parent::delete_relation( $order, $subscription, $relation_type );
}
/**
- * Remove all related orders/subscriptions of a given type from an order.
+ * Removes all related orders/subscriptions of a given type from an order.
*
- * @param WC_Order $order An order that may be linked with subscriptions.
- * @param string $relation_type The relationship between the subscription and the order. Must be 'renewal', 'switch' or 'resubscribe' unless custom relationships are implemented.
+ * @param WC_Order $order An order that may be linked with subscriptions.
+ * @param string $relation_type The relationship between the subscription and the order. Must be 'renewal', 'switch' or 'resubscribe' unless custom relationships are implemented.
*/
public function delete_relations( WC_Order $order, $relation_type ) {
- $this->delete_related_order_id_from_caches( wcs_get_objects_property( $order, 'id' ), $relation_type );
+ $this->delete_related_order_id_from_caches( $order->get_id(), $relation_type );
parent::delete_relations( $order, $relation_type );
}
/* Internal methods for managing the cache */
/**
- * Find orders related to a given subscription in a given way from the cache.
+ * Finds orders related to a given subscription in a given way from the cache.
+ *
+ * @param WC_Subscription|int $subscription_id The Subscription ID or subscription object to fetch related orders.
+ * @param string $relation_type The relationship between the subscription and the orders. Must be 'renewal', 'switch' or 'resubscribe.
*
- * @param int $subscription_id The ID of the subscription for which calling code wants the related orders.
- * @param string $relation_type The relationship between the subscription and the orders. Must be 'renewal', 'switch' or 'resubscribe.
* @return string|array An array of related orders in the cache, or an empty string when no matching row is found for the given key, meaning it's cache is not set yet or has been deleted
*/
- protected function get_related_order_ids_from_cache( $subscription_id, $relation_type ) {
- return get_post_meta( $subscription_id, $this->get_cache_meta_key( $relation_type ), true );
+ public function get_related_order_ids_from_cache( $subscription, $relation_type ) {
+ $subscription = is_object( $subscription ) ? $subscription : wcs_get_subscription( $subscription );
+
+ if ( ! wcs_is_subscription( $subscription ) ) {
+ return false;
+ }
+
+ $meta_data = $this->get_related_order_metadata( $subscription, $relation_type );
+
+ return $meta_data ? maybe_unserialize( $meta_data->meta_value ) : '';
}
/**
- * Add a related order ID to the cached related order IDs for a given order relationship.
+ * Adds an order ID to a subscription's related order cache for a given relationship.
*
- * @param int $order_id An order to link with the subscription.
- * @param int $subscription_id A subscription to link the order to.
- * @param string $relation_type The relationship between the subscription and the orders. Must be 'renewal', 'switch' or 'resubscribe.
+ * @param int $order_id An order to link with the subscription.
+ * @param WC_Subscription|int $subscription A subscription to link the order to. Accepts a subscription object or ID.
+ * @param string $relation_type The relationship between the subscription and the order. Must be 'renewal', 'switch' or 'resubscribe.
*/
- protected function add_related_order_id_to_cache( $order_id, $subscription_id, $relation_type ) {
+ protected function add_related_order_id_to_cache( $order_id, $subscription, $relation_type ) {
+ $subscription = is_object( $subscription ) ? $subscription : wcs_get_subscription( $subscription );
- $subscription = wcs_get_subscription( $subscription_id );
-
- // If we can't get a valid subscription, we can't update its cache
+ // If we can't get a valid subscription, we can't update its cache.
if ( false === $subscription ) {
return;
}
$related_order_ids = $this->get_related_order_ids( $subscription, $relation_type );
- if ( ! in_array( $order_id, $related_order_ids ) ) {
- // Add the new order to the beginning of the array to preserve sort order from newest to oldest
+ if ( ! in_array( $order_id, $related_order_ids, true ) ) {
+ // Add the new order to the beginning of the array to preserve sort order from newest to oldest.
array_unshift( $related_order_ids, $order_id );
- $this->update_related_order_id_cache( $subscription_id, $related_order_ids, $relation_type );
+ $this->update_related_order_id_cache( $subscription, $related_order_ids, $relation_type );
}
}
/**
- * Delete a related order ID from the cached related order IDs for a given order relationship.
+ * Deletes a related order ID from a subscription's related orders cache for a given order relationship.
*
- * @param int $order_id The order that may be linked with subscriptions.
- * @param int $subscription_id A subscription to remove a linked order from.
- * @param string $relation_type The relationship between the subscription and the orders. Must be 'renewal', 'switch' or 'resubscribe.
+ * @param int $order_id The order that may be linked with subscriptions.
+ * @param WC_Subscription|int $subscription A subscription to remove a linked order from. Accepts a subscription object or ID.
+ * @param string $relation_type The relationship between the subscription and the orders. Must be 'renewal', 'switch' or 'resubscribe.e.
*/
- protected function delete_related_order_id_from_cache( $order_id, $subscription_id, $relation_type ) {
+ protected function delete_related_order_id_from_cache( $order_id, $subscription, $relation_type ) {
+ $subscription = is_object( $subscription ) ? $subscription : wcs_get_subscription( $subscription );
- $subscription = wcs_get_subscription( $subscription_id );
-
- // If we can't get a valid subscription, we can't udpate its cache
+ // If we can't get a valid subscription, we can't update its cache.
if ( false === $subscription ) {
return;
}
- $related_order_ids = $this->get_related_order_ids( $subscription, $relation_type );
+ $related_order_ids = $this->get_related_order_ids( $subscription, $relation_type );
+ $related_order_ids = array_map( 'absint', $related_order_ids );
+ $related_order_index = array_search( $order_id, $related_order_ids, true );
- if ( ( $index = array_search( $order_id, $related_order_ids ) ) !== false ) {
- unset( $related_order_ids[ $index ] );
- $this->update_related_order_id_cache( $subscription_id, $related_order_ids, $relation_type );
+ if ( false !== $related_order_index ) {
+ unset( $related_order_ids[ $related_order_index ] );
+ $this->update_related_order_id_cache( $subscription, $related_order_ids, $relation_type );
}
}
/**
- * Helper function for setting related order cache.
+ * Sets a subscription's related order cache for a given relationship.
*
- * @param int $subscription_id A subscription to update the linked order IDs for.
- * @param array $related_order_ids Set of orders related to the given subscription.
- * @param string $relation_type The relationship between the subscription and the order. Must be 'renewal', 'switch' or 'resubscribe' unless custom relationships are implemented.
- * @return bool|int Returns related order cache's meta ID if it doesn't exist yet, otherwise returns true on success and false on failure. NOTE: If the $related_order_ids passed to this function are the same as those already in the database, this function returns false.
+ * @param WC_Subscription|int $subscription A subscription to update the linked order IDs for.
+ * @param array $related_order_ids Set of orders related to the given subscription.
+ * @param string $relation_type The relationship between the subscription and the order. Must be 'renewal', 'switch' or 'resubscribe' unless custom relationships are implemented.
+ *
+ * @return bool|int Returns the related order cache's meta ID if it didn't exist, otherwise returns true on success and false on failure. NOTE: If the $related_order_ids passed to this function are the same as those already in the database, this function returns false.
*/
- protected function update_related_order_id_cache( $subscription_id, array $related_order_ids, $relation_type ) {
- return update_post_meta( $subscription_id, $this->get_cache_meta_key( $relation_type ), $related_order_ids );
+ protected function update_related_order_id_cache( $subscription, array $related_order_ids, $relation_type ) {
+
+ if ( ! is_object( $subscription ) ) {
+ $subscription = wcs_get_subscription( $subscription );
+
+ if ( ! $subscription ) {
+ return false;
+ }
+ }
+
+ $subscription_data_store = WC_Data_Store::load( 'subscription' );
+ $current_metadata = $this->get_related_order_metadata( $subscription, $relation_type );
+ $new_metadata = array(
+ 'key' => $this->get_cache_meta_key( $relation_type ),
+ 'value' => $related_order_ids,
+ );
+
+ // Check if HPOS and data syncing is enabled then manually backfill the related orders cache values to WP Posts table.
+ $this->maybe_backfill_related_order_cache( $subscription, $relation_type, $new_metadata );
+
+ // If there is metadata for this key, update it, otherwise add it.
+ if ( $current_metadata ) {
+ $new_metadata['id'] = $current_metadata->meta_id;
+ return $subscription_data_store->update_meta( $subscription, (object) $new_metadata );
+ } else {
+ return $subscription_data_store->add_meta( $subscription, (object) $new_metadata );
+ }
}
/**
- * Get the meta key used to store the cache of linked order with a subscription, based on the type of relationship.
+ * Backfills the related order cache for a subscription when the "Keep the posts table and the orders tables synchronized"
+ * setting is enabled.
*
- * @param string $relation_type The order's relationship with the subscription. Must be 'renewal', 'switch' or 'resubscribe'.
+ * In this class we update the related orders cache metadata directly to ensure the
+ * proper value is written to the database. To do this we use the data store's update_meta() and
+ * add_meta() functions.
+ *
+ * Using these functions bypasses the DataSynchronizer resulting in order and post data becoming out of sync.
+ * To fix this, this function manually updates the post meta table with the new values.
+ *
+ * @param WC_Subscription $subscription The subscription object to backfill.
+ * @param string $relation_type The related order relationship type. Can be 'renewal', 'switch' or 'resubscribe'.
+ * @param array $metadata The metadata to set update/add in the CPT data store. Should be an array with 'key' and 'value' keys.
+ */
+ protected function maybe_backfill_related_order_cache( $subscription, $relation_type, $metadata ) {
+ if ( ! wcs_is_custom_order_tables_usage_enabled() || ! wcs_is_custom_order_tables_data_sync_enabled() || empty( $metadata['key'] ) ) {
+ return;
+ }
+
+ $cpt_data_store = $subscription->get_data_store()->get_cpt_data_store_instance();
+ $current_metadata = $this->get_related_order_metadata( $subscription, $relation_type, $cpt_data_store );
+
+ if ( $current_metadata ) {
+ $metadata['id'] = $current_metadata->meta_id;
+ $cpt_data_store->update_meta( $subscription, (object) $metadata );
+ } else {
+ $cpt_data_store->add_meta( $subscription, (object) $metadata );
+ }
+ }
+
+ /**
+ * Gets the meta key used to store the cache of linked order with a subscription, based on the type of relationship.
+ *
+ * @param string $relation_type The order's relationship with the subscription. Must be 'renewal', 'switch' or 'resubscribe'.
* @param string $prefix_meta_key Whether to add the underscore prefix to the meta key or not. 'prefix' to prefix the key. 'do_not_prefix' to not prefix the key.
- * @return string
+ *
+ * @return string The related order cache meta key.
*/
protected function get_cache_meta_key( $relation_type, $prefix_meta_key = 'prefix' ) {
return sprintf( '%s_order_ids_cache', $this->get_meta_key( $relation_type, $prefix_meta_key ) );
@@ -240,57 +346,61 @@ class WCS_Related_Order_Store_Cached_CPT extends WCS_Related_Order_Store_CPT imp
/* Public methods used to bulk edit cache */
/**
- * Clear related order caches for a given subscription.
+ * Clears all related order caches for a given subscription.
*
- * @param int $subscription_id The ID of a subscription that may have linked orders.
- * @param string $relation_type The relationship between the subscription and the order. Must be 'renewal', 'switch' or 'resubscribe' unless custom relationships are implemented. Use 'any' to delete all cached.
+ * @param WC_Subscription|int $subscription_id The ID of a subscription that may have linked orders.
+ * @param string $relation_type The relationship between the subscription and the order. Must be 'renewal', 'switch' or 'resubscribe' unless custom relationships are implemented. Use 'any' to delete all cached.
*/
- public function delete_caches_for_subscription( $subscription_id, $relation_type = 'any' ) {
+ public function delete_caches_for_subscription( $subscription, $relation_type = 'any' ) {
+ $subscription = is_object( $subscription ) ? $subscription : wcs_get_subscription( $subscription );
+
foreach ( $this->get_relation_types() as $possible_relation_type ) {
if ( 'any' === $relation_type || $relation_type === $possible_relation_type ) {
- delete_post_meta( $subscription_id, $this->get_cache_meta_key( $possible_relation_type ) );
+ $metadata = $this->get_related_order_metadata( $subscription, $possible_relation_type );
+
+ if ( $metadata ) {
+ WC_Data_Store::load( 'subscription' )->delete_meta( $subscription, (object) [ 'id' => $metadata->meta_id ] );
+ }
}
}
}
/**
- * Remove an order from all related order caches.
+ * Removes an order from all related order caches.
*
- * @param int $order_id The order that may be linked with subscriptions.
- * @param string $relation_type The relationship between the subscription and the order. Must be 'renewal', 'switch' or 'resubscribe' unless custom relationships are implemented. Use 'any' to delete all cached.
+ * @param int $order_id The order ID that must be removed.
+ * @param string $relation_type Optional. The relationship between the subscription and the order. Can be 'renewal', 'switch' or 'resubscribe' unless custom relationships are implemented. Default is 'any' which deletes the ID from all cache types.
*/
public function delete_related_order_id_from_caches( $order_id, $relation_type = 'any' ) {
$relation_types = 'any' === $relation_type ? $this->get_relation_types() : array( $relation_type );
- foreach ( wcs_get_subscriptions_for_order( $order_id, array( 'order_type' => $relation_types ) ) as $subscription_id => $subscription ) {
+ $subscriptions = wcs_get_subscriptions_for_order( $order_id, array( 'order_type' => $relation_types ) );
+
+ foreach ( $subscriptions as $subscription ) {
foreach ( $relation_types as $type ) {
- $this->delete_related_order_id_from_cache( $order_id, $subscription_id, $type );
+ $this->delete_related_order_id_from_cache( $order_id, $subscription, $type );
}
}
}
/**
- * Clear all related order caches for all subscriptions.
+ * Clears all related order caches for all subscriptions.
*
- * @param array $relation_types The relations to clear, or an empty array to clear all relations (default).
+ * @param array $relation_types Optional. The order relations to clear. Default is an empty array which clears all relations.
*/
public function delete_caches_for_all_subscriptions( $relation_types = array() ) {
-
if ( empty( $relation_types ) ) {
$relation_types = $this->get_relation_types();
}
- // Set variables to workaround ambiguous parameters of delete_metadata()
- $delete_all = true;
- $null_post_id = $null_meta_value = null;
foreach ( $relation_types as $relation_type ) {
- delete_metadata( 'post', $null_post_id, $this->get_cache_meta_key( $relation_type ), $null_meta_value, $delete_all );
+ WC_Data_Store::load( 'subscription' )->delete_all_metadata_by_key( $this->get_cache_meta_key( $relation_type ) );
}
}
/* Public methods used as callbacks on hooks for managing cache */
/**
- * Add related order cache meta keys to a set of props for a subscription data store.
+ * Adds related order cache meta keys to a set of props for a subscription data store.
*
* Related order cache APIs need to be handled by querying a central data source directly, instead of using
* data set on an instance of the subscription, as it can be changed by other events outside of that instance's
@@ -298,12 +408,18 @@ class WCS_Related_Order_Store_Cached_CPT extends WCS_Related_Order_Store_CPT imp
* cache, but regardless, the prop should never be a source of that data. This method is attached to the filter
* 'wcs_subscription_data_store_props_to_ignore' so that cache keys are ignored.
*
- * @param array $props_to_ignore A mapping of meta keys => prop names.
- * @param WCS_Subscription_Data_Store_CPT $data_store
+ * @param array $props_to_ignore A mapping of meta keys => prop names.
+ * @param WCS_Subscription_Data_Store_CPT $data_store Subscriptions Data Store
+ *
* @return array A mapping of meta keys => prop names, filtered by ones that should be updated.
*/
public function add_related_order_cache_props( $props_to_ignore, $data_store ) {
+ // Bail out early if the flag to bypass ignored cache props is set to true.
+ if ( self::$override_ignored_props ) {
+ return $props_to_ignore;
+ }
+
if ( is_a( $data_store, 'WCS_Subscription_Data_Store_CPT' ) ) {
foreach ( $this->get_meta_keys() as $relation_type => $meta_key ) {
$props_to_ignore[ $this->get_cache_meta_key( $relation_type ) ] = $this->get_cache_meta_key( $relation_type, 'do_not_prefix' );
@@ -314,33 +430,33 @@ class WCS_Related_Order_Store_Cached_CPT extends WCS_Related_Order_Store_CPT imp
}
/**
- * Set empty renewal order cache on a subscription.
+ * Sets an empty renewal order cache on a subscription.
*
- * Newly created subscriptions can't have renewal orders yet, so we set that cache to empty whenever a new
- * subscription is created. They can have switch or resubscribe orders, which may have been created before them on
+ * Newly created subscriptions cannot have renewal orders yet, so we set that cache to empty whenever a new
+ * subscription is created. Subscriptions can have switch or resubscribe orders, which may have been created before the subscription on
* checkout, so we don't touch those caches.
*
- * @param WC_Subscription $subscription A subscription to set empty renewal cache against.
- * @return WC_Subscription Return the instance of the subscription, required as method is attached to the 'wcs_created_subscription' filter
+ * @param WC_Subscription $subscription A subscription to set an empty renewal cache against.
+ *
+ * @return WC_Subscription The instance of the subscription. Required as this method is attached to the 'wcs_created_subscription' filter
*/
public function set_empty_renewal_order_cache( WC_Subscription $subscription ) {
- $this->update_related_order_id_cache( $subscription->get_id(), array(), 'renewal' );
+ $this->update_related_order_id_cache( $subscription, array(), 'renewal' );
return $subscription;
}
/* Public methods attached to WCS_Post_Meta_Cache_Manager hooks for managing the cache */
/**
- * If there is a change to a related order post meta key, update the cache.
+ * Updates the cache when there is a change to a related order meta key.
*
- * @param string $update_type The type of update to check. Can be 'add', 'update' or 'delete'.
- * @param int $order_id The post the meta is being changed on.
- * @param string $post_meta_key The post meta key being changed.
- * @param mixed $subscription_id The related subscription's ID, as stored in meta value (only when the meta key is a related order meta key).
- * @param mixed $old_subscription_id The previous value stored in the database for the related subscription. Optional.
+ * @param string $update_type The type of update to check. Can be 'add', 'update' or 'delete'.
+ * @param int $order_id The order ID the meta is being changed on.
+ * @param string $post_meta_key The meta key being changed.
+ * @param mixed $subscription_id The related subscription's ID, as stored in meta value (only when the meta key is a related order meta key).
+ * @param mixed $old_subscription_id Optional. The previous value stored in the database for the related subscription.
*/
public function maybe_update_for_post_meta_change( $update_type, $order_id, $post_meta_key, $subscription_id, $old_subscription_id = '' ) {
-
$relation_type = $this->get_relation_type_for_meta_key( $post_meta_key );
if ( false === $relation_type ) {
@@ -352,7 +468,7 @@ class WCS_Related_Order_Store_Cached_CPT extends WCS_Related_Order_Store_CPT imp
$this->add_related_order_id_to_cache( $order_id, $subscription_id, $relation_type );
break;
case 'delete':
- // If we don't have a specific subscription ID, the order/post is being deleted, so clear it from all caches
+ // If we don't have a specific subscription ID, the order is being deleted, so clear it from all caches.
if ( empty( $subscription_id ) ) {
$this->delete_related_order_id_from_caches( $order_id, $relation_type );
} else {
@@ -370,13 +486,15 @@ class WCS_Related_Order_Store_Cached_CPT extends WCS_Related_Order_Store_CPT imp
}
/**
- * Remove all caches for a given meta key if all entries for that meta key are being deleted.
+ * Removes all caches for a given meta key.
*
- * @param string $post_meta_key The post meta key being changed.
+ * Used by caching clearing tools if all entries for that meta key are being deleted.
+ *
+ * @param string $meta_key The meta key to delete.
*/
- public function maybe_delete_all_for_post_meta_change( $post_meta_key ) {
+ public function maybe_delete_all_for_post_meta_change( $meta_key ) {
- $relation_type = $this->get_relation_type_for_meta_key( $post_meta_key );
+ $relation_type = $this->get_relation_type_for_meta_key( $meta_key );
if ( $relation_type ) {
$this->delete_caches_for_all_subscriptions( array( $relation_type ) );
@@ -384,17 +502,17 @@ class WCS_Related_Order_Store_Cached_CPT extends WCS_Related_Order_Store_CPT imp
}
/**
- * Get the IDs of subscriptions without related order cache set for a give relation type or types.
+ * Gets a list of IDs for subscriptions without a related order cache set for a give relation type or types.
*
* If more than one relation is specified, a batch of subscription IDs will be returned that are missing
* either of those relations, not both.
*
- * @param array $relation_types The relations to check, or an empty array to check for any relation type (default).
- * @param int $batch_size The number of subscriptions to return. Use -1 to return all subscriptions.
- * @return array
+ * @param array $relation_types Optional. The relations to check. Default is an empty array which checks for any relation type.
+ * @param int $batch_size Optional. The number of subscriptions to return. Use -1 to return all subscriptions. Default is 10.
+ *
+ * @return array An array of subscription IDs missing the given relation type(s)
*/
protected function get_subscription_ids_without_cache( $relation_types = array(), $batch_size = 10 ) {
- global $wpdb;
if ( empty( $relation_types ) ) {
$relation_types = $this->get_relation_types();
@@ -403,25 +521,26 @@ class WCS_Related_Order_Store_Cached_CPT extends WCS_Related_Order_Store_CPT imp
$subscription_ids = array();
foreach ( $relation_types as $relation_type ) {
-
$limit = $batch_size - count( $subscription_ids );
+ $ids = wcs_get_orders_with_meta_query(
+ [
+ 'limit' => $limit,
+ 'fields' => 'ids',
+ 'orderby' => 'ID',
+ 'order' => 'ASC',
+ 'type' => 'shop_subscription',
+ 'status' => array_keys( wcs_get_subscription_statuses() ),
+ 'meta_query' => [ // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
+ [
+ 'key' => $this->get_cache_meta_key( $relation_type ),
+ 'compare' => 'NOT EXISTS',
+ ],
+ ],
+ ]
+ );
- // Use a subquery instead of a meta query with get_posts() as it's more performant than the multiple joins created by get_posts()
- $post_ids = $wpdb->get_col( $wpdb->prepare(
- "SELECT ID FROM $wpdb->posts
- WHERE post_type = 'shop_subscription'
- AND post_status NOT IN ('trash','auto-draft')
- AND ID NOT IN (
- SELECT post_id FROM $wpdb->postmeta
- WHERE meta_key = %s
- )
- LIMIT 0, %d",
- $this->get_cache_meta_key( $relation_type ),
- $limit
- ) );
-
- if ( $post_ids ) {
- $subscription_ids += $post_ids;
+ if ( $ids ) {
+ $subscription_ids += $ids;
if ( count( $subscription_ids ) >= $batch_size ) {
break;
@@ -433,9 +552,10 @@ class WCS_Related_Order_Store_Cached_CPT extends WCS_Related_Order_Store_CPT imp
}
/**
- * Get the order relation for a given post meta key.
+ * Gets the order relation for a given meta key.
+ *
+ * @param string $meta_key The meta key to get the subscription-relation for.
*
- * @param string $meta_key The post meta key being changed.
* @return bool|string The order relation if it exists, or false if no such meta key exists.
*/
private function get_relation_type_for_meta_key( $meta_key ) {
@@ -443,19 +563,18 @@ class WCS_Related_Order_Store_Cached_CPT extends WCS_Related_Order_Store_CPT imp
}
/**
- * Remove related order cache meta data from order meta copied from subscriptions to renewal orders.
+ * Removes related order cache meta data from order meta copied from subscriptions to renewal orders.
+ *
+ * @param array $meta An order's meta data.
*
- * @param array $meta An order's meta data.
* @return array Filtered order meta data to be copied.
*/
public function remove_related_order_cache_keys( $meta ) {
$cache_meta_keys = array_map( array( $this, 'get_cache_meta_key' ), $this->get_relation_types() );
- foreach ( $meta as $index => $meta_data ) {
- if ( ! empty( $meta_data['meta_key'] ) && in_array( $meta_data['meta_key'], $cache_meta_keys ) ) {
- unset( $meta[ $index ] );
- }
+ foreach ( $cache_meta_keys as $cache_meta_key ) {
+ unset( $meta[ $cache_meta_key ] );
}
return $meta;
@@ -464,21 +583,26 @@ class WCS_Related_Order_Store_Cached_CPT extends WCS_Related_Order_Store_CPT imp
/** Methods to implement WCS_Cache_Updater - wrap more accurately named methods for the sake of clarity */
/**
- * Get the items to be updated, if any.
+ * Gets the subscriptions without caches that need to be updated, if any.
*
- * @return array An array of items to update, or empty array if there are no items to update.
+ * This function is used in the background updater to determine which subscriptions have missing caches that need generating.
+ *
+ * @return array An array of subscriptions without any related order caches.
*/
public function get_items_to_update() {
return $this->get_subscription_ids_without_cache();
}
/**
- * Run the update for a single item.
+ * Generates a related order cache for a given subscription.
*
- * @param mixed $item The item to update.
+ * This function is used in the background updater to generate caches for subscriptions that are missing them.
+ *
+ * @param int $subscription_id The subscription to generate the cache for.
*/
public function update_items_cache( $subscription_id ) {
$subscription = wcs_get_subscription( $subscription_id );
+
if ( $subscription ) {
foreach ( $this->get_relation_types() as $relation_type ) {
// Getting the related IDs also sets the cache when it's not already set
@@ -488,9 +612,44 @@ class WCS_Related_Order_Store_Cached_CPT extends WCS_Related_Order_Store_CPT imp
}
/**
- * Clear all caches.
+ * Clears all caches for all subscriptions.
*/
public function delete_all_caches() {
$this->delete_caches_for_all_subscriptions();
}
+
+ /**
+ * Gets the subscription's related order cached stored in meta.
+ *
+ * @param WC_Subscription $subscription The subscription to get the cache meta for.
+ * @param string $relation_type The relation type to get the cache meta for.
+ * @param mixed $data_store The data store to use to get the meta. Defaults to the current subscription's data store.
+ *
+ * @return stdClass|bool The meta data object if it exists, or false if it doesn't.
+ */
+ protected function get_related_order_metadata( WC_Subscription $subscription, $relation_type, $data_store = null ) {
+ $cache_meta_key = $this->get_cache_meta_key( $relation_type );
+ $data_store = empty( $data_store ) ? WC_Data_Store::load( 'subscription' ) : $data_store;
+
+ /**
+ * Bypass the related order cache keys being ignored when fetching subscription meta.
+ *
+ * By default the related order cache keys are ignored via $this->add_related_order_cache_props(). In order to fetch the subscription's
+ * meta with those keys, we need to bypass that function.
+ *
+ * We use a static variable because it is possible to have multiple instances of this class in memory, and we want to make sure we bypass
+ * the function in all instances.
+ */
+ self::$override_ignored_props = true;
+ $subscription_meta = $data_store->read_meta( $subscription );
+ self::$override_ignored_props = false;
+
+ foreach ( $subscription_meta as $meta ) {
+ if ( isset( $meta->meta_key ) && $cache_meta_key === $meta->meta_key ) {
+ return $meta;
+ }
+ }
+
+ return false;
+ }
}
diff --git a/vendor/woocommerce/subscriptions-core/includes/data-stores/class-wcs-related-order-store-cpt.php b/vendor/woocommerce/subscriptions-core/includes/data-stores/class-wcs-related-order-store-cpt.php
index aaa8bff..242cdf6 100644
--- a/vendor/woocommerce/subscriptions-core/includes/data-stores/class-wcs-related-order-store-cpt.php
+++ b/vendor/woocommerce/subscriptions-core/includes/data-stores/class-wcs-related-order-store-cpt.php
@@ -4,33 +4,20 @@ if ( ! defined( 'ABSPATH' ) ) {
}
/**
- * Related order data store for orders stored in Custom Post Types.
+ * Related order data store for orders.
*
* Importantly, this class uses WC_Data API methods, like WC_Data::add_meta_data() and WC_Data::get_meta(), to manage the
* relationships instead of add_post_meta() or get_post_meta(). This ensures that the relationship is stored, regardless
- * of the order data store being used. However, it also creates potential for relationships to fall out of sync if a
- * custom order data store is active, because @see $this->get_related_order_ids() queries the posts table via wp_posts(),
- * not the order's data store. This is unavoidable as wc_get_orders() and WC_Order_Query do not provide any way to query
- * meta data abstracted from the data store. Instead, it relies on 3rd party code to add custom parameter support for meta.
- * Source: https://github.com/woocommerce/woocommerce/wiki/wc_get_orders-and-WC_Order_Query#adding-custom-parameter-support
+ * of the order data store being used.
*
- * Adding custom parameter support to order querying APIs won't help solve this issue, as the code would still directly
- * query post meta by default, and require additional code for different order data stores.
- *
- * The solution will be to eventually move away from the use of meta data on the order to a standalone relationship table.
- * This can be done already on sites running custom order data stores as WCS_Related_Order_Store::instance() is
- * filterable. It will eventually also be the default implementation in a future version of Subscriptions.
- *
- * @version 2.3.0
- * @category Class
- * @author Prospress
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.0
*/
class WCS_Related_Order_Store_CPT extends WCS_Related_Order_Store {
/**
* Meta keys used to link an order with a subscription for each type of relationship.
*
- * @since 2.3.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.0
* @var array $meta_keys Relationship => Meta key
*/
private $meta_keys;
@@ -47,144 +34,74 @@ class WCS_Related_Order_Store_CPT extends WCS_Related_Order_Store {
/**
* Find orders related to a given subscription in a given way.
*
- * This method uses the WordPress Posts API instead of the WooCommerce Order's API, because
- * order's can not be queried by meta data with either wc_get_orders() or WC_Order_Query, so
- * a custom query parameter would need to be added to WC_Order_Query to run that query, which
- * is not something we want to add public APIs for because in future, that relationship will
- * be moved out of order meta and into its own table and queries on it should come through
- * here instead of the order querying API.
- *
- * @param WC_Order $subscription The ID of the subscription for which calling code wants the related orders.
- * @param string $relation_type The relationship between the subscription and the orders. Must be 'renewal', 'switch' or 'resubscribe.
+ * @param WC_Order $subscription The ID of the subscription for which calling code wants the related orders.
+ * @param string $relation_type The relationship between the subscription and the orders. Must be 'renewal', 'switch' or 'resubscribe.
*
* @return array
*/
public function get_related_order_ids( WC_Order $subscription, $relation_type ) {
- $related_order_ids = get_posts( array(
- 'posts_per_page' => -1,
- 'post_type' => 'shop_order',
- 'post_status' => 'any',
- 'fields' => 'ids',
- 'meta_query' => array(
- array(
- 'key' => $this->get_meta_key( $relation_type ),
- 'compare' => '=',
- 'value' => wcs_get_objects_property( $subscription, 'id' ), // We can't rely on get_id() being available here, because we only require a WC_Order, not a WC_Subscription, and WC_Order does not have get_id() available with WC < 3.0
- 'type' => 'numeric',
- ),
- ),
- 'update_post_term_cache' => false,
- ) );
-
- rsort( $related_order_ids );
-
- return $related_order_ids;
+ return wcs_get_orders_with_meta_query(
+ [
+ 'limit' => -1,
+ 'type' => 'shop_order',
+ 'status' => 'any',
+ 'return' => 'ids',
+ 'orderby' => 'ID',
+ 'order' => 'DESC',
+ 'meta_query' => [ // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
+ [
+ 'key' => $this->get_meta_key( $relation_type ),
+ 'compare' => '=',
+ 'value' => $subscription->get_id(),
+ ],
+ ],
+ ]
+ );
}
/**
* Find subscriptions related to a given order in a given way, if any.
*
- * @param WC_Order $order The ID of an order that may be linked with subscriptions.
- * @param string $relation_type The relationship between the subscription and the orders. Must be 'renewal', 'switch' or 'resubscribe.
+ * @param WC_Order $order The ID of an order that may be linked with subscriptions.
+ * @param string $relation_type The relationship between the subscription and the orders. Must be 'renewal', 'switch' or 'resubscribe.
*
* @return array
*/
public function get_related_subscription_ids( WC_Order $order, $relation_type ) {
$related_order_meta_key = $this->get_meta_key( $relation_type );
- if ( wcs_is_woocommerce_pre( '3.0' ) ) {
- $related_subscription_ids = get_post_meta( wcs_get_objects_property( $order, 'id' ), $related_order_meta_key, false );
- } else {
- $related_subscription_ids = $order->get_meta( $related_order_meta_key, false );
- // Normalise the return value: WooCommerce returns a set of WC_Meta_Data objects, with values cast to strings, even if they're integers
- $related_subscription_ids = wp_list_pluck( $related_subscription_ids, 'value' );
- $related_subscription_ids = array_map( 'absint', $related_subscription_ids );
- $related_subscription_ids = array_values( $related_subscription_ids );
- }
- $related_subscription_ids = $this->apply_deprecated_related_order_filter( $related_subscription_ids, $order, $relation_type );
+ $related_subscription_ids = $order->get_meta( $related_order_meta_key, false );
+ // Normalise the return value: WooCommerce returns a set of WC_Meta_Data objects, with values cast to strings, even if they're integers
+ $related_subscription_ids = wp_list_pluck( $related_subscription_ids, 'value' );
+ $related_subscription_ids = array_map( 'absint', $related_subscription_ids );
+ $related_subscription_ids = array_values( $related_subscription_ids );
return apply_filters( 'wcs_orders_related_subscription_ids', $related_subscription_ids, $order, $relation_type );
}
- /**
- * Apply the deprecated 'wcs_subscriptions_for_renewal_order' and 'wcs_subscriptions_for_resubscribe_order' filters
- * to maintain backward compatibility.
- *
- * @param array $subscription_ids The IDs of subscription linked to the given order, if any.
- * @param WC_Order $order An instance of an order that may be linked with subscriptions.
- * @param string $relation_type The relationship between the subscription and the orders. Must be 'renewal', 'switch' or 'resubscribe'.
- *
- * @return array
- */
- protected function apply_deprecated_related_order_filter( $subscription_ids, WC_Order $order, $relation_type ) {
-
- $deprecated_filter_hook = "wcs_subscriptions_for_{$relation_type}_order";
-
- if ( has_filter( $deprecated_filter_hook ) ) {
- wcs_deprecated_function( sprintf( '"%s" hook should no longer be used and', esc_html( $deprecated_filter_hook ) ), '2.3.2', '"wcs_orders_related_subscription_ids" with a check on the 3rd param, to take advantage of the new persistent caching layer for related subscription IDs' );
-
- $subscriptions = array();
-
- foreach ( $subscription_ids as $subscription_id ) {
- if ( wcs_is_subscription( $subscription_id ) ) {
- $subscriptions[ $subscription_id ] = wcs_get_subscription( $subscription_id );
- }
- }
-
- $filtered_subscriptions = apply_filters( $deprecated_filter_hook, $subscriptions, $order );
-
- // Although this array was previously ordered by ID => instance, that key requirement wasn't enforced so it's possible 3rd party code was not using the ID as the key, and instead, numerical indexes are being used, so its safest not to rely on IDs as keys
- if ( $filtered_subscriptions != $subscriptions ) {
-
- $subscription_ids = array();
-
- foreach ( $filtered_subscriptions as $subscription ) {
- $subscription_ids[] = $subscription->get_id();
- }
- }
- }
-
- return $subscription_ids;
- }
-
/**
* Helper function for linking an order to a subscription via a given relationship.
*
* Existing order relationships of the same type will not be overwritten. This only adds a relationship. To overwrite,
* you must also remove any existing relationship with @see $this->delete_relation().
*
- * This data store links the relationship for a renewal order and a subscription in meta data against the order.
- * That's inefficient for queries, so will be changed in future with a different data store. It also leads to potential
- * bugs when WooCommerce 3.0 or newer is running with a custom data store for order data, as related orders are queried
- * in $this->get_related_order_ids() using post meta directly, but set here using the CRUD WC_Data::add_meta_data() method.
- * This is unfortunately unavoidable. See the WCS_Related_Order_Store_CPT docblock for more details.
- *
- * @param WC_Order $order The order to link with the subscription.
- * @param WC_Order $subscription The order or subscription to link the order to.
- * @param string $relation_type The relationship between the subscription and the order. Must be 'renewal', 'switch' or 'resubscribe' unless custom relationships are implemented.
+ * @param WC_Order $order The order to link with the subscription.
+ * @param WC_Order $subscription The order or subscription to link the order to.
+ * @param string $relation_type The relationship between the subscription and the order. Must be 'renewal', 'switch' or 'resubscribe' unless custom relationships are implemented.
*/
public function add_relation( WC_Order $order, WC_Order $subscription, $relation_type ) {
-
// We can't rely on $subscription->get_id() being available here, because we only require a WC_Order, not a WC_Subscription, and WC_Order does not have get_id() available with WC < 3.0
- $subscription_id = wcs_get_objects_property( $subscription, 'id' );
+ $subscription_id = $subscription->get_id();
$related_order_meta_key = $this->get_meta_key( $relation_type );
- if ( wcs_is_woocommerce_pre( '3.0' ) ) {
- $order_id = wcs_get_objects_property( $order, 'id' );
- $existing_related_ids = get_post_meta( $order_id, $related_order_meta_key, false );
+ // We want to allow more than one piece of meta per key on the order, but we don't want to duplicate the same meta key => value combination, so we need to check if it is set first
+ $existing_relations = $order->get_meta( $related_order_meta_key, false );
+ $existing_related_ids = wp_list_pluck( $existing_relations, 'value' );
+ $existing_related_ids = array_map( 'absint', $existing_related_ids );
- if ( empty( $existing_related_ids ) || ! in_array( $subscription_id, $existing_related_ids ) ) {
- add_post_meta( $order_id, $related_order_meta_key, $subscription_id, false );
- }
- } else {
- // We want to allow more than one piece of meta per key on the order, but we don't want to duplicate the same meta key => value combination, so we need to check if it is set first
- $existing_relations = $order->get_meta( $related_order_meta_key, false );
- $existing_related_ids = wp_list_pluck( $existing_relations, 'value' );
-
- if ( empty( $existing_relations ) || ! in_array( $subscription_id, $existing_related_ids ) ) {
- $order->add_meta_data( $related_order_meta_key, $subscription_id, false );
- $order->save_meta_data();
- }
+ if ( empty( $existing_relations ) || ! in_array( $subscription_id, $existing_related_ids, true ) ) {
+ $order->add_meta_data( $related_order_meta_key, $subscription_id, false );
+ $order->save();
}
}
@@ -192,42 +109,33 @@ class WCS_Related_Order_Store_CPT extends WCS_Related_Order_Store {
* Remove the relationship between a given order and subscription.
*
* This data store links the relationship for a renewal order and a subscription in meta data against the order.
- * That's inefficient for queries, so will be changed in future with a different data store. It also leads to bugs
- * with custom data stores for order data, as $this->get_related_order_ids() queries post meta directly. This is
- * unavoidable. See the WCS_Related_Order_Store_CPT docblock for more details.
*
- * @param WC_Order $order An order that may be linked with subscriptions.
- * @param WC_Order $subscription A subscription or order to unlink the order with, if a relation exists.
- * @param string $relation_type The relationship between the subscription and the order. Must be 'renewal', 'switch' or 'resubscribe' unless custom relationships are implemented.
+ * @param WC_Order $order An order that may be linked with subscriptions.
+ * @param WC_Order $subscription A subscription or order to unlink the order with, if a relation exists.
+ * @param string $relation_type The relationship between the subscription and the order. Must be 'renewal', 'switch' or 'resubscribe' unless custom relationships are implemented.
*/
public function delete_relation( WC_Order $order, WC_Order $subscription, $relation_type ) {
$related_order_meta_key = $this->get_meta_key( $relation_type );
- if ( wcs_is_woocommerce_pre( '3.0' ) ) {
- delete_post_meta( wcs_get_objects_property( $order, 'id' ), $related_order_meta_key, wcs_get_objects_property( $subscription, 'id' ) );
- } else {
- foreach ( $order->get_meta_data() as $meta ) {
- if ( $meta->key == $related_order_meta_key && $meta->value == wcs_get_objects_property( $subscription, 'id' ) ) { // we can't do strict comparison here, because WC_Meta_Data casts the subscription ID to be a string
- $order->delete_meta_data_by_mid( $meta->id );
- }
+
+ foreach ( $order->get_meta_data() as $meta ) {
+ if ( $related_order_meta_key === $meta->key && $subscription->get_id() === (int) $meta->value ) {
+ $order->delete_meta_data_by_mid( $meta->id );
}
- $order->save_meta_data();
}
+
+ $order->save();
}
/**
* Remove all related orders/subscriptions of a given type from an order.
*
- * @param WC_Order $order An order that may be linked with subscriptions.
- * @param string $relation_type The relationship between the subscription and the order. Must be 'renewal', 'switch' or 'resubscribe' unless custom relationships are implemented.
+ * @param WC_Order $order An order that may be linked with subscriptions.
+ * @param string $relation_type The relationship between the subscription and the order. Must be 'renewal', 'switch' or 'resubscribe' unless custom relationships are implemented.
*/
public function delete_relations( WC_Order $order, $relation_type ) {
$related_order_meta_key = $this->get_meta_key( $relation_type );
- if ( wcs_is_woocommerce_pre( '3.0' ) ) {
- delete_post_meta( wcs_get_objects_property( $order, 'id' ), $related_order_meta_key, null );
- } else {
- $order->delete_meta_data( $related_order_meta_key );
- $order->save_meta_data();
- }
+ $order->delete_meta_data( $related_order_meta_key );
+ $order->save();
}
/**
@@ -242,8 +150,9 @@ class WCS_Related_Order_Store_CPT extends WCS_Related_Order_Store {
/**
* Get the meta key used to link an order with a subscription based on the type of relationship.
*
- * @param string $relation_type The order's relationship with the subscription. Must be 'renewal', 'switch' or 'resubscribe'.
+ * @param string $relation_type The order's relationship with the subscription. Must be 'renewal', 'switch' or 'resubscribe'.
* @param string $prefix_meta_key Whether to add the underscore prefix to the meta key or not. 'prefix' to prefix the key. 'do_not_prefix' to not prefix the key.
+ *
* @return string
*/
protected function get_meta_key( $relation_type, $prefix_meta_key = 'prefix' ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/data-stores/class-wcs-subscription-data-store-cpt.php b/vendor/woocommerce/subscriptions-core/includes/data-stores/class-wcs-subscription-data-store-cpt.php
index 48b6109..d29658b 100644
--- a/vendor/woocommerce/subscriptions-core/includes/data-stores/class-wcs-subscription-data-store-cpt.php
+++ b/vendor/woocommerce/subscriptions-core/includes/data-stores/class-wcs-subscription-data-store-cpt.php
@@ -4,11 +4,11 @@ if ( ! defined( 'ABSPATH' ) ) {
}
/**
- * Subscription Data Store: Stored in CPT.
+ * Subscription Data Store: Stored in CPT (posts table).
*
* Extends WC_Order_Data_Store_CPT to make sure subscription related meta data is read/updated.
*
- * @version 2.2.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @category Class
* @author Prospress
*/
@@ -21,7 +21,7 @@ class WCS_Subscription_Data_Store_CPT extends WC_Order_Data_Store_CPT implements
* the $internal_meta_keys property from WC_Order_Data_Store_CPT because we want its value
* too, so instead we create our own and merge it into $internal_meta_keys in __construct.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @var array
*/
protected $subscription_internal_meta_keys = array(
@@ -39,7 +39,7 @@ class WCS_Subscription_Data_Store_CPT extends WC_Order_Data_Store_CPT implements
*
* Used to read/update props on the subscription.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @var array
*/
protected $subscription_meta_keys_to_props = array(
@@ -91,10 +91,27 @@ class WCS_Subscription_Data_Store_CPT extends WC_Order_Data_Store_CPT implements
* Create a new subscription in the database.
*
* @param WC_Subscription $subscription
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
public function create( &$subscription ) {
+
+ $subscription_status = $subscription->get_status( 'edit' );
+
+ if ( ! $subscription_status ) {
+ $subscription->set_status( 'wc' . apply_filters( 'woocommerce_default_subscription_status', 'pending' ) );
+ }
+
+ /**
+ * This function is called on the `woocommerce_new_order_data` filter.
+ * We hook into this function, calling our own filter `woocommerce_new_subscription_data` to allow overriding the default subscription data.
+ */
+ $new_subscription_data = function ( $args ) {
+ return apply_filters( 'woocommerce_new_subscription_data', $args );
+ };
+ add_filter( 'woocommerce_new_order_data', $new_subscription_data );
parent::create( $subscription );
+ remove_filter( 'woocommerce_new_order_data', $new_subscription_data );
+
do_action( 'woocommerce_new_subscription', $subscription->get_id() );
}
@@ -103,7 +120,7 @@ class WCS_Subscription_Data_Store_CPT extends WC_Order_Data_Store_CPT implements
*
* Ignore meta data that we don't want accessible on the object via meta APIs.
*
- * @since 2.3.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.0
* @param WC_Data $object
* @return array
*/
@@ -126,7 +143,7 @@ class WCS_Subscription_Data_Store_CPT extends WC_Order_Data_Store_CPT implements
*
* @param WC_Subscription $subscription
* @param object $post_object
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
protected function read_order_data( &$subscription, $post_object ) {
@@ -178,7 +195,7 @@ class WCS_Subscription_Data_Store_CPT extends WC_Order_Data_Store_CPT implements
* Update subscription in the database.
*
* @param WC_Subscription $subscription
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
public function update( &$subscription ) {
@@ -186,16 +203,16 @@ class WCS_Subscription_Data_Store_CPT extends WC_Order_Data_Store_CPT implements
Abstract_WC_Order_Data_Store_CPT::update( $subscription );
// We used to call parent::update() above, which triggered this hook, so we trigger it manually here for backward compatibilty (and to improve compatibility with 3rd party code which may run validation or additional operations on it which should also be applied to a subscription)
- do_action( 'woocommerce_update_order', $subscription->get_id() );
+ do_action( 'woocommerce_update_order', $subscription->get_id(), $subscription );
- do_action( 'woocommerce_update_subscription', $subscription->get_id() );
+ do_action( 'woocommerce_update_subscription', $subscription->get_id(), $subscription );
}
/**
* Update post meta for a subscription based on it's settings in the WC_Subscription class.
*
* @param WC_Subscription $subscription
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
protected function update_post_meta( &$subscription ) {
@@ -218,12 +235,32 @@ class WCS_Subscription_Data_Store_CPT extends WC_Order_Data_Store_CPT implements
parent::update_post_meta( $subscription );
}
+ /**
+ * Get the subscription's post title
+ */
+ protected function get_post_title() {
+ // @codingStandardsIgnoreStart
+ /* translators: %s: Order date */
+ return sprintf( __( 'Subscription – %s', 'woocommerce-subscriptions' ), ( new DateTime( 'now' ) )->format( _x( 'M d, Y @ h:i A', 'Order date parsed by DateTime::format', 'woocommerce-subscriptions' ) ) );
+ // @codingStandardsIgnoreEnd
+ }
+
+ /**
+ * Excerpt for post.
+ *
+ * @param \WC_Subscription $order Subscription object.
+ * @return string
+ */
+ protected function get_post_excerpt( $order ) {
+ return $order->get_customer_note();
+ }
+
/**
* Get amount refunded for all related orders.
*
* @param WC_Subscription $subscription
* @return string
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
public function get_total_refunded( $subscription ) {
@@ -241,7 +278,7 @@ class WCS_Subscription_Data_Store_CPT extends WC_Order_Data_Store_CPT implements
*
* @param WC_Subscription $subscription
* @return float
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
public function get_total_tax_refunded( $subscription ) {
@@ -259,7 +296,7 @@ class WCS_Subscription_Data_Store_CPT extends WC_Order_Data_Store_CPT implements
*
* @param WC_Subscription $subscription
* @return float
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
public function get_total_shipping_refunded( $subscription ) {
@@ -277,7 +314,7 @@ class WCS_Subscription_Data_Store_CPT extends WC_Order_Data_Store_CPT implements
*
* @param string $type
* @return int
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
public function get_order_count( $status ) {
global $wpdb;
@@ -290,7 +327,7 @@ class WCS_Subscription_Data_Store_CPT extends WC_Order_Data_Store_CPT implements
* @see wc_get_orders()
* @param array $args
* @return array of orders
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
public function get_orders( $args = array() ) {
@@ -335,19 +372,14 @@ class WCS_Subscription_Data_Store_CPT extends WC_Order_Data_Store_CPT implements
*
* @param WC_Subscription $subscription
* @return array The date properties saved to the database in the format: array( $prop_name => DateTime Object )
- * @since 2.2.6
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.6
*/
public function save_dates( $subscription ) {
- $saved_dates = array();
+ $dates_to_save = [];
$changes = $subscription->get_changes();
- $date_meta_keys = array(
- '_schedule_trial_end',
- '_schedule_next_payment',
- '_schedule_cancelled',
- '_schedule_end',
- '_schedule_payment_retry',
- '_schedule_start',
- );
+ $date_meta_keys = [
+ '_schedule_payment_retry' => 'schedule_payment_retry', // This is the only date potentially missing from wcs_get_subscription_date_types().
+ ];
// Add any custom date types to the date meta keys we need to save.
foreach ( wcs_get_subscription_date_types() as $date_type => $date_name ) {
@@ -355,43 +387,77 @@ class WCS_Subscription_Data_Store_CPT extends WC_Order_Data_Store_CPT implements
continue;
}
- $date_meta_key = wcs_get_date_meta_key( $date_type );
-
- if ( ! in_array( $date_meta_key, $date_meta_keys ) ) {
- $date_meta_keys[] = $date_meta_key;
- }
+ $date_meta_keys[ wcs_get_date_meta_key( $date_type ) ] = wcs_maybe_prefix_key( $date_type, 'schedule_' );
}
- $date_meta_keys_to_props = array_intersect_key( $this->subscription_meta_keys_to_props, array_flip( $date_meta_keys ) );
+ // Get the date meta keys we need to save.
+ $date_meta_keys_to_props = array_intersect_key( $this->subscription_meta_keys_to_props, $date_meta_keys );
- // Save the changes to scheduled dates
- foreach ( $this->get_props_to_update( $subscription, $date_meta_keys_to_props ) as $meta_key => $prop ) {
- update_post_meta( $subscription->get_id(), $meta_key, $subscription->get_date( $prop ) );
- $saved_dates[ $prop ] = wcs_get_datetime_from( $subscription->get_time( $prop ) );
+ // Save the changes to scheduled dates.
+ foreach ( $this->get_props_to_update( $subscription, $date_meta_keys_to_props ) as $prop ) {
+ $dates_to_save[] = $prop;
}
- $post_data = array();
-
- // Save any changes to the created date
+ // Save any changes to the created date.
if ( isset( $changes['date_created'] ) ) {
- $post_data['post_date'] = gmdate( 'Y-m-d H:i:s', $subscription->get_date_created( 'edit' )->getOffsetTimestamp() );
- $post_data['post_date_gmt'] = gmdate( 'Y-m-d H:i:s', $subscription->get_date_created( 'edit' )->getTimestamp() );
- $saved_dates['date_created'] = $subscription->get_date_created();
+ $dates_to_save[] = 'date_created';
}
- // Save any changes to the modified date
+ // Save any changes to the modified date.
if ( isset( $changes['date_modified'] ) ) {
+ $dates_to_save[] = 'date_modified';
+ }
+
+ return $this->write_dates_to_database( $subscription, $dates_to_save );
+ }
+
+ /**
+ * Writes subscription dates to the database.
+ *
+ * @param WC_Subscription $subscription The subscription to write date changes for.
+ * @param array $dates_to_save The dates to write to the database.
+ *
+ * @return WC_DateTime[] The date properties saved to the database in the format: array( $prop_name => WC_DateTime Object )
+ */
+ public function write_dates_to_database( $subscription, $dates_to_save ) {
+ // Flip the dates for easier access and removal.
+ $dates_to_save = array_flip( $dates_to_save );
+ $dates_saved = [];
+ $post_data = [];
+
+ if ( isset( $dates_to_save['date_created'] ) ) {
+ $post_data['post_date'] = gmdate( 'Y-m-d H:i:s', $subscription->get_date_created( 'edit' )->getOffsetTimestamp() );
+ $post_data['post_date_gmt'] = gmdate( 'Y-m-d H:i:s', $subscription->get_date_created( 'edit' )->getTimestamp() );
+
+ // Mark the created date as saved.
+ $dates_saved['date_created'] = $subscription->get_date_created();
+ unset( $dates_to_save['date_created'] );
+ }
+
+ if ( isset( $dates_to_save['date_modified'] ) ) {
$post_data['post_modified'] = gmdate( 'Y-m-d H:i:s', $subscription->get_date_modified( 'edit' )->getOffsetTimestamp() );
$post_data['post_modified_gmt'] = gmdate( 'Y-m-d H:i:s', $subscription->get_date_modified( 'edit' )->getTimestamp() );
- $saved_dates['date_modified'] = $subscription->get_date_modified();
+
+ // Mark the modified date as saved.
+ $dates_saved['date_modified'] = $subscription->get_date_modified();
+ unset( $dates_to_save['date_modified'] );
}
+ // Write the dates stored on in post data.
if ( ! empty( $post_data ) ) {
$post_data['ID'] = $subscription->get_id();
wp_update_post( $post_data );
}
- return $saved_dates;
+ // Write the remaining dates to meta.
+ foreach ( $dates_to_save as $date_prop => $index ) {
+ $date_type = wcs_normalise_date_type_key( $date_prop );
+
+ update_post_meta( $subscription->get_id(), wcs_get_date_meta_key( $date_type ), $subscription->get_date( $date_type ) );
+ $dates_saved[ $date_prop ] = wcs_get_datetime_from( $subscription->get_time( $date_type ) );
+ }
+
+ return $dates_saved;
}
/**
@@ -441,7 +507,7 @@ class WCS_Subscription_Data_Store_CPT extends WC_Order_Data_Store_CPT implements
*
* @param string $term Term to search
* @return array of subscription ids
- * @since 2.3.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.0
*/
public function search_subscriptions( $term ) {
global $wpdb;
@@ -500,7 +566,7 @@ class WCS_Subscription_Data_Store_CPT extends WC_Order_Data_Store_CPT implements
/**
* Get the user IDs for customers who have a subscription.
*
- * @since 3.4.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.4.3
* @return array The user IDs.
*/
public function get_subscription_customer_ids() {
@@ -512,4 +578,26 @@ class WCS_Subscription_Data_Store_CPT extends WC_Order_Data_Store_CPT implements
WHERE subscription_meta.meta_key = '_customer_user' AND posts.post_type = 'shop_subscription'"
);
}
+
+ /**
+ * Deletes all rows in the postmeta table with the given meta key.
+ *
+ * @param string $meta_key The meta key to delete.
+ */
+ public function delete_all_metadata_by_key( $meta_key ) {
+ // Set variables to define ambiguous parameters of delete_metadata()
+ $id = null; // All IDs.
+ $meta_value = null; // Delete any values.
+ $delete_all = true;
+ delete_metadata( 'post', $id, $meta_key, $meta_value, $delete_all );
+ }
+
+ /**
+ * Count subscriptions by status.
+ *
+ * @return array
+ */
+ public function get_subscriptions_count_by_status() {
+ return (array) wp_count_posts( 'shop_subscription' );
+ }
}
diff --git a/vendor/woocommerce/subscriptions-core/includes/deprecated/class-wcs-action-deprecator.php b/vendor/woocommerce/subscriptions-core/includes/deprecated/class-wcs-action-deprecator.php
index 334e037..f8504f6 100644
--- a/vendor/woocommerce/subscriptions-core/includes/deprecated/class-wcs-action-deprecator.php
+++ b/vendor/woocommerce/subscriptions-core/includes/deprecated/class-wcs-action-deprecator.php
@@ -10,7 +10,7 @@
* @subpackage WCS_Hook_Deprecator
* @category Class
* @author Prospress
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
class WCS_Action_Deprecator extends WCS_Hook_Deprecator {
@@ -41,7 +41,7 @@ class WCS_Action_Deprecator extends WCS_Hook_Deprecator {
/**
* Bootstraps the class and hooks required actions & filters.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function __construct() {
parent::__construct();
@@ -50,7 +50,7 @@ class WCS_Action_Deprecator extends WCS_Hook_Deprecator {
/**
* Trigger the old action with the original callback parameters
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
protected function trigger_hook( $old_hook, $new_callback_args ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/deprecated/class-wcs-deprecated-filter-hooks.php b/vendor/woocommerce/subscriptions-core/includes/deprecated/class-wcs-deprecated-filter-hooks.php
index 211ad2d..6eafcb2 100644
--- a/vendor/woocommerce/subscriptions-core/includes/deprecated/class-wcs-deprecated-filter-hooks.php
+++ b/vendor/woocommerce/subscriptions-core/includes/deprecated/class-wcs-deprecated-filter-hooks.php
@@ -9,7 +9,7 @@
* @package WooCommerce Subscriptions
* @category Class
* @author Prospress
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
@@ -18,7 +18,7 @@ if ( ! defined( 'ABSPATH' ) ) {
/**
* Handles deprecation notices and triggering of legacy filter hooks when WC 3.0+ subscription filters are triggered.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
class WCS_Deprecated_Filter_Hooks extends WC_Deprecated_Filter_Hooks {
@@ -46,7 +46,7 @@ class WCS_Deprecated_Filter_Hooks extends WC_Deprecated_Filter_Hooks {
*
* @param string $old_hook
* @param string $new_hook
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
protected function display_notice( $old_hook, $new_hook ) {
wcs_deprecated_function( sprintf( 'The "%s" hook uses out of date data structures and', esc_html( $old_hook ) ), '2.2.0', esc_html( $new_hook ) . ' to filter subscription properties' );
diff --git a/vendor/woocommerce/subscriptions-core/includes/deprecated/class-wcs-dynamic-action-deprecator.php b/vendor/woocommerce/subscriptions-core/includes/deprecated/class-wcs-dynamic-action-deprecator.php
index 2764cdf..e7e47e1 100644
--- a/vendor/woocommerce/subscriptions-core/includes/deprecated/class-wcs-dynamic-action-deprecator.php
+++ b/vendor/woocommerce/subscriptions-core/includes/deprecated/class-wcs-dynamic-action-deprecator.php
@@ -6,7 +6,7 @@
* @subpackage WCS_Hook_Deprecator
* @category Class
* @author Prospress
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
class WCS_Dynamic_Action_Deprecator extends WCS_Dynamic_Hook_Deprecator {
@@ -38,7 +38,7 @@ class WCS_Dynamic_Action_Deprecator extends WCS_Dynamic_Hook_Deprecator {
* We need to use the special 'all' hook here because we don't actually know the full hook names
* in advance, just their prefix.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function __construct() {
parent::__construct();
@@ -47,7 +47,7 @@ class WCS_Dynamic_Action_Deprecator extends WCS_Dynamic_Hook_Deprecator {
/**
* Display a notice if functions are hooked to the old filter and apply the old filters args
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
protected function trigger_hook( $old_hook, $new_callback_args ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/deprecated/class-wcs-dynamic-filter-deprecator.php b/vendor/woocommerce/subscriptions-core/includes/deprecated/class-wcs-dynamic-filter-deprecator.php
index cb6e1ff..6b353c0 100644
--- a/vendor/woocommerce/subscriptions-core/includes/deprecated/class-wcs-dynamic-filter-deprecator.php
+++ b/vendor/woocommerce/subscriptions-core/includes/deprecated/class-wcs-dynamic-filter-deprecator.php
@@ -6,7 +6,7 @@
* @subpackage WCS_Hook_Deprecator
* @category Class
* @author Prospress
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
class WCS_Dynamic_Filter_Deprecator extends WCS_Dynamic_Hook_Deprecator {
@@ -22,7 +22,7 @@ class WCS_Dynamic_Filter_Deprecator extends WCS_Dynamic_Hook_Deprecator {
* We need to use the special 'all' hook here because we don't actually know the full hook names
* in advance, just their prefix.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function __construct() {
parent::__construct();
@@ -31,7 +31,7 @@ class WCS_Dynamic_Filter_Deprecator extends WCS_Dynamic_Hook_Deprecator {
/**
* Display a notice if functions are hooked to the old filter and apply the old filters args
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
protected function trigger_hook( $old_hook, $new_callback_args ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/deprecated/class-wcs-filter-deprecator.php b/vendor/woocommerce/subscriptions-core/includes/deprecated/class-wcs-filter-deprecator.php
index 9cd5b33..64c9d31 100644
--- a/vendor/woocommerce/subscriptions-core/includes/deprecated/class-wcs-filter-deprecator.php
+++ b/vendor/woocommerce/subscriptions-core/includes/deprecated/class-wcs-filter-deprecator.php
@@ -11,7 +11,7 @@
* @subpackage WCS_Hook_Deprecator
* @category Class
* @author Prospress
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
class WCS_Filter_Deprecator extends WCS_Hook_Deprecator {
@@ -69,7 +69,7 @@ class WCS_Filter_Deprecator extends WCS_Hook_Deprecator {
/**
* Bootstraps the class and hooks required actions & filters.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function __construct() {
parent::__construct();
@@ -78,7 +78,7 @@ class WCS_Filter_Deprecator extends WCS_Hook_Deprecator {
/**
* Trigger the old filter with the original callback parameters and make sure the return value is passed on (when possible).
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
protected function trigger_hook( $old_hook, $new_callback_args ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/deprecated/deprecation-handlers/class-wc-subscriptions-deprecation-handler.php b/vendor/woocommerce/subscriptions-core/includes/deprecated/deprecation-handlers/class-wc-subscriptions-deprecation-handler.php
index f63f8a6..ef0c3a4 100644
--- a/vendor/woocommerce/subscriptions-core/includes/deprecated/deprecation-handlers/class-wc-subscriptions-deprecation-handler.php
+++ b/vendor/woocommerce/subscriptions-core/includes/deprecated/deprecation-handlers/class-wc-subscriptions-deprecation-handler.php
@@ -5,7 +5,7 @@
* @package WooCommerce Subscriptions
* @category Class
* @author WooCommerce
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*/
defined( 'ABSPATH' ) || exit;
@@ -229,7 +229,7 @@ class WC_Subscriptions_Deprecation_Handler extends WCS_Deprecated_Functions_Hand
* @deprecated
*/
protected function _get_subscription_status_counts() {
- $results = wp_count_posts( 'shop_subscription' );
+ $results = WC_Data_Store::load( 'subscription' )->get_subscriptions_count_by_status();
$counts = array();
foreach ( $results as $status => $count ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-cancelled-subscription.php b/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-cancelled-subscription.php
index fb81c5a..e54f772 100644
--- a/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-cancelled-subscription.php
+++ b/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-cancelled-subscription.php
@@ -8,7 +8,7 @@ if ( ! defined( 'ABSPATH' ) ) {
* An email sent to the admin when a subscription is cancelled (either by a store manager, or the customer).
*
* @class WCS_Email_Cancelled_Subscription
- * @version 2.1
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.1
* @package WooCommerce_Subscriptions/Classes/Emails
* @author Prospress
* @extends WC_Email
@@ -48,7 +48,7 @@ class WCS_Email_Cancelled_Subscription extends WC_Email {
/**
* Get the default e-mail subject.
*
- * @since 2.5.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.3
* @return string
*/
public function get_default_subject() {
@@ -58,7 +58,7 @@ class WCS_Email_Cancelled_Subscription extends WC_Email {
/**
* Get the default e-mail heading.
*
- * @since 2.5.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.3
* @return string
*/
public function get_default_heading() {
diff --git a/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-completed-renewal-order.php b/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-completed-renewal-order.php
index df93abf..75ef069 100644
--- a/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-completed-renewal-order.php
+++ b/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-completed-renewal-order.php
@@ -8,7 +8,7 @@ if ( ! defined( 'ABSPATH' ) ) {
* Order complete emails are sent to the customer when the order is marked complete and usual indicates that the order has been shipped.
*
* @class WC_Email_Customer_Completed_Order
- * @version 2.0.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.0
* @package WooCommerce/Classes/Emails
* @author Prospress
* @extends WC_Email
@@ -49,7 +49,7 @@ class WCS_Email_Completed_Renewal_Order extends WC_Email_Customer_Completed_Orde
/**
* Get the default e-mail subject.
*
- * @since 2.5.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.3
* @return string
*/
public function get_default_subject() {
@@ -59,7 +59,7 @@ class WCS_Email_Completed_Renewal_Order extends WC_Email_Customer_Completed_Orde
/**
* Get the default e-mail heading.
*
- * @since 2.5.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.3
* @return string
*/
public function get_default_heading() {
diff --git a/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-completed-switch-order.php b/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-completed-switch-order.php
index b87d7c6..6ed4867 100644
--- a/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-completed-switch-order.php
+++ b/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-completed-switch-order.php
@@ -9,7 +9,7 @@ if ( ! defined( 'ABSPATH' ) ) {
* Order switch email sent to customer when a subscription is switched successfully.
*
* @class WCS_Email_Completed_Switch_Order
- * @version 2.0.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.0
* @package WooCommerce/Classes/Emails
* @author Prospress
* @extends WC_Email
@@ -48,7 +48,7 @@ class WCS_Email_Completed_Switch_Order extends WC_Email_Customer_Completed_Order
/**
* Get the default e-mail subject.
*
- * @since 2.5.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.3
* @return string
*/
public function get_default_subject() {
@@ -58,7 +58,7 @@ class WCS_Email_Completed_Switch_Order extends WC_Email_Customer_Completed_Order
/**
* Get the default e-mail heading.
*
- * @since 2.5.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.3
* @return string
*/
public function get_default_heading() {
diff --git a/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-customer-on-hold-renewal-order.php b/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-customer-on-hold-renewal-order.php
index 8a77576..b1a6e1a 100644
--- a/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-customer-on-hold-renewal-order.php
+++ b/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-customer-on-hold-renewal-order.php
@@ -7,7 +7,7 @@ defined( 'ABSPATH' ) || exit; // Exit if accessed directly.
* Order On Hold emails are sent to the customer when the renewal order is marked on-hold and usually indicates that the order is awaiting payment confirmation.
*
* @class WCS_Email_On-hold_Renewal_Order
- * @version 3.0.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v3.0.0
* @package WooCommerce_Subscriptions/Includes/Emails
* @author WooCommerce.
* @extends WC_Email_Customer_On_Hold_Order
@@ -44,7 +44,7 @@ class WCS_Email_Customer_On_Hold_Renewal_Order extends WC_Email_Customer_On_Hold
/**
* Get the default e-mail subject.
*
- * @since 3.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.0.0
* @return string
*/
public function get_default_subject() {
@@ -54,7 +54,7 @@ class WCS_Email_Customer_On_Hold_Renewal_Order extends WC_Email_Customer_On_Hold
/**
* Get the default e-mail heading.
*
- * @since 3.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.0.0
* @return string
*/
public function get_default_heading() {
diff --git a/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-customer-renewal-invoice.php b/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-customer-renewal-invoice.php
index 40ec9af..8bf7ac1 100644
--- a/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-customer-renewal-invoice.php
+++ b/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-customer-renewal-invoice.php
@@ -8,7 +8,7 @@ if ( ! defined( 'ABSPATH' ) ) {
* An email sent to the customer via admin.
*
* @class WCS_Email_Customer_Renewal_Invoice
- * @version 1.4
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v1.4
* @package WooCommerce_Subscriptions/Includes/Emails
* @author Prospress
* @extends WC_Email_Customer_Invoice
@@ -60,7 +60,7 @@ class WCS_Email_Customer_Renewal_Invoice extends WC_Email_Customer_Invoice {
* Get the default e-mail subject.
*
* @param bool $paid Whether the order has been paid or not.
- * @since 2.5.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.3
* @return string
*/
public function get_default_subject( $paid = false ) {
@@ -71,7 +71,7 @@ class WCS_Email_Customer_Renewal_Invoice extends WC_Email_Customer_Invoice {
* Get the default e-mail heading.
*
* @param bool $paid Whether the order has been paid or not.
- * @since 2.5.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.3
* @return string
*/
public function get_default_heading( $paid = false ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-expired-subscription.php b/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-expired-subscription.php
index e16e218..8a6f2a9 100644
--- a/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-expired-subscription.php
+++ b/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-expired-subscription.php
@@ -8,7 +8,7 @@ if ( ! defined( 'ABSPATH' ) ) {
* An email sent to the admin when a subscription is expired.
*
* @class WCS_Email_Expired_Subscription
- * @version 2.1
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.1
* @package WooCommerce_Subscriptions/Classes/Emails
* @author Prospress
* @extends WC_Email
@@ -48,7 +48,7 @@ class WCS_Email_Expired_Subscription extends WC_Email {
/**
* Get the default e-mail subject.
*
- * @since 2.5.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.3
* @return string
*/
public function get_default_subject() {
@@ -58,7 +58,7 @@ class WCS_Email_Expired_Subscription extends WC_Email {
/**
* Get the default e-mail heading.
*
- * @since 2.5.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.3
* @return string
*/
public function get_default_heading() {
diff --git a/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-new-renewal-order.php b/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-new-renewal-order.php
index f4ea8cc..7c68f71 100644
--- a/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-new-renewal-order.php
+++ b/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-new-renewal-order.php
@@ -8,7 +8,7 @@ if ( ! defined( 'ABSPATH' ) ) {
* An email sent to the admin when a new order is received/paid for.
*
* @class WCS_Email_New_Renewal_Order
- * @version 1.4
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v1.4
* @extends WC_Email_New_Order
*/
class WCS_Email_New_Renewal_Order extends WC_Email_New_Order {
@@ -54,7 +54,7 @@ class WCS_Email_New_Renewal_Order extends WC_Email_New_Order {
/**
* Get the default e-mail subject.
*
- * @since 2.5.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.3
* @return string
*/
public function get_default_subject() {
@@ -64,7 +64,7 @@ class WCS_Email_New_Renewal_Order extends WC_Email_New_Order {
/**
* Get the default e-mail heading.
*
- * @since 2.5.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.3
* @return string
*/
public function get_default_heading() {
diff --git a/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-new-switch-order.php b/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-new-switch-order.php
index 0a49e5e..0572187 100644
--- a/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-new-switch-order.php
+++ b/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-new-switch-order.php
@@ -8,7 +8,7 @@ if ( ! defined( 'ABSPATH' ) ) {
* An email sent to the admin when a customer switches their subscription.
*
* @class WCS_Email_New_Switch_Order
- * @version 1.5
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v1.5
* @extends WC_Email_New_Order
*/
class WCS_Email_New_Switch_Order extends WC_Email_New_Order {
@@ -46,7 +46,7 @@ class WCS_Email_New_Switch_Order extends WC_Email_New_Order {
/**
* Get the default e-mail subject.
*
- * @since 2.5.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.3
* @return string
*/
public function get_default_subject() {
@@ -56,7 +56,7 @@ class WCS_Email_New_Switch_Order extends WC_Email_New_Order {
/**
* Get the default e-mail heading.
*
- * @since 2.5.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.3
* @return string
*/
public function get_default_heading() {
diff --git a/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-on-hold-subscription.php b/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-on-hold-subscription.php
index ef4bd94..7e2006c 100644
--- a/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-on-hold-subscription.php
+++ b/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-on-hold-subscription.php
@@ -8,7 +8,7 @@ if ( ! defined( 'ABSPATH' ) ) {
* An email sent to the admin when a subscription is expired.
*
* @class WCS_Email_On_Hold_Subscription
- * @version 2.1
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.1
* @package WooCommerce_Subscriptions/Classes/Emails
* @author Prospress
* @extends WC_Email
@@ -48,7 +48,7 @@ class WCS_Email_On_Hold_Subscription extends WC_Email {
/**
* Get the default e-mail subject.
*
- * @since 2.5.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.3
* @return string
*/
public function get_default_subject() {
@@ -58,7 +58,7 @@ class WCS_Email_On_Hold_Subscription extends WC_Email {
/**
* Get the default e-mail heading.
*
- * @since 2.5.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.3
* @return string
*/
public function get_default_heading() {
diff --git a/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-processing-renewal-order.php b/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-processing-renewal-order.php
index 1caad89..ed774e4 100644
--- a/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-processing-renewal-order.php
+++ b/vendor/woocommerce/subscriptions-core/includes/emails/class-wcs-email-processing-renewal-order.php
@@ -8,7 +8,7 @@ if ( ! defined( 'ABSPATH' ) ) {
* Order complete emails are sent to the customer when the order is marked complete and usual indicates that the order has been shipped.
*
* @class WC_Email_Customer_Completed_Order
- * @version 2.0.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.0
* @package WooCommerce/Classes/Emails
* @author Prospress
* @extends WC_Email
@@ -45,7 +45,7 @@ class WCS_Email_Processing_Renewal_Order extends WC_Email_Customer_Processing_Or
/**
* Get the default e-mail subject.
*
- * @since 2.5.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.3
* @return string
*/
public function get_default_subject() {
@@ -55,7 +55,7 @@ class WCS_Email_Processing_Renewal_Order extends WC_Email_Customer_Processing_Or
/**
* Get the default e-mail heading.
*
- * @since 2.5.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.3
* @return string
*/
public function get_default_heading() {
diff --git a/vendor/woocommerce/subscriptions-core/includes/gateways/class-wc-subscriptions-core-payment-gateways.php b/vendor/woocommerce/subscriptions-core/includes/gateways/class-wc-subscriptions-core-payment-gateways.php
index 564d207..95edafd 100644
--- a/vendor/woocommerce/subscriptions-core/includes/gateways/class-wc-subscriptions-core-payment-gateways.php
+++ b/vendor/woocommerce/subscriptions-core/includes/gateways/class-wc-subscriptions-core-payment-gateways.php
@@ -3,7 +3,7 @@
* Subscriptions Core Payment Gateways
* Hooks into the WooCommerce payment gateways class to add subscription specific functionality.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*/
class WC_Subscriptions_Core_Payment_Gateways {
@@ -17,7 +17,7 @@ class WC_Subscriptions_Core_Payment_Gateways {
/**
* Bootstraps the class and hooks required actions & filters.
*
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function init() {
self::$is_displaying_mini_cart = false;
@@ -41,7 +41,7 @@ class WC_Subscriptions_Core_Payment_Gateways {
/**
* Instantiate our custom PayPal class
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function init_paypal() {
WCS_PayPal::init();
@@ -50,7 +50,7 @@ class WC_Subscriptions_Core_Payment_Gateways {
/**
* Returns a payment gateway object by gateway's ID, or false if it could not find the gateway.
*
- * @since 1.2.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2.4
*/
public static function get_payment_gateway( $gateway_id ) {
$found_gateway = false;
@@ -69,7 +69,7 @@ class WC_Subscriptions_Core_Payment_Gateways {
/**
* Only display the gateways which subscriptions-core supports
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
* @param array $available_gateways
* @return array
*/
@@ -146,7 +146,7 @@ class WC_Subscriptions_Core_Payment_Gateways {
/**
* Helper function to check if at least one payment gateway on the site supports a certain subscription feature.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function one_gateway_supports( $supports_flag ) {
@@ -169,7 +169,7 @@ class WC_Subscriptions_Core_Payment_Gateways {
/**
* Improve message displayed on checkout when a subscription is in the cart but not gateways support subscriptions.
*
- * @since 1.5.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5.2
*/
public static function no_available_payment_methods_message( $no_gateways_message ) {
if ( WC_Subscriptions_Cart::cart_contains_subscription() && ! wcs_is_manual_renewal_enabled() ) {
@@ -187,7 +187,7 @@ class WC_Subscriptions_Core_Payment_Gateways {
/**
* Fire a gateway specific whenever a subscription's status is changed.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function trigger_gateway_status_updated_hook( $subscription, $new_status ) {
@@ -222,7 +222,7 @@ class WC_Subscriptions_Core_Payment_Gateways {
/**
* Display a list of each gateway supported features in a tooltip
*
- * @since 2.5.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.0
*/
public static function payment_gateways_support_tooltip( $status_html, $gateway ) {
@@ -289,7 +289,7 @@ class WC_Subscriptions_Core_Payment_Gateways {
/**
* Returns whether the subscription has an available payment gateway that's supported by subscriptions-core.
*
- * @since 1.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0.0
* @param WC_Subscription $subscription Subscription to check if the gateway is available.
* @return bool
*/
@@ -358,7 +358,7 @@ class WC_Subscriptions_Core_Payment_Gateways {
/**
* Fire a gateway specific hook for when a subscription is activated.
*
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function trigger_gateway_activated_subscription_hook( $user_id, $subscription_key ) {
_deprecated_function( __METHOD__, '2.0', __CLASS__ . '::trigger_gateway_status_updated_hook()' );
@@ -368,7 +368,7 @@ class WC_Subscriptions_Core_Payment_Gateways {
/**
* Fire a gateway specific hook for when a subscription is activated.
*
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function trigger_gateway_reactivated_subscription_hook( $user_id, $subscription_key ) {
_deprecated_function( __METHOD__, '2.0', __CLASS__ . '::trigger_gateway_status_updated_hook()' );
@@ -378,7 +378,7 @@ class WC_Subscriptions_Core_Payment_Gateways {
/**
* Fire a gateway specific hook for when a subscription is on-hold.
*
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function trigger_gateway_subscription_put_on_hold_hook( $user_id, $subscription_key ) {
_deprecated_function( __METHOD__, '2.0', __CLASS__ . '::trigger_gateway_status_updated_hook()' );
@@ -388,7 +388,7 @@ class WC_Subscriptions_Core_Payment_Gateways {
/**
* Fire a gateway specific when a subscription is cancelled.
*
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function trigger_gateway_cancelled_subscription_hook( $user_id, $subscription_key ) {
_deprecated_function( __METHOD__, '2.0', __CLASS__ . '::trigger_gateway_status_updated_hook()' );
@@ -398,7 +398,7 @@ class WC_Subscriptions_Core_Payment_Gateways {
/**
* Fire a gateway specific hook when a subscription expires.
*
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function trigger_gateway_subscription_expired_hook( $user_id, $subscription_key ) {
_deprecated_function( __METHOD__, '2.0', __CLASS__ . '::trigger_gateway_status_updated_hook()' );
diff --git a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/class-wcs-paypal.php b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/class-wcs-paypal.php
index d467ee9..aef1d02 100644
--- a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/class-wcs-paypal.php
+++ b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/class-wcs-paypal.php
@@ -9,7 +9,7 @@
* @subpackage Gateways/PayPal
* @category Class
* @author Prospress
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -42,7 +42,7 @@ class WCS_PayPal {
*
* @see wc_paypal_express()
* @return WCS_PayPal
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function instance() {
if ( is_null( self::$instance ) ) {
@@ -54,7 +54,7 @@ class WCS_PayPal {
/**
* Bootstraps the class and hooks required actions & filters.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function init() {
@@ -104,6 +104,9 @@ class WCS_PayPal {
// Remove PayPal from the available payment methods if it's disabled for subscription purchases.
add_filter( 'woocommerce_available_payment_gateways', array( __CLASS__, 'maybe_remove_paypal_standard' ) );
+ // Add PayPal domains to the list of allowed hosts for safe redirect.
+ add_filter( 'allowed_redirect_hosts', __CLASS__ . '::allow_paypal_redirect' );
+
WCS_PayPal_Supports::init();
WCS_PayPal_Status_Manager::init();
WCS_PayPal_Standard_Switcher::init();
@@ -118,7 +121,7 @@ class WCS_PayPal {
/**
* Get a WooCommerce setting value for the PayPal Standard Gateway
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_option( $setting_key ) {
@@ -133,7 +136,7 @@ class WCS_PayPal {
/**
* Checks if the PayPal API credentials are set.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function are_credentials_set() {
@@ -152,7 +155,7 @@ class WCS_PayPal {
* Subscriptions keeps a record of all accounts where reference transactions were found to be enabled just in case the
* store manager switches to and from accounts. This record is stored as a JSON encoded array in the options table.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function are_reference_transactions_enabled( $bypass_cache = '' ) {
@@ -186,7 +189,7 @@ class WCS_PayPal {
/**
* Handle WC API requests where we need to run a reference transaction API operation
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function handle_wc_api() {
@@ -297,7 +300,7 @@ class WCS_PayPal {
* PayPal doesn't support subscriptions with a $0 recurring total, we need to circumvent it and
* manage it entirely ourselves.)
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_paypal_args( $paypal_args, $order ) {
@@ -318,7 +321,7 @@ class WCS_PayPal {
*
* @link https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNandPDTVariables/
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function process_ipn_request( $transaction_details ) {
@@ -343,7 +346,7 @@ class WCS_PayPal {
/**
* Check whether a given subscription is using reference transactions and if so process the payment.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function process_subscription_payment( $amount, $order ) {
@@ -369,7 +372,7 @@ class WCS_PayPal {
/**
* Process a payment based on a response
*
- * @since 2.0.9
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.9
*/
public static function process_subscription_payment_response( $order, $response ) {
@@ -416,7 +419,7 @@ class WCS_PayPal {
* @param object $resubscribe_order The order created for resubscribing the subscription
* @param object $subscription The subscription to which the resubscribe order relates
* @return object
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function remove_resubscribe_order_meta( $resubscribe_order, $subscription ) {
@@ -439,26 +442,31 @@ class WCS_PayPal {
}
/**
- * Maybe adds a warning message to subscription script parameters which is used in a Javascript dialog if the
- * payment method of the subscription is set to be changed. The warning message is only added if the subscriptions
- * payment gateway is PayPal Standard.
+ * Adds script parameters necessary to display a JS dialog when changing a PayPal subscription's payment method.
+ *
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*
* @param array $script_parameters The script parameters used in subscription meta boxes.
* @return array $script_parameters
- * @since 2.0
*/
public static function maybe_add_change_payment_method_warning( $script_parameters ) {
- global $post;
- $subscription = wcs_get_subscription( $post );
+ global $post, $theorder;
- if ( 'paypal' === $subscription->get_payment_method() ) {
+ if ( wcs_is_custom_order_tables_usage_enabled() ) {
+ $subscription = $theorder; // $theorder is a subscription object on Edit subscription admin screens.
+ } else {
+ $subscription = wcs_get_subscription( $post->ID );
+ }
- $paypal_profile_id = wcs_get_paypal_id( $subscription->get_id() );
- $is_paypal_standard = ! wcs_is_paypal_profile_a( $paypal_profile_id, 'billing_agreement' );
+ if ( ! $subscription || 'paypal' !== $subscription->get_payment_method() ) {
+ return $script_parameters;
+ }
- if ( $is_paypal_standard ) {
- $script_parameters['change_payment_method_warning'] = __( "Are you sure you want to change the payment method from PayPal standard?\n\nThis will suspend the subscription at PayPal.", 'woocommerce-subscriptions' );
- }
+ $paypal_profile_id = wcs_get_paypal_id( $subscription->get_id() );
+ $is_paypal_standard = ! wcs_is_paypal_profile_a( $paypal_profile_id, 'billing_agreement' );
+
+ if ( $is_paypal_standard ) {
+ $script_parameters['change_payment_method_warning'] = __( "Are you sure you want to change the payment method from PayPal standard?\n\nThis will suspend the subscription at PayPal.", 'woocommerce-subscriptions' );
}
return $script_parameters;
@@ -476,7 +484,7 @@ class WCS_PayPal {
* @param WC_Order $order The actual order.
*
* @return bool
- * @since 2.5.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.3
*/
public static function maybe_override_needs_payment( $needs_payment, $order ) {
if ( $needs_payment && self::instance()->get_id() === $order->get_payment_method() && ! self::are_reference_transactions_enabled() && wcs_order_contains_subscription( $order, array( 'parent' ) ) ) {
@@ -500,7 +508,7 @@ class WCS_PayPal {
* - PayPal Reference Transactions is disabled.
* - order is parent order of a subscription.
*
- * @since 2.5.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.3
*/
public static function maybe_add_payment_lock() {
if ( ! wcs_is_order_received_page() ) {
@@ -521,7 +529,7 @@ class WCS_PayPal {
*
* @param int $order_id Order cancelled/paid.
*
- * @since 2.5.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.3
*/
public static function maybe_remove_payment_lock( $order_id ) {
$order = wc_get_order( $order_id );
@@ -532,6 +540,21 @@ class WCS_PayPal {
}
}
+ /**
+ * Allow PayPal domains for redirect.
+ *
+ * @since 1.0.0
+ *
+ * @param array $hosts Add PayPal domains for `wp_safe_redirect`.
+ *
+ * @return array
+ */
+ public static function allow_paypal_redirect( $hosts ) {
+ $hosts[] = 'www.paypal.com';
+ $hosts[] = 'www.sandbox.paypal.com';
+ return $hosts;
+ }
+
/** Getters ******************************************************/
/**
@@ -539,7 +562,7 @@ class WCS_PayPal {
*
* @see SV_WC_Payment_Gateway::get_api()
* @return WC_PayPal_Express_API API instance
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
protected static function get_ipn_handler( $ipn_type = 'standard' ) {
@@ -570,7 +593,7 @@ class WCS_PayPal {
* Get the API object
*
* @return WCS_PayPal_Express_API API instance
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_api() {
@@ -590,7 +613,7 @@ class WCS_PayPal {
/**
* Return the default WC PayPal gateway's settings.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function reload_options() {
self::get_options();
@@ -599,7 +622,7 @@ class WCS_PayPal {
/**
* Return the default WC PayPal gateway's settings.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
protected static function get_options() {
@@ -613,7 +636,7 @@ class WCS_PayPal {
/**
* Log API request/response data
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function log_api_requests( $request_data, $response_data ) {
WC_Gateway_Paypal::log( 'Subscription Request Parameters: ' . print_r( $request_data, true ) );
@@ -627,7 +650,7 @@ class WCS_PayPal {
}
public function get_version() {
- return WC_Subscriptions_Core_Plugin::instance()->get_plugin_version();
+ return WC_Subscriptions_Core_Plugin::instance()->get_library_version();
}
public function get_id() {
@@ -644,7 +667,7 @@ class WCS_PayPal {
* In any other case, it will be disabled by default.
* This function is called when 2.5.0 is active for the first time. @see WC_Subscriptions_Upgrader::upgrade()
*
- * @since 2.5.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.0
*/
public static function set_enabled_for_subscriptions_default() {
@@ -674,7 +697,7 @@ class WCS_PayPal {
*
* @param array $available_gateways A list of available payment methods displayed on the checkout.
* @return array
- * @since 2.5.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.0
*/
public static function maybe_remove_paypal_standard( $available_gateways ) {
@@ -699,7 +722,7 @@ class WCS_PayPal {
/**
* Gets subscriptions with a given paypal subscription id.
*
- * @since 2.5.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.4
* @param string $paypal_id The PayPal Standard Profile ID or PayPal Reference Transactions Billing Agreement.
* @param string $return Optional. The type to return. Can be 'ids' to return subscription IDs or 'objects' to return WC_Subscription objects. Default 'ids'.
* @return WC_Subscription[]|int[] Subscriptions (objects or IDs) with the PayPal Profile ID or Billing Agreement stored in meta.
@@ -707,19 +730,21 @@ class WCS_PayPal {
public static function get_subscriptions_by_paypal_id( $paypal_id, $return = 'ids' ) {
if ( ! isset( self::$subscriptions_by_paypal_id[ $paypal_id ] ) ) {
- $subscription_ids = get_posts( array(
- 'posts_per_page' => -1,
- 'post_type' => 'shop_subscription',
- 'post_status' => 'any',
- 'fields' => 'ids',
- 'meta_query' => array(
- array(
- 'key' => '_paypal_subscription_id',
- 'compare' => '=',
- 'value' => $paypal_id,
- ),
- ),
- ) );
+ $subscription_ids = wcs_get_orders_with_meta_query(
+ [
+ 'limit' => -1,
+ 'type' => 'shop_subscription',
+ 'status' => 'any',
+ 'return' => 'ids',
+ 'meta_query' => [ // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
+ [
+ 'key' => '_paypal_subscription_id',
+ 'compare' => '=',
+ 'value' => $paypal_id,
+ ],
+ ],
+ ]
+ );
self::$subscriptions_by_paypal_id[ $paypal_id ] = array_combine( $subscription_ids, $subscription_ids );
}
diff --git a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/abstracts/abstract-wcs-sv-api-base.php b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/abstracts/abstract-wcs-sv-api-base.php
index 3332eac..84740c8 100644
--- a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/abstracts/abstract-wcs-sv-api-base.php
+++ b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/abstracts/abstract-wcs-sv-api-base.php
@@ -25,7 +25,7 @@
* @author SkyVerge
* @copyright Copyright (c) 2013-2015, SkyVerge, Inc.
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0
- * @version 2.2.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -38,7 +38,7 @@ if ( ! defined( 'ABSPATH' ) ) {
* This class provides a standardized framework for constructing an API wrapper
* to external services. It is designed to be extremely flexible.
*
- * @version 2.2.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
abstract class WCS_SV_API_Base {
@@ -86,7 +86,7 @@ abstract class WCS_SV_API_Base {
/**
* Perform the request and return the parsed response
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @param object $request class instance which implements \SV_WC_API_Request
* @throws Exception
* @return object class instance which implements \SV_WC_API_Response
@@ -129,7 +129,7 @@ abstract class WCS_SV_API_Base {
* and provide their own transport mechanism if needed, e.g. a custom
* cURL implementation
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @param string $request_uri
* @param string $request_args
* @return array|WP_Error
@@ -142,7 +142,7 @@ abstract class WCS_SV_API_Base {
/**
* Handle and parse the response
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @param array|WP_Error $response response data
* @throws Exception network issues, timeouts, API errors, etc
* @return object request class instance that implements SV_WC_API_Request
@@ -192,7 +192,7 @@ abstract class WCS_SV_API_Base {
* an exception, as it will be included in the broadcast_request() method
* which is typically used to log requests.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
protected function do_pre_parse_response_validation() {
// stub method
@@ -210,7 +210,7 @@ abstract class WCS_SV_API_Base {
*
* Note: Response body sanitization is handled automatically
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
protected function do_post_parse_response_validation() {
// stub method
@@ -220,7 +220,7 @@ abstract class WCS_SV_API_Base {
/**
* Return the parsed response object for the request
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @param string $raw_response_body
* @return object response class instance which implements SV_WC_API_Request
*/
@@ -236,7 +236,7 @@ abstract class WCS_SV_API_Base {
* Alert other actors that a request has been performed. This is primarily used
* for request logging.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
protected function broadcast_request() {
@@ -263,7 +263,7 @@ abstract class WCS_SV_API_Base {
/**
* Reset the API response members to their
*
- * @since 1.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0.0
*/
protected function reset_response() {
@@ -282,7 +282,7 @@ abstract class WCS_SV_API_Base {
/**
* Get the request URI
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @return string
*/
protected function get_request_uri() {
@@ -297,7 +297,7 @@ abstract class WCS_SV_API_Base {
* this method, which means this filter may be invoked prior to the overridden
* method.
*
- * @since 4.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.1.0
* @param string $uri current request URI
* @param \WCS_SV_API_Base class instance
*/
@@ -308,7 +308,7 @@ abstract class WCS_SV_API_Base {
/**
* Get the request arguments in the format required by wp_remote_request()
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @return mixed|void
*/
protected function get_request_args() {
@@ -333,7 +333,7 @@ abstract class WCS_SV_API_Base {
* child classes can override this method, which means this filter may
* not be invoked, or may be invoked prior to the overridden method
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @param array $args request arguments
* @param \WCS_SV_API_Base class instance
*/
@@ -344,7 +344,7 @@ abstract class WCS_SV_API_Base {
/**
* Get the request method, POST by default
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @return string
*/
protected function get_request_method() {
@@ -356,7 +356,7 @@ abstract class WCS_SV_API_Base {
/**
* Get the request HTTP version, 1.1 by default
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @return string
*/
protected function get_request_http_version() {
@@ -368,7 +368,7 @@ abstract class WCS_SV_API_Base {
/**
* Get the request headers
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @return array
*/
protected function get_request_headers() {
@@ -385,7 +385,7 @@ abstract class WCS_SV_API_Base {
* Child classes that implement any custom authorization headers should
* override this method to perform sanitization.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @return array
*/
protected function get_sanitized_request_headers() {
@@ -405,7 +405,7 @@ abstract class WCS_SV_API_Base {
*
* Dasherized-Plugin-Name/Plugin-Version (WooCommerce/WC-Version; WordPress/WP-Version)
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @return string
*/
protected function get_request_user_agent() {
@@ -417,7 +417,7 @@ abstract class WCS_SV_API_Base {
/**
* Get the request duration in seconds, rounded to the 5th decimal place
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @return string
*/
protected function get_request_duration() {
@@ -431,7 +431,7 @@ abstract class WCS_SV_API_Base {
/**
* Get the response handler class name
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @return string
*/
protected function get_response_handler() {
@@ -442,7 +442,7 @@ abstract class WCS_SV_API_Base {
/**
* Get the response code
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @return string
*/
protected function get_response_code() {
@@ -453,7 +453,7 @@ abstract class WCS_SV_API_Base {
/**
* Get the response message
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @return string
*/
protected function get_response_message() {
@@ -464,7 +464,7 @@ abstract class WCS_SV_API_Base {
/**
* Get the response headers
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @return array
*/
protected function get_response_headers() {
@@ -475,7 +475,7 @@ abstract class WCS_SV_API_Base {
/**
* Get the raw response body, prior to any parsing or sanitization
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @return string
*/
protected function get_raw_response_body() {
@@ -487,7 +487,7 @@ abstract class WCS_SV_API_Base {
* Get the sanitized response body, provided by the response class
* to_string_safe() method
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @return string|null
*/
protected function get_sanitized_response_body() {
@@ -501,7 +501,7 @@ abstract class WCS_SV_API_Base {
/**
* Returns the most recent request object
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @see \SV_WC_API_Request
* @return object the most recent request object
*/
@@ -513,7 +513,7 @@ abstract class WCS_SV_API_Base {
/**
* Returns the most recent response object
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @see \SV_WC_API_Response
* @return object the most recent response object
*/
@@ -526,7 +526,7 @@ abstract class WCS_SV_API_Base {
* Get the ID for the API, used primarily to namespace the action name
* for broadcasting requests
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @return string
*/
protected function get_api_id() {
@@ -543,7 +543,7 @@ abstract class WCS_SV_API_Base {
* to build the request. The returned SV_WC_API_Request should be passed
* to self::perform_request() by your concrete API methods
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @param array $args optional request arguments
* @return SV_WC_API_Request
*/
@@ -558,7 +558,7 @@ abstract class WCS_SV_API_Base {
* This is used for defining the plugin ID used in filter names, as well
* as the plugin name used for the default user agent.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @return SV_WC_Plugin
*/
abstract protected function get_plugin();
@@ -570,7 +570,7 @@ abstract class WCS_SV_API_Base {
/**
* Set a header request
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @param string $name header name
* @param string $value header value
* @return string
@@ -597,7 +597,7 @@ abstract class WCS_SV_API_Base {
/**
* Set the Content-Type request header
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @param string $content_type
*/
protected function set_request_content_type_header( $content_type ) {
@@ -608,7 +608,7 @@ abstract class WCS_SV_API_Base {
/**
* Set the Accept request header
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @param string $type the request accept type
*/
protected function set_request_accept_header( $type ) {
@@ -622,7 +622,7 @@ abstract class WCS_SV_API_Base {
*
* Note the class should implement SV_WC_API
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @param string $handler handle class name
* @return array
*/
diff --git a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/admin/class-wcs-paypal-admin.php b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/admin/class-wcs-paypal-admin.php
index b29ec22..f714324 100644
--- a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/admin/class-wcs-paypal-admin.php
+++ b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/admin/class-wcs-paypal-admin.php
@@ -8,7 +8,7 @@
* @subpackage Gateways/PayPal
* @category Class
* @author Prospress
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -20,7 +20,7 @@ class WCS_PayPal_Admin {
/**
* Bootstraps the class and hooks required actions & filters.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function init() {
@@ -47,7 +47,7 @@ class WCS_PayPal_Admin {
/**
* Adds extra PayPal credential fields required to manage subscriptions.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function add_form_fields() {
@@ -67,7 +67,7 @@ class WCS_PayPal_Admin {
/**
* Handle requests to check whether a PayPal account has Reference Transactions enabled
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function maybe_check_account() {
@@ -88,7 +88,7 @@ class WCS_PayPal_Admin {
/**
* Display an assortment of notices to administrators to encourage them to get PayPal setup right.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function maybe_show_admin_notices() {
self::maybe_disable_invalid_profile_notice();
@@ -217,7 +217,7 @@ class WCS_PayPal_Admin {
/**
* Disable the invalid profile notice when requested.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
protected static function maybe_disable_invalid_profile_notice() {
if ( isset( $_GET['wcs_disable_paypal_invalid_profile_id_notice'] ) ) {
@@ -232,7 +232,7 @@ class WCS_PayPal_Admin {
/**
* Remove the invalid credentials error flag whenever a new set of API credentials are saved.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function maybe_update_credentials_error_flag() {
@@ -304,7 +304,7 @@ class WCS_PayPal_Admin {
*
* @param array $settings The WooCommerce PayPal Settings array.
* @return array
- * @since 2.5.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.0
*/
public static function add_enable_for_subscriptions_setting( $settings ) {
if ( WCS_PayPal::are_reference_transactions_enabled() ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/admin/class-wcs-paypal-change-payment-method-admin.php b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/admin/class-wcs-paypal-change-payment-method-admin.php
index c18910c..e2c9888 100644
--- a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/admin/class-wcs-paypal-change-payment-method-admin.php
+++ b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/admin/class-wcs-paypal-change-payment-method-admin.php
@@ -8,7 +8,7 @@
* @subpackage Gateways/PayPal
* @category Class
* @author Prospress
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -20,7 +20,7 @@ class WCS_PayPal_Change_Payment_Method_Admin {
/**
* Bootstraps the class and hooks required actions & filters.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function init() {
@@ -40,7 +40,7 @@ class WCS_PayPal_Change_Payment_Method_Admin {
* @param array $payment_meta associative array of meta data required for automatic payments
* @param WC_Subscription $subscription An instance of a subscription object
* @return array
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function add_payment_meta_details( $payment_meta, $subscription ) {
$subscription_id = get_post_meta( $subscription->get_id(), '_paypal_subscription_id', true );
@@ -73,7 +73,7 @@ class WCS_PayPal_Change_Payment_Method_Admin {
* @param string $payment_method_id The ID of the payment method to validate
* @param array $payment_meta associative array of meta data required for automatic payments
* @return array
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function validate_payment_meta( $payment_meta, $subscription ) {
if ( empty( $payment_meta['post_meta']['_paypal_subscription_id']['value'] ) ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-reference-transaction-api-request.php b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-reference-transaction-api-request.php
index 0ee24ba..6dc52b8 100644
--- a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-reference-transaction-api-request.php
+++ b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-reference-transaction-api-request.php
@@ -9,7 +9,7 @@
* @package WooCommerce Subscriptions
* @subpackage Gateways/PayPal
* @category Class
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -31,7 +31,7 @@ class WCS_PayPal_Reference_Transaction_API_Request {
* @param string $api_password the API password
* @param string $api_signature the API signature
* @param string $api_version the API version
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function __construct( $api_username, $api_password, $api_signature, $api_version ) {
@@ -63,7 +63,7 @@ class WCS_PayPal_Reference_Transaction_API_Request {
* @type string 'cancel_url' (Required) URL to which the buyer is returned if the buyer does not approve the use of PayPal to pay you.
* @type string 'custom' (Optional) A free-form field for up to 256 single-byte alphanumeric characters
* }
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function set_express_checkout( $args ) {
@@ -132,7 +132,7 @@ class WCS_PayPal_Reference_Transaction_API_Request {
* @link https://developer.paypal.com/docs/classic/express-checkout/integration-guide/ECGettingStarted/#id084RN060BPF
* @link https://developer.paypal.com/webapps/developer/docs/classic/api/merchant/DoExpressCheckoutPayment_API_Operation_NVP/
*
- * @since 2.0.9
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.9
* @param string $token PayPal Express Checkout token returned by SetExpressCheckout operation
* @param WC_Order $order order object
* @param string $type
@@ -159,7 +159,7 @@ class WCS_PayPal_Reference_Transaction_API_Request {
* @link https://developer.paypal.com/webapps/developer/docs/classic/api/merchant/GetExpressCheckoutDetails_API_Operation_NVP/
*
* @param string $token token from SetExpressCheckout response
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function get_express_checkout_details( $token ) {
@@ -174,7 +174,7 @@ class WCS_PayPal_Reference_Transaction_API_Request {
* @link https://developer.paypal.com/docs/classic/api/merchant/CreateBillingAgreement_API_Operation_NVP/
*
* @param string $token token from SetExpressCheckout response
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function create_billing_agreement( $token ) {
@@ -195,7 +195,7 @@ class WCS_PayPal_Reference_Transaction_API_Request {
* @type string 'payment_action' How you want to obtain payment. It is one of the following values: 'Authorization' - this payment is a basic authorization subject to settlement with PayPal Authorization and Capture; or 'Sale' - This is a final sale for which you are requesting payment.
* @type string 'return_fraud_filters' (Optional) Flag to indicate whether you want the results returned by Fraud Management Filters. By default, you do not receive this information.
* }
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function do_reference_transaction( $reference_id, $order, $args = array() ) {
@@ -232,7 +232,7 @@ class WCS_PayPal_Reference_Transaction_API_Request {
/**
* Set up the payment details for a DoExpressCheckoutPayment or DoReferenceTransaction request
*
- * @since 2.0.9
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.9
* @param WC_Order $order order object
* @param string $type the type of transaction for the payment
* @param bool $use_deprecated_params whether to use deprecated PayPal NVP parameters (required for DoReferenceTransaction API calls)
@@ -402,7 +402,7 @@ class WCS_PayPal_Reference_Transaction_API_Request {
* Although the PayPal Standard API provides no facility for cancelling a subscription, the PayPal
* Express Checkout NVP API can be used.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function manage_recurring_payments_profile_status( $profile_id, $new_status, $order = null ) {
@@ -424,7 +424,7 @@ class WCS_PayPal_Reference_Transaction_API_Request {
*
* @param string $key
* @param string|int $value
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
private function add_parameter( $key, $value ) {
$this->parameters[ $key ] = $value;
@@ -434,7 +434,7 @@ class WCS_PayPal_Reference_Transaction_API_Request {
* Add multiple parameters
*
* @param array $params
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
private function add_parameters( array $params ) {
foreach ( $params as $key => $value ) {
@@ -451,7 +451,7 @@ class WCS_PayPal_Reference_Transaction_API_Request {
* + `DoCapture` - captures a previously authorized transaction
*
* @param string $method
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
private function set_method( $method ) {
$this->add_parameter( 'METHOD', $method );
@@ -462,7 +462,7 @@ class WCS_PayPal_Reference_Transaction_API_Request {
* for convenience and readability
*
* @param array $params
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
private function add_payment_parameters( array $params ) {
foreach ( $params as $key => $value ) {
@@ -476,7 +476,7 @@ class WCS_PayPal_Reference_Transaction_API_Request {
*
* @param array $params
* @param int $item_count current item count
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
private function add_line_item_parameters( array $params, $item_count, $use_deprecated_params = false ) {
foreach ( $params as $key => $value ) {
@@ -498,7 +498,7 @@ class WCS_PayPal_Reference_Transaction_API_Request {
* @param array $item cart or order item
* @param \WC_Product $product product data
* @return string
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
private function get_item_description( $item, $product ) {
@@ -545,7 +545,7 @@ class WCS_PayPal_Reference_Transaction_API_Request {
*
* @see SV_WC_Payment_Gateway_API_Request::to_string()
* @return string the request query string
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function to_string() {
return http_build_query( $this->get_parameters(), '', '&' );
@@ -557,7 +557,7 @@ class WCS_PayPal_Reference_Transaction_API_Request {
*
* @see SV_WC_Payment_Gateway_API_Request::to_string_safe()
* @return string the pretty-printed request array string representation, safe for logging
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function to_string_safe() {
@@ -581,7 +581,7 @@ class WCS_PayPal_Reference_Transaction_API_Request {
*
* @throws \Exception invalid amount
* @return array request parameters
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function get_parameters() {
/**
@@ -624,7 +624,7 @@ class WCS_PayPal_Reference_Transaction_API_Request {
* method (POST)
*
* @return null
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function get_method() { }
@@ -633,7 +633,7 @@ class WCS_PayPal_Reference_Transaction_API_Request {
* vary per request
*
* @return string
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function get_path() {
return '';
@@ -645,7 +645,7 @@ class WCS_PayPal_Reference_Transaction_API_Request {
* to rounding issues), so line items are skipped and the order is sent as
* a single item
*
- * @since 2.0.9
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.9
* @param WC_Order $order Optional. The WC_Order object. Default null.
* @return bool true if line items should be skipped, false otherwise
*/
@@ -673,7 +673,7 @@ class WCS_PayPal_Reference_Transaction_API_Request {
/**
* Filter whether line items should be skipped or not
*
- * @since 3.3.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.3.0
* @param bool $skip_line_items True if line items should be skipped, false otherwise
* @param WC_Order/null $order The WC_Order object or null.
*/
@@ -683,7 +683,7 @@ class WCS_PayPal_Reference_Transaction_API_Request {
/**
* Round a float
*
- * @since 2.0.9
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.9
* @param float $number
* @param int $precision Optional. The number of decimal digits to round to.
*/
@@ -694,7 +694,7 @@ class WCS_PayPal_Reference_Transaction_API_Request {
/**
* Format prices.
*
- * @since 2.2.12
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.12
* @param float|int $price
* @param int $decimals Optional. The number of decimal points.
* @return string
diff --git a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-reference-transaction-api-response-billing-agreement.php b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-reference-transaction-api-response-billing-agreement.php
index 99c1dcb..766cead 100644
--- a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-reference-transaction-api-response-billing-agreement.php
+++ b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-reference-transaction-api-response-billing-agreement.php
@@ -9,7 +9,7 @@
* @package WooCommerce Subscriptions
* @subpackage Gateways/PayPal
* @category Class
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -23,7 +23,7 @@ class WCS_PayPal_Reference_Transaction_API_Response_Billing_Agreement extends WC
* Get the billing agreement ID which is returned after a successful CreateBillingAgreement API call
*
* @return string|null
- * @since 2.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.0
*/
public function get_billing_agreement_id() {
return $this->get_parameter( 'BILLINGAGREEMENTID' );
diff --git a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-reference-transaction-api-response-checkout.php b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-reference-transaction-api-response-checkout.php
index 2af26d7..8cc1730 100644
--- a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-reference-transaction-api-response-checkout.php
+++ b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-reference-transaction-api-response-checkout.php
@@ -13,7 +13,7 @@
* @package WooCommerce Subscriptions
* @subpackage Gateways/PayPal
* @category Class
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -27,7 +27,7 @@ class WCS_PayPal_Reference_Transaction_API_Response_Checkout extends WCS_PayPal_
* API call
*
* @return string|null
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function get_token() {
return $this->get_parameter( 'TOKEN' );
@@ -36,9 +36,9 @@ class WCS_PayPal_Reference_Transaction_API_Response_Checkout extends WCS_PayPal_
/**
* Get the billing agreement status for a successful SetExpressCheckout
*
- * @since 3.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.0.0
* @return string|null
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function get_billing_agreement_status() {
return $this->get_parameter( 'BILLINGAGREEMENTACCEPTEDSTATUS' );
@@ -47,9 +47,9 @@ class WCS_PayPal_Reference_Transaction_API_Response_Checkout extends WCS_PayPal_
/**
* Get the shipping details from GetExpressCheckoutDetails response mapped to the WC shipping address format
*
- * @since 3.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.0.0
* @return array
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function get_shipping_details() {
@@ -79,7 +79,7 @@ class WCS_PayPal_Reference_Transaction_API_Response_Checkout extends WCS_PayPal_
* Get the note text from checkout details
*
* @return string
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function get_note_text() {
return $this->get_parameter( 'PAYMENTREQUEST_0_NOTETEXT' );
@@ -89,7 +89,7 @@ class WCS_PayPal_Reference_Transaction_API_Response_Checkout extends WCS_PayPal_
* Gets the payer ID from checkout details, a payer ID is a Unique PayPal Customer Account identification number
*
* @return string
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function get_payer_id() {
return $this->get_parameter( 'PAYERID' );
@@ -101,7 +101,7 @@ class WCS_PayPal_Reference_Transaction_API_Response_Checkout extends WCS_PayPal_
* @param string $country_code country code sent by PayPal
* @param string $state state name or code sent by PayPal
* @return string state code
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
private function get_state_code( $country_code, $state ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-reference-transaction-api-response-payment.php b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-reference-transaction-api-response-payment.php
index 17aa88c..8bfff10 100644
--- a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-reference-transaction-api-response-payment.php
+++ b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-reference-transaction-api-response-payment.php
@@ -11,7 +11,7 @@
* @package WooCommerce Subscriptions
* @subpackage Gateways/PayPal
* @category Class
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -42,7 +42,7 @@ class WCS_PayPal_Reference_Transaction_API_Response_Payment extends WCS_PayPal_R
*
* @see WC_PayPal_Express_API_Response::__construct()
* @param string $response the raw URL-encoded response string
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function __construct( $response ) {
@@ -59,7 +59,7 @@ class WCS_PayPal_Reference_Transaction_API_Response_Payment extends WCS_PayPal_R
* Checks if the transaction was successful
*
* @return bool true if approved, false otherwise
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function transaction_approved() {
@@ -74,7 +74,7 @@ class WCS_PayPal_Reference_Transaction_API_Response_Payment extends WCS_PayPal_R
* @link https://developer.paypal.com/docs/classic/api/merchant/DoExpressCheckoutPayment_API_Operation_NVP/#id105CAM003Y4__id116RI0UF0YK
*
* @return bool true if the transaction was held, false otherwise
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function transaction_held() {
@@ -88,7 +88,7 @@ class WCS_PayPal_Reference_Transaction_API_Response_Payment extends WCS_PayPal_R
* @link https://developer.paypal.com/docs/classic/api/merchant/DoExpressCheckoutPayment_API_Operation_NVP/#id105CAM003Y4__id116RI0UF0YK
*
* @return string status code
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function get_status_code() {
@@ -102,7 +102,7 @@ class WCS_PayPal_Reference_Transaction_API_Response_Payment extends WCS_PayPal_R
* PayPal provides additional info only for Pending or Completed-Funds-Held transactions.
*
* @return string status message
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function get_status_message() {
@@ -135,7 +135,7 @@ class WCS_PayPal_Reference_Transaction_API_Response_Payment extends WCS_PayPal_R
* Gets the response transaction id, or null if there is no transaction id associated with this transaction.
*
* @return string transaction id
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function get_transaction_id() {
@@ -147,7 +147,7 @@ class WCS_PayPal_Reference_Transaction_API_Response_Payment extends WCS_PayPal_R
* Return true if the response has a payment type other than `none`
*
* @return bool
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function has_payment_type() {
@@ -158,7 +158,7 @@ class WCS_PayPal_Reference_Transaction_API_Response_Payment extends WCS_PayPal_R
/**
* Get the PayPal payment type, either `none`, `echeck`, or `instant`
*
- * @since 2.0.9
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.9
* @return string
*/
public function get_payment_type() {
@@ -171,7 +171,7 @@ class WCS_PayPal_Reference_Transaction_API_Response_Payment extends WCS_PayPal_R
* Gets payment status
*
* @return string
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
private function get_payment_status() {
@@ -183,7 +183,7 @@ class WCS_PayPal_Reference_Transaction_API_Response_Payment extends WCS_PayPal_R
* Gets the pending reason
*
* @return string
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
private function get_pending_reason() {
@@ -198,7 +198,7 @@ class WCS_PayPal_Reference_Transaction_API_Response_Payment extends WCS_PayPal_R
* PayPal Express does not return an authorization code
*
* @return string credit card authorization code
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function get_authorization_code() {
return false;
@@ -209,7 +209,7 @@ class WCS_PayPal_Reference_Transaction_API_Response_Payment extends WCS_PayPal_R
* Returns the result of the AVS check
*
* @return string result of the AVS check, if any
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function get_avs_result() {
@@ -232,7 +232,7 @@ class WCS_PayPal_Reference_Transaction_API_Response_Payment extends WCS_PayPal_R
* Returns the result of the CSC check
*
* @return string result of CSC check
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function get_csc_result() {
@@ -255,7 +255,7 @@ class WCS_PayPal_Reference_Transaction_API_Response_Payment extends WCS_PayPal_R
* Returns true if the CSC check was successful
*
* @return boolean true if the CSC check was successful
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function csc_match() {
@@ -278,7 +278,7 @@ class WCS_PayPal_Reference_Transaction_API_Response_Payment extends WCS_PayPal_R
* @type string $id filter ID, integer from 1-17
* @type string name filter name, short description for filter
* }
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
private function get_fraud_filters() {
@@ -318,7 +318,7 @@ class WCS_PayPal_Reference_Transaction_API_Response_Payment extends WCS_PayPal_R
* A wrapper around @see WCS_PayPal_Reference_Transaction_API_Response::has_parameter()
* that prepends the @see self::get_payment_parameter_prefix().
*
- * @since 2.0.9
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.9
* @param string $name parameter name
* @return bool
*/
@@ -333,7 +333,7 @@ class WCS_PayPal_Reference_Transaction_API_Response_Payment extends WCS_PayPal_R
* A wrapper around @see WCS_PayPal_Reference_Transaction_API_Response::get_parameter()
* that prepends the @see self::get_payment_parameter_prefix().
*
- * @since 2.0.9
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.9
* @param string $name parameter name
* @return string|null
*/
@@ -347,7 +347,7 @@ class WCS_PayPal_Reference_Transaction_API_Response_Payment extends WCS_PayPal_R
* parameters. Parallels payments are not used, so the numeric portion of
* the prefix is always '0'
*
- * @since 2.0.9
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.9
* @return string
*/
protected function get_payment_parameter_prefix() {
diff --git a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-reference-transaction-api-response-recurring-payment.php b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-reference-transaction-api-response-recurring-payment.php
index 3b60bf5..71dd755 100644
--- a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-reference-transaction-api-response-recurring-payment.php
+++ b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-reference-transaction-api-response-recurring-payment.php
@@ -15,7 +15,7 @@
* @package WooCommerce Subscriptions
* @subpackage Gateways/PayPal
* @category Class
- * @since 2.0.9
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.9
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -29,7 +29,7 @@ class WCS_PayPal_Reference_Transaction_API_Response_Recurring_Payment extends WC
*
* @see WC_PayPal_Express_API_Response::__construct()
* @param string $response the raw URL-encoded response string
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function __construct( $response ) {
parent::__construct( $response );
@@ -40,7 +40,7 @@ class WCS_PayPal_Reference_Transaction_API_Response_Recurring_Payment extends WC
* parameters. Parallels payments are not used, so the numeric portion of
* the prefix is always '0'
*
- * @since 2.0.9
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.9
* @return string
*/
protected function get_payment_parameter_prefix() {
diff --git a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-reference-transaction-api-response.php b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-reference-transaction-api-response.php
index 729dc59..03943dc 100644
--- a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-reference-transaction-api-response.php
+++ b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-reference-transaction-api-response.php
@@ -11,7 +11,7 @@
* @package WooCommerce Subscriptions
* @subpackage Gateways/PayPal
* @category Class
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -29,7 +29,7 @@ class WCS_PayPal_Reference_Transaction_API_Response extends WC_Gateway_Paypal_Re
* @link https://developer.paypal.com/docs/classic/api/NVPAPIOverview/#id084FBM0M0HS
*
* @param string $response the raw URL-encoded response string
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function __construct( $response ) {
@@ -43,7 +43,7 @@ class WCS_PayPal_Reference_Transaction_API_Response extends WC_Gateway_Paypal_Re
* @link https://developer.paypal.com/docs/classic/api/errorcodes/
*
* @return bool true if has API error, false otherwise
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function has_api_error() {
@@ -63,7 +63,7 @@ class WCS_PayPal_Reference_Transaction_API_Response extends WC_Gateway_Paypal_Re
* @link https://developer.paypal.com/docs/classic/api/errorcodes/
*
* @return bool true if has API error relating to incorrect credentials, false otherwise
- * @since 2.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1
*/
public function has_api_error_for_credentials() {
@@ -97,7 +97,7 @@ class WCS_PayPal_Reference_Transaction_API_Response extends WC_Gateway_Paypal_Re
* @link https://developer.paypal.com/docs/classic/api/errorcodes/
*
* @return string
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function get_api_error_code() {
@@ -122,7 +122,7 @@ class WCS_PayPal_Reference_Transaction_API_Response extends WC_Gateway_Paypal_Re
* @link https://developer.paypal.com/docs/classic/api/errorcodes/
*
* @return string
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function get_api_error_message() {
@@ -155,7 +155,7 @@ class WCS_PayPal_Reference_Transaction_API_Response extends WC_Gateway_Paypal_Re
*
* @param string $name parameter name
* @return bool
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
protected function has_parameter( $name ) {
return ! empty( $this->parameters[ $name ] );
@@ -166,7 +166,7 @@ class WCS_PayPal_Reference_Transaction_API_Response extends WC_Gateway_Paypal_Re
*
* @param string $name parameter name
* @return string|null
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
protected function get_parameter( $name ) {
return $this->has_parameter( $name ) ? $this->parameters[ $name ] : null;
@@ -181,7 +181,7 @@ class WCS_PayPal_Reference_Transaction_API_Response extends WC_Gateway_Paypal_Re
* @link https://developer.paypal.com/docs/classic/api/errorcodes/
*
* @return string user message, if there is one
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function get_user_message() {
@@ -201,7 +201,7 @@ class WCS_PayPal_Reference_Transaction_API_Response extends WC_Gateway_Paypal_Re
* Returns the string representation of this response
*
* @return string response
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function to_string() {
@@ -213,7 +213,7 @@ class WCS_PayPal_Reference_Transaction_API_Response extends WC_Gateway_Paypal_Re
* sensitive elements masked or removed
*
* @return string response safe for logging/displaying
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function to_string_safe() {
@@ -226,7 +226,7 @@ class WCS_PayPal_Reference_Transaction_API_Response extends WC_Gateway_Paypal_Re
*
* @see WC_Gateway_Paypal_Response::get_paypal_order()
* @param string $response the raw URL-encoded response string
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function get_order() {
diff --git a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-reference-transaction-api.php b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-reference-transaction-api.php
index 39294a9..9f90a1e 100644
--- a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-reference-transaction-api.php
+++ b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-reference-transaction-api.php
@@ -15,7 +15,7 @@
* @package WooCommerce Subscriptions
* @subpackage Gateways/PayPal
* @category Class
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -44,7 +44,7 @@ class WCS_PayPal_Reference_Transaction_API extends WCS_SV_API_Base {
* @param string $api_username the API username
* @param string $api_password the API password
* @param string $api_signature the API signature
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function __construct( $gateway_id, $api_environment, $api_username, $api_password, $api_signature ) {
@@ -68,7 +68,7 @@ class WCS_PayPal_Reference_Transaction_API extends WCS_SV_API_Base {
* @param array $paypal_args
* @param WC_Order $order
* @return array
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function get_paypal_args( $paypal_args, $order ) {
@@ -103,7 +103,7 @@ class WCS_PayPal_Reference_Transaction_API extends WCS_SV_API_Base {
* @link https://developer.paypal.com/docs/classic/api/errorcodes/#id09C3G0PJ0N9__id5e8c50e9-4f1b-462a-8586-399b63b07f1a
*
* @return bool
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function are_reference_transactions_enabled() {
@@ -145,7 +145,7 @@ class WCS_PayPal_Reference_Transaction_API extends WCS_SV_API_Base {
* @param array $args @see WCS_PayPal_Reference_Transaction_API_Request::set_express_checkout() for details
* @throws Exception network timeouts, etc
* @return WCS_PayPal_Reference_Transaction_API_Response_Checkout response object
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function set_express_checkout( $args ) {
@@ -166,7 +166,7 @@ class WCS_PayPal_Reference_Transaction_API extends WCS_SV_API_Base {
*
* @param string $token token from SetExpressCheckout response
* @return WCS_PayPal_Reference_Transaction_API_Response_Billing_Agreement response object
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function create_billing_agreement( $token ) {
@@ -185,7 +185,7 @@ class WCS_PayPal_Reference_Transaction_API extends WCS_SV_API_Base {
* @param string $token Token from set_express_checkout response
* @return WC_PayPal_Reference_Transaction_API_Checkout_Response response object
* @throws Exception network timeouts, etc
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function get_express_checkout_details( $token ) {
@@ -205,7 +205,7 @@ class WCS_PayPal_Reference_Transaction_API extends WCS_SV_API_Base {
* @param WC_Order $order order object
* @param array $args
* @return WCS_PayPal_Reference_Transaction_API_Response_Payment refund response
- * @since 2.0.9
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.9
*/
public function do_express_checkout( $token, $order, $args ) {
@@ -227,7 +227,7 @@ class WCS_PayPal_Reference_Transaction_API extends WCS_SV_API_Base {
* @param WC_Order $order order object
* @return SV_WC_Payment_Gateway_API_Response refund response
* @throws SV_WC_Payment_Gateway_Exception network timeouts, etc
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function do_reference_transaction( $reference_id, $order, $args ) {
@@ -245,7 +245,7 @@ class WCS_PayPal_Reference_Transaction_API extends WCS_SV_API_Base {
/**
* Change the status of a subscription for a given order/profile ID
*
- * @since 2.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.0
* @see SV_WC_Payment_Gateway_API::refund()
* @param WC_Order $order order object
* @return SV_WC_Payment_Gateway_API_Response refund response
@@ -267,14 +267,23 @@ class WCS_PayPal_Reference_Transaction_API extends WCS_SV_API_Base {
/** Helper methods ******************************************************/
/**
- * Get the wc-api URL to redirect to
+ * Get the wc-api URL to redirect to.
*
- * @param string $action checkout action, either `set_express_checkout or `get_express_checkout_details`
- * @return string URL
- * @since 2.0
+ * @param string $action checkout action, either `set_express_checkout or `get_express_checkout_details`.
+ *
+ * @return string URL The URL. Note: this URL is escaped.
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function get_callback_url( $action ) {
- return add_query_arg( 'action', $action, WC()->api_request_url( 'wcs_paypal' ) );
+ return esc_url(
+ add_query_arg(
+ 'action',
+ $action,
+ WC()->api_request_url( 'wcs_paypal' )
+ ),
+ null,
+ 'db'
+ );
}
/**
@@ -283,7 +292,7 @@ class WCS_PayPal_Reference_Transaction_API extends WCS_SV_API_Base {
* @see \WCS_SV_API_Base::get_new_request()
* @param array $args
* @return WC_PayPal_Reference_Transaction_API_Request API request object
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
protected function get_new_request( $args = array() ) {
return new WCS_PayPal_Reference_Transaction_API_Request( $this->api_username, $this->api_password, $this->api_signature, self::VERSION );
@@ -294,7 +303,7 @@ class WCS_PayPal_Reference_Transaction_API extends WCS_SV_API_Base {
*
* @see \WCS_SV_API_Base::get_plugin()
* @return object
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
protected function get_plugin() {
return WCS_PayPal::instance();
diff --git a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-reference-transaction-ipn-handler.php b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-reference-transaction-ipn-handler.php
index c20cd90..9e7aac6 100644
--- a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-reference-transaction-ipn-handler.php
+++ b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-reference-transaction-ipn-handler.php
@@ -10,7 +10,7 @@
* @subpackage Gateways/PayPal
* @category Class
* @author Prospress
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -88,7 +88,7 @@ class WCS_PayPal_Reference_Transaction_IPN_Handler extends WCS_PayPal_Standard_I
* Find all subscription with a given billing agreement ID and cancel them because that billing agreement has been
* cancelled at PayPal, and therefore, no future payments can be charged.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
protected function cancel_subscriptions( $billing_agreement_id ) {
$note = esc_html__( 'Billing agreement cancelled at PayPal.', 'woocommerce-subscriptions' );
@@ -111,7 +111,7 @@ class WCS_PayPal_Reference_Transaction_IPN_Handler extends WCS_PayPal_Standard_I
/**
* Removes a billing agreement from all subscriptions.
*
- * @since 2.5.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.4
* @param string $billing_agreement_id The billing agreement to remove.
*/
protected function remove_billing_agreement_from_subscriptions( $billing_agreement_id ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-standard-change-payment-method.php b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-standard-change-payment-method.php
index 8cd0e6c..8fbb050 100644
--- a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-standard-change-payment-method.php
+++ b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-standard-change-payment-method.php
@@ -10,7 +10,7 @@
* @subpackage Gateways/PayPal
* @category Class
* @author Prospress
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -22,7 +22,7 @@ class WCS_PayPal_Standard_Change_Payment_Method {
/**
* Bootstraps the class and hooks required actions & filters.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function init() {
@@ -40,7 +40,7 @@ class WCS_PayPal_Standard_Change_Payment_Method {
* If changing a subscriptions payment method from and to PayPal, wait until an appropriate IPN message
* has come in before deciding to cancel the old subscription.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function maybe_remove_subscription_cancelled_callback( $subscription, $new_payment_method, $old_payment_method ) {
if ( 'paypal' == $new_payment_method && 'paypal' == $old_payment_method && ! WCS_PayPal::are_reference_transactions_enabled() ) {
@@ -52,7 +52,7 @@ class WCS_PayPal_Standard_Change_Payment_Method {
* If changing a subscriptions payment method from and to PayPal, the cancelled subscription hook was removed in
* @see self::maybe_remove_cancelled_subscription_hook() so we want to add it again for other subscriptions.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function maybe_reattach_subscription_cancelled_callback( $subscription, $new_payment_method, $old_payment_method ) {
if ( 'paypal' == $new_payment_method && 'paypal' == $old_payment_method && ! WCS_PayPal::are_reference_transactions_enabled() ) {
@@ -65,7 +65,7 @@ class WCS_PayPal_Standard_Change_Payment_Method {
*
* @param string $item_name
* @return string
- * @since 1.5.14
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5.14
*/
public static function maybe_dont_update_payment_method( $update, $new_payment_method, $subscription ) {
@@ -81,7 +81,7 @@ class WCS_PayPal_Standard_Change_Payment_Method {
*
* @param string $change_button_text
* @param WC_Payment_Gateway $gateway
- * @since 2.0.8
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.8
*/
public static function change_payment_button_text( $change_button_text, $gateway ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-standard-ipn-failure-handler.php b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-standard-ipn-failure-handler.php
index 57f49ad..ae32c31 100644
--- a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-standard-ipn-failure-handler.php
+++ b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-standard-ipn-failure-handler.php
@@ -8,7 +8,7 @@
* @subpackage Gateways/PayPal
* @category Class
* @author Prospress
- * @since 2.0.6
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.6
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -27,7 +27,7 @@ class WCS_PayPal_Standard_IPN_Failure_Handler {
/**
* Attaches all IPN failure handler related hooks and filters and also sets logging to enabled.
*
- * @since 2.0.6
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.6
* @param array $transaction_details
*/
public static function attach( $transaction_details ) {
@@ -53,7 +53,7 @@ class WCS_PayPal_Standard_IPN_Failure_Handler {
/**
* Close up loose ends
*
- * @since 2.0.6
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.6
* @param $transaction_details
*/
public static function detach( $transaction_details ) {
@@ -66,7 +66,7 @@ class WCS_PayPal_Standard_IPN_Failure_Handler {
/**
* On PHP shutdown log any unexpected failures from PayPal IPN processing
*
- * @since 2.0.6
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.6
*/
public static function catch_unexpected_shutdown() {
@@ -82,7 +82,7 @@ class WCS_PayPal_Standard_IPN_Failure_Handler {
/**
* Log any fatal errors occurred while Subscriptions is trying to process IPN messages
*
- * @since 2.0.6
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.6
* @param array $transaction_details the current IPN message being processed when the fatal error occurred
* @param array $error
*/
@@ -107,7 +107,7 @@ class WCS_PayPal_Standard_IPN_Failure_Handler {
/**
* Log any unexpected fatal errors to wcs-ipn-failures log file
*
- * @since 2.0.6
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.6
* @param string $message
*/
public static function log_to_failure( $message ) {
@@ -123,7 +123,7 @@ class WCS_PayPal_Standard_IPN_Failure_Handler {
* Builds an error array from exception and call @see self::log_ipn_errors() to log unhandled
* exceptions in a separate paypal log.
*
- * @since 2.0.6
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.6
* @param Exception $exception
*/
public static function log_unexpected_exception( $exception ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-standard-ipn-handler.php b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-standard-ipn-handler.php
index 8493d32..b97a827 100644
--- a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-standard-ipn-handler.php
+++ b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-standard-ipn-handler.php
@@ -12,7 +12,7 @@
* @subpackage Gateways/PayPal
* @category Class
* @author Prospress
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -50,7 +50,7 @@ class WCS_PayPal_Standard_IPN_Handler extends WC_Gateway_Paypal_IPN_Handler {
* Based on the IPN Variables documented here: https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNandPDTVariables/#id091EB0901HT
*
* @param array $transaction_details Post data after wp_unslash
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function valid_response( $transaction_details ) {
global $wpdb;
@@ -71,7 +71,7 @@ class WCS_PayPal_Standard_IPN_Handler extends WC_Gateway_Paypal_IPN_Handler {
* Process a PayPal Standard Subscription IPN request
*
* @param array $transaction_details Post data after wp_unslash
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
protected function process_ipn_request( $transaction_details ) {
@@ -558,7 +558,7 @@ class WCS_PayPal_Standard_IPN_Handler extends WC_Gateway_Paypal_IPN_Handler {
/**
* Return valid transaction types
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function get_transaction_types() {
return $this->transaction_types;
@@ -584,11 +584,11 @@ class WCS_PayPal_Standard_IPN_Handler extends WC_Gateway_Paypal_IPN_Handler {
/**
* Checks a set of args and derives an Order ID with backward compatibility for WC < 1.7 where 'custom' was the Order ID.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function get_order_id_and_key( $args, $order_type = 'shop_order', $meta_key = '_paypal_subscription_id' ) {
-
- $order_id = $order_key = '';
+ $order_id = '';
+ $order_key = '';
if ( isset( $args['subscr_id'] ) ) { // PayPal Standard IPN message
$subscription_id = $args['subscr_id'];
@@ -600,32 +600,36 @@ class WCS_PayPal_Standard_IPN_Handler extends WC_Gateway_Paypal_IPN_Handler {
// First try and get the order ID by the subscription ID
if ( ! empty( $subscription_id ) ) {
+ $orders = wcs_get_orders_with_meta_query(
+ [
+ 'limit' => 1,
+ 'orderby' => 'ID',
+ 'order' => 'ASC',
+ 'type' => $order_type,
+ 'status' => 'any',
+ 'meta_query' => [ // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
+ [
+ 'key' => $meta_key,
+ 'value' => $subscription_id,
+ 'compare' => '=',
+ ],
+ ],
+ ]
+ );
- $posts = get_posts( array(
- 'numberposts' => 1,
- 'orderby' => 'ID',
- 'order' => 'ASC',
- 'meta_key' => $meta_key,
- 'meta_value' => $subscription_id,
- 'post_type' => $order_type,
- 'post_status' => 'any',
- 'suppress_filters' => true,
- ) );
-
- if ( ! empty( $posts ) ) {
- $order_id = $posts[0]->ID;
- $order_key = get_post_meta( $order_id, '_order_key', true );
+ if ( ! empty( $orders ) ) {
+ $order_id = $orders[0]->get_id();
+ $order_key = $orders[0]->get_order_key();
}
}
// Couldn't find the order ID by subscr_id, so it's either not set on the order yet or the $args doesn't have a subscr_id (?!), either way, let's get it from the args
if ( empty( $order_id ) && isset( $args['custom'] ) ) {
-
$order_details = json_decode( $args['custom'] );
if ( is_object( $order_details ) ) { // WC 2.3.11+ converted the custom value to JSON, if we have an object, we've got valid JSON
- if ( 'shop_order' == $order_type ) {
+ if ( 'shop_order' === $order_type ) {
$order_id = $order_details->order_id;
$order_key = $order_details->order_key;
} elseif ( isset( $order_details->subscription_id ) ) {
@@ -638,8 +642,8 @@ class WCS_PayPal_Standard_IPN_Handler extends WC_Gateway_Paypal_IPN_Handler {
if ( ! empty( $subscriptions ) ) {
$subscription = array_pop( $subscriptions );
- $order_id = $subscription->get_id();
- $order_key = $subscription->get_order_key();
+ $order_id = $subscription->get_id();
+ $order_key = $subscription->get_order_key();
}
}
} else { // WC < 2.3.11, we could have a variety of payloads, but something has gone wrong if we got to here as we should only be here on new purchases where the '_paypal_subscription_id' is not already set, so throw an exception
@@ -677,7 +681,7 @@ class WCS_PayPal_Standard_IPN_Handler extends WC_Gateway_Paypal_IPN_Handler {
*
* @param WC_Subscription A subscription object
* @param string A PayPal Subscription Profile ID
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
protected static function cancel_subscription( $subscription, $old_paypal_subscriber_id ) {
@@ -702,7 +706,7 @@ class WCS_PayPal_Standard_IPN_Handler extends WC_Gateway_Paypal_IPN_Handler {
* Check for a valid transaction type
*
* @param string $txn_type
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
protected function validate_transaction_type( $txn_type ) {
if ( in_array( strtolower( $txn_type ), $this->get_transaction_types() ) ) {
@@ -718,7 +722,7 @@ class WCS_PayPal_Standard_IPN_Handler extends WC_Gateway_Paypal_IPN_Handler {
* @param string $note The text note
* @param WC_Order $order An order object
* @param array $transaction_details The transaction details, as provided by PayPal
- * @since 2.0.20
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.20
*/
protected function add_order_note( $note, $order, $transaction_details ) {
$note = apply_filters( 'wcs_paypal_ipn_note', $note, $order, $transaction_details );
@@ -735,7 +739,7 @@ class WCS_PayPal_Standard_IPN_Handler extends WC_Gateway_Paypal_IPN_Handler {
* @param array|string Order type we want. Defaults to any.
*
* @return WC_Order|null If order with that transaction id, WC_Order object, otherwise null
- * @since 2.4.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.4.3
*/
protected function get_order_by_transaction_id( $subscription, $transaction_id, $order_types = 'any' ) {
$orders = $subscription->get_related_orders( 'all', $order_types );
@@ -757,7 +761,7 @@ class WCS_PayPal_Standard_IPN_Handler extends WC_Gateway_Paypal_IPN_Handler {
* @param WC_Subscription object $subscription
* @param int $transaction_id Id from transaction details as provided by PayPal
* @return WC_Order|null If order with that transaction id, WC_Order object, otherwise null
- * @since 2.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1
*/
protected function get_renewal_order_by_transaction_id( $subscription, $transaction_id ) {
return self::get_order_by_transaction_id( $subscription, $transaction_id, 'renewal' );
@@ -770,7 +774,7 @@ class WCS_PayPal_Standard_IPN_Handler extends WC_Gateway_Paypal_IPN_Handler {
* @param int $transaction_id Id from transaction details as provided by PayPal
*
* @return WC_Order|null If order with that transaction id, WC_Order object, otherwise null
- * @since 2.4.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.4.3
*/
protected function get_parent_order_by_transaction_id( $subscription, $transaction_id ) {
return self::get_order_by_transaction_id( $subscription, $transaction_id, 'parent' );
diff --git a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-standard-request.php b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-standard-request.php
index 16d9322..cffa50c 100644
--- a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-standard-request.php
+++ b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-standard-request.php
@@ -8,7 +8,7 @@
* @subpackage Gateways/PayPal
* @category Class
* @author Prospress
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-standard-switcher.php b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-standard-switcher.php
index 6b456b1..d7c9caa 100644
--- a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-standard-switcher.php
+++ b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-standard-switcher.php
@@ -10,7 +10,7 @@
* @subpackage Gateways/PayPal
* @category Class
* @author Prospress
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -22,7 +22,7 @@ class WCS_PayPal_Standard_Switcher {
/**
* Bootstraps the class and hooks required actions & filters.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function init() {
@@ -52,7 +52,7 @@ class WCS_PayPal_Standard_Switcher {
* profile ID for PayPal Standard. However, PayPal Reference Transactions do allow these to be updated and because switching uses the checkout
* process, we can migrate a subscription from PayPal Standard to Reference Transactions when the customer switches, so we will allow that.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function can_item_be_switched( $item_can_be_switch, $item, $subscription ) {
@@ -152,7 +152,7 @@ class WCS_PayPal_Standard_Switcher {
*
* @param int $order_id
* @param array $posted
- * @since 2.0.15
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.15
*/
public static function save_old_paypal_meta( $order_id, $posted ) {
$order = wc_get_order( $order_id );
@@ -184,7 +184,7 @@ class WCS_PayPal_Standard_Switcher {
* Cancel subscriptions with PayPal Standard after the order has been successfully switched.
*
* @param WC_Order $order
- * @since 2.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1
*/
public static function cancel_paypal_standard_after_switch( $order ) {
@@ -222,7 +222,7 @@ class WCS_PayPal_Standard_Switcher {
/**
* Do not allow subscriptions to be switched using PayPal Standard as the payment method
*
- * @since 2.0.16
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.16
*/
public static function get_available_payment_gateways( $available_gateways ) {
@@ -245,7 +245,7 @@ class WCS_PayPal_Standard_Switcher {
* @param int $order_id
* @param string $old_status
* @param string $new_status
- * @since 2.0.15
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.15
*/
public static function maybe_cancel_paypal_after_switch( $order_id, $old_status, $new_status ) {
@@ -264,7 +264,7 @@ class WCS_PayPal_Standard_Switcher {
*
* Hooked onto 'wc_subscriptions_paypal_standard_suspension_note'. @see WCS_PayPal_Standard_Switcher::cancel_paypal_standard_after_switch()
*
- * @since 3.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
* @return string The note added to a subscription when the payment method changes from PayPal Standard to PayPal RT.
*/
public static function filter_suspended_switch_note() {
diff --git a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-status-manager.php b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-status-manager.php
index 220c9d3..8af66ea 100644
--- a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-status-manager.php
+++ b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-status-manager.php
@@ -6,7 +6,7 @@
* @subpackage Gateways/PayPal
* @category Class
* @author Prospress
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -18,7 +18,7 @@ class WCS_PayPal_Status_Manager extends WCS_PayPal {
/**
* Bootstraps the class and hooks required actions & filters.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function init() {
@@ -35,7 +35,7 @@ class WCS_PayPal_Status_Manager extends WCS_PayPal {
/**
* When a store manager or user cancels a subscription in the store, also cancel the subscription with PayPal.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function cancel_subscription( $subscription ) {
if ( ! wcs_is_paypal_profile_a( wcs_get_paypal_id( $subscription->get_id() ), 'billing_agreement' ) && self::update_subscription_status( $subscription, 'Cancel' ) ) {
@@ -46,7 +46,7 @@ class WCS_PayPal_Status_Manager extends WCS_PayPal {
/**
* When a store manager or user suspends a subscription in the store, also suspend the subscription with PayPal.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function suspend_subscription( $subscription ) {
if ( ! wcs_is_paypal_profile_a( wcs_get_paypal_id( $subscription->get_id() ), 'billing_agreement' ) && self::update_subscription_status( $subscription, 'Suspend' ) ) {
@@ -59,7 +59,7 @@ class WCS_PayPal_Status_Manager extends WCS_PayPal {
*
* How PayPal Handles suspension is discussed here: https://www.x.com/developers/paypal/forums/nvp/reactivate-recurring-profile
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function reactivate_subscription( $subscription ) {
if ( ! wcs_is_paypal_profile_a( wcs_get_paypal_id( $subscription->get_id() ), 'billing_agreement' ) && self::update_subscription_status( $subscription, 'Reactivate' ) ) {
@@ -73,7 +73,7 @@ class WCS_PayPal_Status_Manager extends WCS_PayPal {
* Although the PayPal Standard API provides no facility for cancelling a subscription, the PayPal
* Express Checkout NVP API can be used.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function update_subscription_status( $subscription, $new_status ) {
@@ -126,7 +126,7 @@ class WCS_PayPal_Status_Manager extends WCS_PayPal {
*
* @param string $status The subscription status sent to the current payment gateway before changing subscription payment method.
* @return object $subscription
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function suspend_subscription_on_payment_changed( $status, $subscription ) {
return ( 'paypal' == $subscription->get_payment_method() ) ? 'on-hold' : $status;
diff --git a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-supports.php b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-supports.php
index 094c914..e7846ab 100644
--- a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-supports.php
+++ b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/class-wcs-paypal-supports.php
@@ -11,7 +11,7 @@
* @subpackage Gateways/PayPal
* @category Class
* @author Prospress
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -41,7 +41,7 @@ class WCS_PayPal_Supports {
/**
* Bootstraps the class and hooks required actions & filters.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function init() {
@@ -58,7 +58,7 @@ class WCS_PayPal_Supports {
/**
* Add subscription support to the PayPal Standard gateway only when credentials are set
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function add_feature_support_for_gateway( $is_supported, $feature, $gateway ) {
@@ -78,7 +78,7 @@ class WCS_PayPal_Supports {
* Add additional feature support at the subscription level instead of just the gateway level because some subscriptions may have been
* setup with PayPal Standard while others may have been setup with Billing Agreements to use with Reference Transactions.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function add_feature_support_for_subscription( $is_supported, $feature, $subscription ) {
@@ -114,7 +114,7 @@ class WCS_PayPal_Supports {
/**
* Adds the payment gateway features supported by the type of billing the PayPal account supports (Reference Transactions or Standard).
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*
* @param array $features The list of features the payment gateway supports.
* @param WC_Payment_Gateway $gateway The payment gateway object.
diff --git a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/deprecated/class-wc-paypal-standard-subscriptions.php b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/deprecated/class-wc-paypal-standard-subscriptions.php
index e2398fc..55a7733 100644
--- a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/deprecated/class-wc-paypal-standard-subscriptions.php
+++ b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/deprecated/class-wc-paypal-standard-subscriptions.php
@@ -10,7 +10,7 @@
* @subpackage WC_PayPal_Standard_Subscriptions
* @category Class
* @author Brent Shepherd
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
class WC_PayPal_Standard_Subscriptions {
@@ -25,7 +25,7 @@ class WC_PayPal_Standard_Subscriptions {
/**
* Set the public properties to make sure we don't trigger any fatal errors even though the class is deprecated.
*
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function init() {
self::$api_username = WCS_PayPal::get_option( 'api_username' );
@@ -37,7 +37,7 @@ class WC_PayPal_Standard_Subscriptions {
/**
* Checks if the PayPal API credentials are set.
*
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function are_credentials_set() {
_deprecated_function( __METHOD__, '2.0', 'WCS_PayPal::are_credentials_set()' );
@@ -47,7 +47,7 @@ class WC_PayPal_Standard_Subscriptions {
/**
* Add subscription support to the PayPal Standard gateway only when credentials are set
*
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function add_paypal_standard_subscription_support( $is_supported, $feature, $gateway ) {
_deprecated_function( __METHOD__, '2.0', 'WCS_PayPal_Supports::add_feature_support( $is_supported, $feature, $gateway )' );
@@ -58,7 +58,7 @@ class WC_PayPal_Standard_Subscriptions {
* When a PayPal IPN messaged is received for a subscription transaction,
* check the transaction details and
*
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function process_paypal_ipn_request( $transaction_details ) {
_deprecated_function( __METHOD__, '2.0', 'WCS_PayPal::process_ipn_request( $transaction_details )' );
@@ -71,7 +71,7 @@ class WC_PayPal_Standard_Subscriptions {
* PayPal doesn't support subscriptions with a $0 recurring total, we need to circumvent it and
* manage it entirely ourselves.)
*
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function paypal_standard_subscription_args( $paypal_args, $order = '' ) {
_deprecated_function( __METHOD__, '2.0', 'WCS_PayPal_Standard_Request::get_paypal_args( $paypal_args, $order )' );
@@ -81,7 +81,7 @@ class WC_PayPal_Standard_Subscriptions {
/**
* Adds extra PayPal credential fields required to manage subscriptions.
*
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
public static function add_subscription_form_fields() {
_deprecated_function( __METHOD__, '2.0', 'WCS_PayPal_Admin::add_form_fields()' );
@@ -92,7 +92,7 @@ class WC_PayPal_Standard_Subscriptions {
* Returns a PayPal Subscription ID/Recurring Payment Profile ID based on a user ID and subscription key
*
* @param WC_Order|WC_Subscription A WC_Order object or child object (i.e. WC_Subscription)
- * @since 1.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.1
*/
public static function get_subscriptions_paypal_id( $order_id, $product_id = '' ) {
_deprecated_function( __METHOD__, '2.0', 'wcs_get_paypal_id( $order_id )' );
@@ -105,7 +105,7 @@ class WC_PayPal_Standard_Subscriptions {
* Although the PayPal Standard API provides no facility for cancelling a subscription, the PayPal
* Express Checkout NVP API can be used.
*
- * @since 1.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.1
*/
public static function change_subscription_status( $profile_id, $new_status, $order = null ) {
_deprecated_function( __METHOD__, '2.0', 'WCS_PayPal::get_api()->manage_recurring_payments_profile_status()' );
@@ -115,7 +115,7 @@ class WC_PayPal_Standard_Subscriptions {
/**
* Checks a set of args and derives an Order ID with backward compatibility for WC < 1.7 where 'custom' was the Order ID.
*
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function get_order_id_and_key( $args ) {
_deprecated_function( __METHOD__, '2.0', 'WCS_Paypal_Standard_IPN_Handler::get_order_id_and_key()' );
@@ -126,7 +126,7 @@ class WC_PayPal_Standard_Subscriptions {
* If changing a subscriptions payment method from and to PayPal, wait until an appropriate IPN message
* has come in before deciding to cancel the old subscription.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function maybe_remove_subscription_cancelled_callback( $subscription, $new_payment_method, $old_payment_method ) {
_deprecated_function( __METHOD__, '2.0' );
@@ -136,7 +136,7 @@ class WC_PayPal_Standard_Subscriptions {
* If changing a subscriptions payment method from and to PayPal, the cancelled subscription hook was removed in
* @see self::maybe_remove_cancelled_subscription_hook() so we want to add it again for other subscriptions.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function maybe_reattach_subscription_cancelled_callback( $subscription, $new_payment_method, $old_payment_method ) {
_deprecated_function( __METHOD__, '2.0' );
@@ -147,7 +147,7 @@ class WC_PayPal_Standard_Subscriptions {
*
* @param string $item_name
* @return string
- * @since 1.5.14
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5.14
*/
public static function maybe_dont_update_payment_method( $update, $new_payment_method ) {
_deprecated_function( __METHOD__, '2.0' );
@@ -157,7 +157,7 @@ class WC_PayPal_Standard_Subscriptions {
/**
* In typical PayPal style, there are a couple of important limitations we need to work around:
*
- * @since 1.4.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4.3
*/
public static function scheduled_subscription_payment() {
_deprecated_function( __METHOD__, '2.0' );
@@ -176,7 +176,7 @@ class WC_PayPal_Standard_Subscriptions {
/**
* When a store manager or user cancels a subscription in the store, also cancel the subscription with PayPal.
*
- * @since 1.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.1
*/
public static function cancel_subscription_with_paypal( $order, $product_id = '', $profile_id = '' ) {
_deprecated_function( __METHOD__, '2.0', 'WCS_PayPal_Status_Manager::cancel_subscription( $subscription )' );
@@ -188,7 +188,7 @@ class WC_PayPal_Standard_Subscriptions {
/**
* When a store manager or user suspends a subscription in the store, also suspend the subscription with PayPal.
*
- * @since 1.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.1
*/
public static function suspend_subscription_with_paypal( $order, $product_id ) {
_deprecated_function( __METHOD__, '2.0', 'WCS_PayPal_Status_Manager::suspend_subscription( $subscription )' );
@@ -202,7 +202,7 @@ class WC_PayPal_Standard_Subscriptions {
*
* How PayPal Handles suspension is discussed here: https://www.x.com/developers/paypal/forums/nvp/reactivate-recurring-profile
*
- * @since 1.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.1
*/
public static function reactivate_subscription_with_paypal( $order, $product_id ) {
_deprecated_function( __METHOD__, '2.0', 'WCS_PayPal::reactivate_subscription( $subscription )' );
@@ -245,7 +245,7 @@ class WC_PayPal_Standard_Subscriptions {
* If changing a subscriptions payment method from and to PayPal, wait until an appropriate IPN message
* has come in before deciding to cancel the old subscription.
*
- * @since 1.4.6
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4.6
*/
public static function maybe_remove_cancelled_subscription_hook( $order, $subscription_key, $new_payment_method, $old_payment_method ) {
_deprecated_function( __METHOD__, '2.0' );
@@ -255,7 +255,7 @@ class WC_PayPal_Standard_Subscriptions {
* If changing a subscriptions payment method from and to PayPal, the cancelled subscription hook was removed in
* @see self::maybe_remove_cancelled_subscription_hook() so we want to add it again for other subscriptions.
*
- * @since 1.4.6
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4.6
*/
public static function maybe_readd_cancelled_subscription_hook( $order, $subscription_key, $new_payment_method, $old_payment_method ) {
_deprecated_function( __METHOD__, '2.0' );
@@ -264,7 +264,7 @@ class WC_PayPal_Standard_Subscriptions {
/**
* Takes a timestamp for a date in the future and calculates the number of days between now and then
*
- * @since 1.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4
*/
public static function calculate_trial_periods_until( $future_timestamp ) {
_deprecated_function( __METHOD__, '2.0', 'wcs_calculate_paypal_trial_periods_until()' );
diff --git a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/templates/admin-notices.php b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/templates/admin-notices.php
index 663fe6b..1ebd862 100644
--- a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/templates/admin-notices.php
+++ b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/templates/admin-notices.php
@@ -6,7 +6,7 @@
* @subpackage Gateways/PayPal
* @category Class
* @author Prospress
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/templates/html-ipn-failure-notice.php b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/templates/html-ipn-failure-notice.php
index 09df39c..eb713b7 100644
--- a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/templates/html-ipn-failure-notice.php
+++ b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/templates/html-ipn-failure-notice.php
@@ -2,7 +2,7 @@
/**
* The template for displaying an admin notice to report fatal errors which ocurred while processing PayPal IPNs.
*
- * @version 2.4.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.4.0
* @var string $last_ipn_error
*/
diff --git a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/wcs-paypal-functions.php b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/wcs-paypal-functions.php
index b486bcc..7f48c9b 100644
--- a/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/wcs-paypal-functions.php
+++ b/vendor/woocommerce/subscriptions-core/includes/gateways/paypal/includes/wcs-paypal-functions.php
@@ -7,7 +7,7 @@
* @package WooCommerce Subscriptions
* @subpackage Gateways/PayPal
* @author Brent Shepherd
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -18,7 +18,7 @@ if ( ! defined( 'ABSPATH' ) ) {
* Returns a PayPal Subscription ID or Billing Agreement ID use to process payment for a given subscription or order.
*
* @param int The ID of a WC_Order or WC_Subscription object
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_get_paypal_id( $order ) {
@@ -34,7 +34,7 @@ function wcs_get_paypal_id( $order ) {
*
* @param int|object A WC_Order or WC_Subscription object or the ID of a WC_Order or WC_Subscription object
* @param string A PayPal Standard Subscription ID or Express Checkout Billing Agreement ID
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_set_paypal_id( $order, $paypal_subscription_id ) {
@@ -62,7 +62,7 @@ function wcs_set_paypal_id( $order, $paypal_subscription_id ) {
*
* @param string $profile_id A PayPal Standard Subscription ID or Express Checkout Billing Agreement ID
* @param string $profile_type A type of profile ID, can be 'billing_agreement' or 'old_id'.
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_is_paypal_profile_a( $profile_id, $profile_type ) {
@@ -82,7 +82,7 @@ function wcs_is_paypal_profile_a( $profile_id, $profile_type ) {
*
* @param string $item_name
* @return string
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_get_paypal_item_name( $item_name ) {
@@ -95,7 +95,7 @@ function wcs_get_paypal_item_name( $item_name ) {
/**
* Takes a timestamp for a date in the future and calculates the number of days between now and then
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_calculate_paypal_trial_periods_until( $future_timestamp ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/interfaces/interface-wcs-cache-updater.php b/vendor/woocommerce/subscriptions-core/includes/interfaces/interface-wcs-cache-updater.php
index 9e6dc01..0de85a4 100644
--- a/vendor/woocommerce/subscriptions-core/includes/interfaces/interface-wcs-cache-updater.php
+++ b/vendor/woocommerce/subscriptions-core/includes/interfaces/interface-wcs-cache-updater.php
@@ -7,8 +7,8 @@
* @author Prospress
* @category Admin
* @package WooCommerce Subscriptions/Admin
- * @version 2.3
- * @since 2.3
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.3
*/
if ( ! defined( 'ABSPATH' ) ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/legacy/class-wc-product-subscription-legacy.php b/vendor/woocommerce/subscriptions-core/includes/legacy/class-wc-product-subscription-legacy.php
index 35af309..8c8a3c5 100644
--- a/vendor/woocommerce/subscriptions-core/includes/legacy/class-wc-product-subscription-legacy.php
+++ b/vendor/woocommerce/subscriptions-core/includes/legacy/class-wc-product-subscription-legacy.php
@@ -7,7 +7,7 @@
* @class WC_Product_Subscription_Legacy
* @package WooCommerce Subscriptions
* @category Class
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*
*/
if ( ! defined( 'ABSPATH' ) ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/legacy/class-wc-product-subscription-variation-legacy.php b/vendor/woocommerce/subscriptions-core/includes/legacy/class-wc-product-subscription-variation-legacy.php
index 3f47885..9616afc 100644
--- a/vendor/woocommerce/subscriptions-core/includes/legacy/class-wc-product-subscription-variation-legacy.php
+++ b/vendor/woocommerce/subscriptions-core/includes/legacy/class-wc-product-subscription-variation-legacy.php
@@ -7,7 +7,7 @@
* @class WC_Product_Subscription_Variation_Legacy
* @package WooCommerce Subscriptions
* @category Class
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*
*/
if ( ! defined( 'ABSPATH' ) ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/legacy/class-wc-product-variable-subscription-legacy.php b/vendor/woocommerce/subscriptions-core/includes/legacy/class-wc-product-variable-subscription-legacy.php
index be63903..623afb6 100644
--- a/vendor/woocommerce/subscriptions-core/includes/legacy/class-wc-product-variable-subscription-legacy.php
+++ b/vendor/woocommerce/subscriptions-core/includes/legacy/class-wc-product-variable-subscription-legacy.php
@@ -7,7 +7,7 @@
* @class WC_Product_Variable_Subscription_Legacy
* @package WooCommerce Subscriptions
* @category Class
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -122,7 +122,7 @@ class WC_Product_Variable_Subscription_Legacy extends WC_Product_Variable_Subscr
* @see WC_Product_Variable::get_variation_prices()
* @param bool $include_taxes Should taxes be included in the prices.
* @return array() Array of RAW prices, regular prices, and sale prices with keys set to variation ID.
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
public function get_variation_prices( $display = false ) {
@@ -176,7 +176,7 @@ class WC_Product_Variable_Subscription_Legacy extends WC_Product_Variable_Subscr
* Create unique cache key based on the tax location (affects displayed/cached prices), product version and active price filters.
* DEVELOPERS should filter this hash if offering conditonal pricing to keep it unique.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @param WC_Product
* @param bool $display Are prices for display? If so, taxes will be calculated.
* @return string
@@ -379,7 +379,7 @@ class WC_Product_Variable_Subscription_Legacy extends WC_Product_Variable_Subscr
/**
* Get default attributes.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @param string $context
* @return array
*/
@@ -392,7 +392,7 @@ class WC_Product_Variable_Subscription_Legacy extends WC_Product_Variable_Subscr
*
* @param array $min_and_max_data The min and max variation data returned by @see wcs_get_min_max_variation_data(). Optional.
* @param array $variation_ids The visible child variation IDs. Optional. By default this value be generated by @see WC_Product_Variable->get_children( true ).
- * @since 2.3.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.0
*/
public function set_min_and_max_variation_data( $min_and_max_data = array(), $variation_ids = array() ) {
@@ -417,7 +417,7 @@ class WC_Product_Variable_Subscription_Legacy extends WC_Product_Variable_Subscr
*
* @param array $variation_ids An array of variation IDs.
* @return array The variable product's min and max variation data.
- * @since 2.3.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.0
*/
public function get_min_and_max_variation_data( $variation_ids ) {
$variation_ids_hash = $this->get_variation_ids_hash( $variation_ids );
diff --git a/vendor/woocommerce/subscriptions-core/includes/legacy/class-wc-subscription-legacy.php b/vendor/woocommerce/subscriptions-core/includes/legacy/class-wc-subscription-legacy.php
index 2107a3f..4a98569 100644
--- a/vendor/woocommerce/subscriptions-core/includes/legacy/class-wc-subscription-legacy.php
+++ b/vendor/woocommerce/subscriptions-core/includes/legacy/class-wc-subscription-legacy.php
@@ -5,7 +5,7 @@
* Extends WC_Subscription to provide WC 3.0 methods when running WooCommerce < 3.0.
*
* @class WC_Subscription_Legacy
- * @version 2.1
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.1
* @package WooCommerce Subscriptions/Classes
* @category Class
* @author Brent Shepherd
@@ -64,7 +64,7 @@ class WC_Subscription_Legacy extends WC_Subscription {
/**
* Get parent order ID.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @return int
*/
public function get_parent_id() {
@@ -325,7 +325,7 @@ class WC_Subscription_Legacy extends WC_Subscription {
/**
* Get order key.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @param string $context
* @return string
*/
@@ -387,7 +387,7 @@ class WC_Subscription_Legacy extends WC_Subscription {
* @param array|int Either an order item (in the array format returned by self::get_items()) or the ID of an order item.
* @param string $tax_inclusive_or_exclusive Whether or not to adjust sign up fee if prices inc tax - ensures that the sign up fee paid amount includes the paid tax if inc
* @return bool
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public function get_items_sign_up_fee( $line_item, $tax_inclusive_or_exclusive = 'exclusive_of_tax' ) {
@@ -526,7 +526,7 @@ class WC_Subscription_Legacy extends WC_Subscription {
* Set parent order ID. We don't use WC_Abstract_Order::set_parent_id() because we want to allow false
* parent IDs, like 0.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @param int $value
*/
public function set_parent_id( $value ) {
@@ -620,7 +620,7 @@ class WC_Subscription_Legacy extends WC_Subscription {
/**
* Set a certain date type for the last order on the subscription.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @param string $date_type
* @param string|integer|object
* @return WC_DateTime|NULL object if the date is set or null if there is no date.
@@ -751,7 +751,7 @@ class WC_Subscription_Legacy extends WC_Subscription {
/**
* Update meta data by key or ID, if provided.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @param string $key
* @param string $value
* @param int $meta_id
@@ -768,7 +768,7 @@ class WC_Subscription_Legacy extends WC_Subscription {
* Save subscription date changes to the database.
* Nothing to do here as all date properties are saved when calling @see $this->set_prop().
*
- * @since 2.2.6
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.6
*/
public function save_dates() {
// Nothing to do here.
diff --git a/vendor/woocommerce/subscriptions-core/includes/legacy/class-wcs-array-property-post-meta-black-magic.php b/vendor/woocommerce/subscriptions-core/includes/legacy/class-wcs-array-property-post-meta-black-magic.php
index 5a235df..268ff3e 100644
--- a/vendor/woocommerce/subscriptions-core/includes/legacy/class-wcs-array-property-post-meta-black-magic.php
+++ b/vendor/woocommerce/subscriptions-core/includes/legacy/class-wcs-array-property-post-meta-black-magic.php
@@ -15,7 +15,7 @@
*
* @package WooCommerce Subscriptions
* @category Class
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*
*/
if ( ! defined( 'ABSPATH' ) ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/legacy/class-wcs-product-legacy.php b/vendor/woocommerce/subscriptions-core/includes/legacy/class-wcs-product-legacy.php
index bcd785b..db925fb 100644
--- a/vendor/woocommerce/subscriptions-core/includes/legacy/class-wcs-product-legacy.php
+++ b/vendor/woocommerce/subscriptions-core/includes/legacy/class-wcs-product-legacy.php
@@ -8,14 +8,14 @@
* @package WooCommerce Subscriptions
* @subpackage WCS_Product_Legacy
* @category Class
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
class WCS_Product_Legacy {
/**
* Set up the class, including it's hooks & filters, when the file is loaded.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
**/
public static function init() {
@@ -27,7 +27,7 @@ class WCS_Product_Legacy {
* Use legacy classes for WC < 3.0
*
* @return string $classname The name of the WC_Product_* class which should be instantiated to create an instance of this product.
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
public static function set_product_class( $classname, $product_type, $post_type, $product_id ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/privacy/class-wcs-privacy-background-updater.php b/vendor/woocommerce/subscriptions-core/includes/privacy/class-wcs-privacy-background-updater.php
index ce7e186..8018b2c 100644
--- a/vendor/woocommerce/subscriptions-core/includes/privacy/class-wcs-privacy-background-updater.php
+++ b/vendor/woocommerce/subscriptions-core/includes/privacy/class-wcs-privacy-background-updater.php
@@ -5,7 +5,7 @@
* @author Prospress
* @category Class
* @package WooCommerce Subscriptions\Privacy
- * @version 2.2.20
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.20
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -41,7 +41,7 @@ class WCS_Privacy_Background_Updater {
/**
* Schedule ended subscription anonymization, if it's not already scheduled.
*
- * @since 2.2.20
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.20
*/
public function schedule_ended_subscription_anonymization() {
if ( false === as_next_scheduled_action( $this->ended_subscription_anonymization_hook ) ) {
@@ -52,7 +52,7 @@ class WCS_Privacy_Background_Updater {
/**
* Unschedule the ended subscription anonymization hook.
*
- * @since 2.2.20
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.20
*/
protected function unschedule_ended_subscription_anonymization() {
as_unschedule_action( $this->ended_subscription_anonymization_hook );
@@ -61,7 +61,7 @@ class WCS_Privacy_Background_Updater {
/**
* Schedule subscription related order anonymization, if it's not already scheduled.
*
- * @since 2.2.20
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.20
* @param int The subscription ID.
*/
protected function schedule_subscription_orders_anonymization( $subscription_id ) {
@@ -75,7 +75,7 @@ class WCS_Privacy_Background_Updater {
/**
* Unschedule a specific subscription's related order anonymization hook.
*
- * @since 2.2.20
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.20
* @param int The subscription ID.
*/
protected function unschedule_subscription_orders_anonymization( $subscription_id ) {
@@ -85,7 +85,7 @@ class WCS_Privacy_Background_Updater {
/**
* Schedule a specific order's anonymization action.
*
- * @since 2.2.20
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.20
* @param int The order ID.
*/
protected function schedule_order_anonymization( $order_id ) {
@@ -95,7 +95,7 @@ class WCS_Privacy_Background_Updater {
/**
* Check if an order has a scheduled anonymization action.
*
- * @since 2.2.20
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.20
* @param int The order ID.
* @return bool Wether the order has a scheduled anonymization action.
*/
@@ -106,7 +106,7 @@ class WCS_Privacy_Background_Updater {
/**
* Anonymize old ended subscriptions.
*
- * @since 2.2.20
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.20
*/
public function anonymize_ended_subscriptions() {
$option = wc_parse_relative_date_option( get_option( 'woocommerce_anonymize_ended_subscriptions' ) );
@@ -156,7 +156,7 @@ class WCS_Privacy_Background_Updater {
/**
* Schedule related order anonymization events for a specific subscription.
*
- * @since 2.2.20
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.20
*/
public function schedule_subscription_orders_anonymization_events( $subscription_id ) {
$subscription = wcs_get_subscription( $subscription_id );
@@ -210,7 +210,7 @@ class WCS_Privacy_Background_Updater {
* Anonymize an order.
*
* @param int The ID of the order to be anonymized.
- * @since 2.2.20
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.20
*/
public function anonymize_order( $order_id ) {
$order = wc_get_order( $order_id );
diff --git a/vendor/woocommerce/subscriptions-core/includes/privacy/class-wcs-privacy-erasers.php b/vendor/woocommerce/subscriptions-core/includes/privacy/class-wcs-privacy-erasers.php
index 23fb080..d54886e 100644
--- a/vendor/woocommerce/subscriptions-core/includes/privacy/class-wcs-privacy-erasers.php
+++ b/vendor/woocommerce/subscriptions-core/includes/privacy/class-wcs-privacy-erasers.php
@@ -5,7 +5,7 @@
* @author Prospress
* @category Class
* @package WooCommerce Subscriptions\Privacy
- * @version 2.2.20
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.20
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -20,7 +20,7 @@ class WCS_Privacy_Erasers {
* Subscriptions are erased in blocks of 10 to avoid timeouts.
* Based on @see WC_Privacy_Erasers::order_data_eraser().
*
- * @since 2.2.20
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.20
* @param string $email_address The user email address.
* @param int $page Page.
* @return array An array of response data to return to the WP eraser.
@@ -48,7 +48,7 @@ class WCS_Privacy_Erasers {
/**
* Erase personal data from an array of subscriptions and generate an eraser response.
*
- * @since 2.2.20
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.20
* @param array $subscriptions An array of WC_Subscription objects.
* @param int $limit The number of subscriptions erased in each batch. Optional. Default is 10.
* @return array An array of response data to return to the WP eraser.
@@ -88,7 +88,7 @@ class WCS_Privacy_Erasers {
*
* Note; this will hinder the subscription's ability function correctly for obvious reasons!
*
- * @since 2.2.20
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.20
* @param WC_Subscription $subscription $subscription object.
*/
public static function remove_subscription_personal_data( $subscription ) {
@@ -97,7 +97,7 @@ class WCS_Privacy_Erasers {
/**
* Allow extensions to remove their own personal data for this subscription first, so subscription data is still available.
*
- * @since 2.2.20
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.20
* @param WC_Subscription $subscription A Subscription object.
*/
do_action( 'woocommerce_privacy_before_remove_subscription_personal_data', $subscription );
@@ -110,7 +110,7 @@ class WCS_Privacy_Erasers {
/**
* Expose props and data types we'll be anonymizing.
*
- * @since 2.2.20
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.20
* @param array $props Keys are the prop names, values are the data type we'll be passing to wp_privacy_anonymize_data().
* @param WC_subscription $subscription A subscription object.
*/
@@ -160,7 +160,7 @@ class WCS_Privacy_Erasers {
/**
* Expose a way to control the anonymized value of a prop via 3rd party code.
*
- * @since 2.2.20
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.20
* @param bool $anonymized_data Value of this prop after anonymization.
* @param string $prop Name of the prop being removed.
* @param string $value Current value of the data.
@@ -191,7 +191,7 @@ class WCS_Privacy_Erasers {
/**
* Allow extensions to remove their own personal data for this subscription.
*
- * @since 2.2.20
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.20
* @param WC_subscription $subscription A subscription object.
*/
do_action( 'woocommerce_privacy_remove_subscription_personal_data', $subscription );
diff --git a/vendor/woocommerce/subscriptions-core/includes/privacy/class-wcs-privacy-exporters.php b/vendor/woocommerce/subscriptions-core/includes/privacy/class-wcs-privacy-exporters.php
index 1601ebf..b78eb79 100644
--- a/vendor/woocommerce/subscriptions-core/includes/privacy/class-wcs-privacy-exporters.php
+++ b/vendor/woocommerce/subscriptions-core/includes/privacy/class-wcs-privacy-exporters.php
@@ -5,7 +5,7 @@
* @author Prospress
* @category Class
* @package WooCommerce Subscriptions\Privacy
- * @version 2.2.20
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.20
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -23,7 +23,7 @@ class WCS_Privacy_Exporters {
* @param string $email_address The user email address.
* @param int $page Page.
* @return array An array of personal data in name value pairs
- * @since 2.2.20
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.20
*/
public static function subscription_data_exporter( $email_address, $page ) {
$done = false;
@@ -67,7 +67,7 @@ class WCS_Privacy_Exporters {
/**
* Get personal data (key/value pairs) for an subscription object.
*
- * @since 2.2.20
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.20
* @param WC_Subscription $subscription Subscription object.
* @return array
*/
@@ -124,7 +124,7 @@ class WCS_Privacy_Exporters {
/**
* Allow extensions to register their own personal data for this subscription for the export.
*
- * @since 2.2.20
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.20
* @param array $personal_data Array of name value pairs to expose in the export.
* @param WC_Subscription $subscription A subscription object.
*/
diff --git a/vendor/woocommerce/subscriptions-core/includes/privacy/class-wcs-privacy.php b/vendor/woocommerce/subscriptions-core/includes/privacy/class-wcs-privacy.php
index 5aad2d9..be9fe8d 100644
--- a/vendor/woocommerce/subscriptions-core/includes/privacy/class-wcs-privacy.php
+++ b/vendor/woocommerce/subscriptions-core/includes/privacy/class-wcs-privacy.php
@@ -5,7 +5,7 @@
* @author Prospress
* @category Class
* @package WooCommerce Subscriptions\Privacy
- * @version 2.2.20
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.20
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -51,7 +51,7 @@ class WCS_Privacy extends WC_Abstract_Privacy {
parent::init();
self::$background_process->init();
- add_filter( 'woocommerce_subscription_bulk_actions', array( __CLASS__, 'add_remove_personal_data_bulk_action' ) );
+ add_filter( 'woocommerce_subscription_bulk_actions', array( __CLASS__, 'add_privacy_bulk_action' ) );
add_action( 'load-edit.php', array( __CLASS__, 'process_bulk_action' ) );
add_action( 'woocommerce_remove_subscription_personal_data', array( 'WCS_Privacy_Erasers', 'remove_subscription_personal_data' ) );
add_action( 'admin_notices', array( __CLASS__, 'bulk_admin_notices' ) );
@@ -71,12 +71,14 @@ class WCS_Privacy extends WC_Abstract_Privacy {
add_filter( 'woocommerce_delete_inactive_account_roles', array( __CLASS__, 'flag_subscription_user_exclusion_from_query' ), 1000 );
add_action( 'pre_get_users', array( __CLASS__, 'maybe_exclude_subscription_customers' ) );
add_filter( 'woocommerce_account_settings', array( __CLASS__, 'add_inactive_user_retention_note' ) );
+
+ add_action( 'handle_bulk_actions-woocommerce_page_wc-orders--shop_subscription', [ __CLASS__, 'handle_privacy_bulk_actions' ], 10, 3 );
}
/**
* Spawn events for subscription cleanup.
*
- * @since 2.2.20
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.20
*/
public function queue_cleanup_personal_data() {
self::$background_process->schedule_ended_subscription_anonymization();
@@ -85,7 +87,7 @@ class WCS_Privacy extends WC_Abstract_Privacy {
/**
* Add privacy policy content for the privacy policy page.
*
- * @since 2.2.20
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.20
*/
public function get_privacy_message() {
return '' .
@@ -100,48 +102,37 @@ class WCS_Privacy extends WC_Abstract_Privacy {
}
/**
- * Add the option to remove personal data from subscription via a bulk action.
+ * Adds the option to remove personal data from subscription via a bulk action.
+ *
+ * @since 5.2.0
*
- * @since 2.2.20
* @param array $bulk_actions Subscription bulk actions.
+ *
+ * @return array
*/
- public static function add_remove_personal_data_bulk_action( $bulk_actions ) {
- $bulk_actions['remove_personal_data'] = __( 'Cancel and remove personal data', 'woocommerce-subscriptions' );
+ public static function add_privacy_bulk_action( $bulk_actions ) {
+ $bulk_actions['wcs_remove_personal_data'] = __( 'Cancel and remove personal data', 'woocommerce-subscriptions' );
return $bulk_actions;
}
/**
- * Process the request to delete personal data from subscriptions via admin bulk action.
+ * Handles the Remove Personal Data bulk action requests for Subscriptions.
*
- * @since 2.2.20
+ * @param string $redirect_url The default URL to redirect to after handling the bulk action request.
+ * @param string $action The action to take against the list of subscriptions.
+ * @param array $subscription_ids The list of subscription to run the action against.
*/
- public static function process_bulk_action() {
-
- // We only want to deal with shop_subscription bulk actions.
- if ( ! isset( $_REQUEST['post_type'] ) || 'shop_subscription' !== $_REQUEST['post_type'] || ! isset( $_REQUEST['post'] ) ) {
+ public static function handle_privacy_bulk_actions( $redirect_url, $action, $subscription_ids ) {
+ if ( 'wcs_remove_personal_data' !== $action ) {
return;
}
- $action = '';
-
- if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] ) {
- $action = $_REQUEST['action'];
- } else if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] ) {
- $action = $_REQUEST['action2'];
- }
-
- if ( 'remove_personal_data' !== $action ) {
- return;
- }
-
- $subscription_ids = array_map( 'absint', (array) $_REQUEST['post'] );
- $changed = 0;
- $sendback_args = array(
- 'post_type' => 'shop_subscription',
- 'bulk_action' => 'remove_personal_data',
+ $changed = 0;
+ $sendback_args = [
+ 'bulk_action' => 'wcs_remove_personal_data',
'ids' => join( ',', $subscription_ids ),
'error_count' => 0,
- );
+ ];
foreach ( $subscription_ids as $subscription_id ) {
$subscription = wcs_get_subscription( $subscription_id );
@@ -153,21 +144,64 @@ class WCS_Privacy extends WC_Abstract_Privacy {
}
$sendback_args['changed'] = $changed;
- $sendback = add_query_arg( $sendback_args, wp_get_referer() ? wp_get_referer() : '' );
+ $sendback = add_query_arg( $sendback_args, $redirect_url );
wp_safe_redirect( esc_url_raw( $sendback ) );
exit();
}
+ /**
+ * Process the request to delete personal data from subscriptions via admin bulk action.
+ *
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.20
+ */
+ public static function process_bulk_action() {
+ /**
+ * We only want to deal with shop_subscription bulk actions.
+ *
+ * Note: The nonce checks are ignored below as we are validating the request before returning.
+ */
+ if ( ! isset( $_REQUEST['post_type'] ) || 'shop_subscription' !== $_REQUEST['post_type'] || ! isset( $_REQUEST['post'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ return;
+ }
+
+ check_admin_referer( 'bulk-posts' );
+
+ $action = '';
+
+ if ( isset( $_REQUEST['action'] ) && -1 !== $_REQUEST['action'] ) {
+ $action = wc_clean( wp_unslash( $_REQUEST['action'] ) );
+ } elseif ( isset( $_REQUEST['action2'] ) && -1 !== $_REQUEST['action2'] ) {
+ $action = wc_clean( wp_unslash( $_REQUEST['action2'] ) );
+ }
+
+ $subscription_ids = array_map( 'absint', (array) $_REQUEST['post'] );
+ $base_redirect_url = wp_get_referer() ? wp_get_referer() : '';
+
+ self::handle_privacy_bulk_actions( $base_redirect_url, $action, $subscription_ids );
+ }
+
/**
* Add admin notice after processing personal data removal bulk action.
*
- * @since 2.2.20
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.20
*/
public static function bulk_admin_notices() {
- global $post_type, $pagenow;
+ // Nonce verification is not required here because we're just displaying an admin notice after a verified request was made.
+ if ( ! isset( $_REQUEST['bulk_action'] ) || ! 'wcs_remove_personal_data' === wc_clean( wp_unslash( $_REQUEST['bulk_action'] ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ return;
+ }
- if ( 'edit.php' !== $pagenow || 'shop_subscription' !== $post_type || ! isset( $_REQUEST['bulk_action'] ) || 'remove_personal_data' !== wc_clean( $_REQUEST['bulk_action'] ) ) {
+ if ( wcs_is_custom_order_tables_usage_enabled() ) {
+ $current_screen = get_current_screen();
+ $is_subscription_list_table = $current_screen && wcs_get_page_screen_id( 'shop_subscription' ) === $current_screen->id;
+ } else {
+ global $post_type, $pagenow;
+ $is_subscription_list_table = 'edit.php' === $pagenow && 'shop_subscription' === $post_type;
+ }
+
+ // Bail out if not on shop subscription list page.
+ if ( ! $is_subscription_list_table ) {
return;
}
@@ -180,7 +214,7 @@ class WCS_Privacy extends WC_Abstract_Privacy {
/**
* Add a note to WC Personal Data Retention settings explaining that subscription orders aren't affected.
*
- * @since 2.2.20
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.20
* @param array $settings WooCommerce Account and Privacy settings.
* @return array Account and Privacy settings.
*/
@@ -203,7 +237,7 @@ class WCS_Privacy extends WC_Abstract_Privacy {
/**
* Add admin setting to turn subscription data removal when processing erasure requests on or off.
*
- * @since 2.2.20
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.20
* @param array $settings WooCommerce Account and Privacy settings.
* @return array Account and Privacy settings.
*/
@@ -247,7 +281,7 @@ class WCS_Privacy extends WC_Abstract_Privacy {
/**
* Remove subscription related order types from the order anonymization query.
*
- * @since 2.2.20
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.20
* @param array $query_args @see wc_get_orders() args.
* @return array The args used to get orders to anonymize.
*/
@@ -267,7 +301,7 @@ class WCS_Privacy extends WC_Abstract_Privacy {
/**
* Add a note to the inactive user data retention setting noting that users with a subscription are excluded.
*
- * @since 2.3.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.4
* @param array $settings WooCommerce Account and Privacy settings.
* @return array Account and Privacy settings.
*/
@@ -285,7 +319,7 @@ class WCS_Privacy extends WC_Abstract_Privacy {
/**
* Set a flag to record inactive user account deletion.
*
- * @since 2.3.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.4
* @param array $user_roles The user roles included in the inactive user query.
* @return array
*/
@@ -297,7 +331,7 @@ class WCS_Privacy extends WC_Abstract_Privacy {
/**
* Exclude customers who have subscriptions from the inactive user cleanup query.
*
- * @since 2.3.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.4
* @param WP_User_Query $user_query
*/
public static function maybe_exclude_subscription_customers( $user_query ) {
@@ -312,4 +346,19 @@ class WCS_Privacy extends WC_Abstract_Privacy {
self::$doing_user_inactivity_query = false;
}
+
+ /* Deprecated Functions */
+
+ /**
+ * Add the option to remove personal data from subscription via a bulk action.
+ *
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.20
+ * @param array $bulk_actions Subscription bulk actions.
+ */
+ public static function add_remove_personal_data_bulk_action( $bulk_actions ) {
+ wcs_deprecated_function( __METHOD__, 'subscriptions-core 5.2.0', 'WCS_Privacy_Exporters::add_privacy_bulk_action' );
+ $bulk_actions['remove_personal_data'] = __( 'Cancel and remove personal data', 'woocommerce-subscriptions' );
+
+ return $bulk_actions;
+ }
}
diff --git a/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wc-subscriptions-upgrader.php b/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wc-subscriptions-upgrader.php
index c94e5e2..9bbc6d2 100644
--- a/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wc-subscriptions-upgrader.php
+++ b/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wc-subscriptions-upgrader.php
@@ -11,8 +11,8 @@
* @author Prospress
* @category Admin
* @package WooCommerce Subscriptions/Admin/Upgrades
- * @version 2.0.0
- * @since 1.2
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
class WC_Subscriptions_Upgrader {
@@ -38,7 +38,7 @@ class WC_Subscriptions_Upgrader {
/**
* Hooks upgrade function to init.
*
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function init() {
@@ -48,7 +48,7 @@ class WC_Subscriptions_Upgrader {
self::$about_page_url = admin_url( 'admin.php?page=wc-admin' );
- $version_out_of_date = version_compare( self::$active_version, WC_Subscriptions_Core_Plugin::instance()->get_plugin_version(), '<' );
+ $version_out_of_date = version_compare( self::$active_version, WC_Subscriptions_Core_Plugin::instance()->get_library_version(), '<' );
// Set the cron lock on every request with an out of date version, regardless of authentication level, as we can only lock cron for up to 10 minutes at a time, but we need to keep it locked until the upgrade is complete, regardless of who is browing the site
if ( $version_out_of_date ) {
@@ -111,7 +111,7 @@ class WC_Subscriptions_Upgrader {
*
* The size of subscription at the time the upgrade is started is used to determine the batch size.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
protected static function set_upgrade_limits() {
@@ -133,7 +133,7 @@ class WC_Subscriptions_Upgrader {
* Try to block WP-Cron until upgrading finishes. spawn_cron() will only let us steal the lock for 10 minutes into the future, so
* we can actually only block it for 9 minutes confidently. But as long as the upgrade process continues, the lock will remain.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
protected static function set_cron_lock() {
delete_transient( 'doing_cron' );
@@ -143,7 +143,7 @@ class WC_Subscriptions_Upgrader {
/**
* Checks which upgrades need to run and calls the necessary functions for that upgrade.
*
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function upgrade() {
global $wpdb;
@@ -155,7 +155,7 @@ class WC_Subscriptions_Upgrader {
/**
* before upgrade hook.
*/
- do_action( 'woocommerce_subscriptions_before_upgrade', WC_Subscriptions_Core_Plugin::instance()->get_plugin_version(), self::$active_version );
+ do_action( 'woocommerce_subscriptions_before_upgrade', WC_Subscriptions_Core_Plugin::instance()->get_library_version(), self::$active_version );
// Update the hold stock notification to be one week (if it's still at the default 60 minutes) to prevent cancelling subscriptions using manual renewals and payment methods that can take more than 1 hour (i.e. PayPal eCheck)
if ( '0' == self::$active_version || version_compare( self::$active_version, '1.4', '<' ) ) {
@@ -269,23 +269,23 @@ class WC_Subscriptions_Upgrader {
/**
* When an upgrade is complete, set the active version, delete the transient locking upgrade and fire a hook.
*
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function upgrade_complete() {
- update_option( WC_Subscriptions_Admin::$option_prefix . '_active_version', WC_Subscriptions_Core_Plugin::instance()->get_plugin_version() );
+ update_option( WC_Subscriptions_Admin::$option_prefix . '_active_version', WC_Subscriptions_Core_Plugin::instance()->get_library_version() );
delete_transient( 'doing_cron' );
delete_option( 'wc_subscriptions_is_upgrading' );
- do_action( 'woocommerce_subscriptions_upgraded', WC_Subscriptions_Core_Plugin::instance()->get_plugin_version(), self::$active_version );
+ do_action( 'woocommerce_subscriptions_upgraded', WC_Subscriptions_Core_Plugin::instance()->get_library_version(), self::$active_version );
}
/**
* Redirect to the Subscriptions major version Welcome/About page for major version updates
*
- * @since 2.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1
*/
public static function maybe_redirect_after_upgrade_complete( $current_version, $previously_active_version ) {
if ( version_compare( $previously_active_version, '2.1.0', '<' ) && version_compare( $current_version, '2.1.0', '>=' ) && version_compare( $current_version, '2.2.0', '<' ) ) {
@@ -298,7 +298,7 @@ class WC_Subscriptions_Upgrader {
* Add support for quantities for subscriptions.
* Update all current subscription wp_cron tasks to the new action-scheduler system.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
private static function ajax_upgrade_handler() {
@@ -327,7 +327,7 @@ class WC_Subscriptions_Upgrader {
* Also set all existing subscriptions to "sold individually" to maintain previous behavior
* for existing subscription products before the subscription quantities feature was enabled..
*
- * @since 1.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5
*/
public static function ajax_upgrade() {
global $wpdb;
@@ -472,7 +472,7 @@ class WC_Subscriptions_Upgrader {
/**
* Handle upgrades for really old versions.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
private static function upgrade_really_old_versions() {
@@ -504,7 +504,7 @@ class WC_Subscriptions_Upgrader {
* Version 1.2 introduced child renewal orders to keep a record of each completed subscription
* payment. Before 1.2, these orders did not exist, so this function creates them.
*
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
private static function generate_renewal_orders() {
global $wpdb;
@@ -570,7 +570,7 @@ class WC_Subscriptions_Upgrader {
* This is important to avoid the possibility of a database not upgrading correctly, but the site continuing
* to function without any remedy.
*
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
public static function display_database_upgrade_helper() {
@@ -632,7 +632,7 @@ class WC_Subscriptions_Upgrader {
* upgrade process, and how many subscriptions per request can typically be updated given the amount of memory
* allocated to PHP.
*
- * @since 1.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4
*/
public static function upgrade_in_progress_notice() {
include_once( dirname( __FILE__ ) . '/templates/wcs-upgrade-in-progress.php' );
@@ -642,7 +642,7 @@ class WC_Subscriptions_Upgrader {
/**
* Display the Subscriptions welcome/about page after successfully upgrading to the latest version.
*
- * @since 1.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4
*/
public static function updated_welcome_page() {
$about_page = add_dashboard_page( __( 'Welcome to WooCommerce Subscriptions 2.1', 'woocommerce-subscriptions' ), __( 'About WooCommerce Subscriptions', 'woocommerce-subscriptions' ), 'manage_options', 'wcs-about', __CLASS__ . '::about_screen' );
@@ -686,7 +686,7 @@ class WC_Subscriptions_Upgrader {
* but not in v1.5, because a subscription data is still stored in order item meta. This function queries the
* v1.5 database structure.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
private static function get_total_subscription_count( $initial = false ) {
@@ -786,7 +786,7 @@ class WC_Subscriptions_Upgrader {
*
* The method returns a 409 Conflict HTTP response code to indicate that the IPN is conflicting with the upgrader.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function maybe_block_paypal_ipn() {
if ( false !== get_option( 'wc_subscriptions_is_upgrading', false ) ) {
@@ -798,7 +798,7 @@ class WC_Subscriptions_Upgrader {
/**
* Run the end of prepaid term repair script.
*
- * @since 2.2.7
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.7
*/
public static function repair_end_of_prepaid_term_actions() {
WCS_Upgrade_2_2_7::repair_pending_cancelled_subscriptions();
@@ -807,7 +807,7 @@ class WC_Subscriptions_Upgrader {
/**
* Repair subscriptions with missing contains_synced_subscription post meta.
*
- * @since 2.2.9
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.9
*/
public static function repair_subscription_contains_sync_meta() {
WCS_Upgrade_2_2_9::repair_subscriptions_containing_synced_variations();
@@ -816,7 +816,7 @@ class WC_Subscriptions_Upgrader {
/**
* When updating WC to a version after 3.0 from a version prior to 3.0, schedule the repair script to add address indexes.
*
- * @since 2.3.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.0
*/
public static function maybe_add_subscription_address_indexes() {
$woocommerce_active_version = WC()->version;
@@ -830,7 +830,7 @@ class WC_Subscriptions_Upgrader {
/**
* Load and initialise the background updaters.
*
- * @since 2.4.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.4.0
*/
public static function initialise_background_updaters() {
$logger = new WC_logger();
@@ -855,7 +855,7 @@ class WC_Subscriptions_Upgrader {
* Under these circumstances, there is a chance that the persistent caches introduced in 2.3 could contain invalid data.
*
* @see https://github.com/Prospress/woocommerce-subscriptions/issues/2822 for more details.
- * @since 2.3.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.3
*/
public static function maybe_display_external_object_cache_warning() {
$option_name = 'wcs_display_2_3_3_warning';
@@ -906,8 +906,8 @@ class WC_Subscriptions_Upgrader {
/**
* Handles the WC 3.5.0 upgrade routine that moves customer IDs from post metadata to the 'post_author' column.
*
- * @since 2.4.0
- * @deprecated 2.5.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.4.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.0
*/
public static function maybe_update_subscription_post_author() {
wcs_deprecated_function( __METHOD__, '2.5.0' );
@@ -930,7 +930,7 @@ class WC_Subscriptions_Upgrader {
* Needs to be a separate function so that it can use a static variable (and therefore avoid calling get_option() thousands
* of times when iterating over thousands of users).
*
- * @since 1.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4
*/
public static function is_user_upgraded_to_1_4( $user_id ) {
_deprecated_function( __METHOD__, '2.0', 'WCS_Upgrade_1_4::is_user_upgraded( $user_id )' );
@@ -947,7 +947,7 @@ class WC_Subscriptions_Upgrader {
wcs_deprecated_function( __METHOD__, '1.2.0' );
// If there's no downgrade, exit early. self::$active_version is a bit of a misnomer here but in an upgrade context it refers to the database version of the plugin.
- if ( ! version_compare( wcs_get_minor_version_string( self::$active_version ), wcs_get_minor_version_string( WC_Subscriptions_Core_Plugin::instance()->get_plugin_version() ), '>' ) ) {
+ if ( ! version_compare( wcs_get_minor_version_string( self::$active_version ), wcs_get_minor_version_string( WC_Subscriptions_Core_Plugin::instance()->get_library_version() ), '>' ) ) {
return;
}
@@ -959,7 +959,7 @@ class WC_Subscriptions_Upgrader {
'
',
' ',
'
' . self::$active_version . '',
- '
' . WC_Subscriptions_Core_Plugin::instance()->get_plugin_version() . '',
+ '
' . WC_Subscriptions_Core_Plugin::instance()->get_library_version() . '',
'
',
' ',
'
',
diff --git a/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-repair-2-0-2.php b/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-repair-2-0-2.php
index da8b2d7..c939bdb 100644
--- a/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-repair-2-0-2.php
+++ b/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-repair-2-0-2.php
@@ -5,7 +5,7 @@
* @author Prospress
* @category Admin
* @package WooCommerce Subscriptions/Admin/Upgrades
- * @version 2.0.2
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.2
*/
if ( ! defined( 'ABSPATH' ) ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-repair-2-0.php b/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-repair-2-0.php
index 6c20ff0..bb619ed 100644
--- a/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-repair-2-0.php
+++ b/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-repair-2-0.php
@@ -5,7 +5,7 @@
* @author Prospress
* @category Admin
* @package WooCommerce Subscriptions/Admin/Upgrades
- * @version 2.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-repair-line-item-has-trial-meta.php b/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-repair-line-item-has-trial-meta.php
index f6a0fe7..1991b59 100644
--- a/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-repair-line-item-has-trial-meta.php
+++ b/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-repair-line-item-has-trial-meta.php
@@ -14,7 +14,7 @@
* @author WooCommerce
* @category Admin
* @package WooCommerce Subscriptions/Admin/Upgrades
- * @version 2.6.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
// Exit if accessed directly.
@@ -29,7 +29,7 @@ class WCS_Repair_Line_Item_Has_Trial_Meta extends WCS_Background_Repairer {
*
* @param WC_Logger_Interface $logger The WC_Logger instance.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
public function __construct( WC_Logger_Interface $logger ) {
$this->scheduled_hook = 'wcs_schedule_trial_subscription_repairs';
@@ -44,7 +44,7 @@ class WCS_Repair_Line_Item_Has_Trial_Meta extends WCS_Background_Repairer {
* @param int $page The page number to get results from.
* @return array A list of subscription ids.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
protected function get_items_to_repair( $page ) {
$query = new WP_Query();
@@ -74,7 +74,7 @@ class WCS_Repair_Line_Item_Has_Trial_Meta extends WCS_Background_Repairer {
*
* @param int $subscription_id
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
public function repair_item( $subscription_id ) {
try {
diff --git a/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-repair-start-date-metadata.php b/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-repair-start-date-metadata.php
index 42af3d0..7436f2b 100644
--- a/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-repair-start-date-metadata.php
+++ b/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-repair-start-date-metadata.php
@@ -5,7 +5,7 @@
* @author Prospress
* @category Admin
* @package WooCommerce Subscriptions/Admin/Upgrades
- * @version 2.4.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.4.0
*/
// Exit if accessed directly.
@@ -20,7 +20,7 @@ class WCS_Repair_Start_Date_Metadata extends WCS_Background_Upgrader {
*
* @param WC_Logger_Interface $logger The WC_Logger instance.
*
- * @since 2.4.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.4.0
*/
public function __construct( WC_Logger_Interface $logger ) {
$this->scheduled_hook = 'wcs_add_start_date_metadata';
@@ -31,7 +31,7 @@ class WCS_Repair_Start_Date_Metadata extends WCS_Background_Upgrader {
/**
* Update a subscription, saving its start date as metadata.
*
- * @since 2.4.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.4.0
*/
protected function update_item( $subscription_id ) {
try {
@@ -53,7 +53,7 @@ class WCS_Repair_Start_Date_Metadata extends WCS_Background_Upgrader {
/**
* Get a batch of subscriptions to repair.
*
- * @since 2.4.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.4.0
* @return array A list of subscription ids which may need to be repaired.
*/
protected function get_items_to_update() {
diff --git a/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-repair-subscription-address-indexes.php b/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-repair-subscription-address-indexes.php
index 5527026..0b48c17 100644
--- a/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-repair-subscription-address-indexes.php
+++ b/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-repair-subscription-address-indexes.php
@@ -8,7 +8,7 @@
* @author Prospress
* @category Admin
* @package WooCommerce Subscriptions/Admin/Upgrades
- * @version 2.3.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.0
*/
// Exit if accessed directly.
@@ -23,7 +23,7 @@ class WCS_Repair_Subscription_Address_Indexes extends WCS_Background_Upgrader {
*
* @param WC_Logger_Interface $logger The WC_Logger instance.
*
- * @since 2.3.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.0
*/
public function __construct( WC_Logger_Interface $logger ) {
$this->scheduled_hook = 'wcs_add_missing_subscription_address_indexes';
@@ -34,7 +34,7 @@ class WCS_Repair_Subscription_Address_Indexes extends WCS_Background_Upgrader {
/**
* Update a subscription, setting its address indexes.
*
- * @since 2.3.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.0
*/
protected function update_item( $subscription_id ) {
try {
@@ -56,7 +56,7 @@ class WCS_Repair_Subscription_Address_Indexes extends WCS_Background_Upgrader {
/**
* Get a batch of subscriptions which need address indexes.
*
- * @since 2.3.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.0
* @return array A list of subscription ids which need address indexes.
*/
protected function get_items_to_update() {
diff --git a/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-repair-subtracted-base-tax-line-item-meta.php b/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-repair-subtracted-base-tax-line-item-meta.php
index 1078726..535faf2 100644
--- a/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-repair-subtracted-base-tax-line-item-meta.php
+++ b/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-repair-subtracted-base-tax-line-item-meta.php
@@ -20,7 +20,7 @@
* @author WooCommerce
* @category Admin
* @package WooCommerce Subscriptions/Admin/Upgrades
- * @version 3.1.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
*/
// Exit if accessed directly.
@@ -33,7 +33,7 @@ class WCS_Repair_Subtracted_Base_Tax_Line_Item_Meta extends WCS_Background_Repai
*
* @param WC_Logger_Interface $logger The WC_Logger instance.
*
- * @since 3.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
*/
public function __construct( WC_Logger_Interface $logger ) {
$this->scheduled_hook = 'wcs_schedule_subtracted_base_line_item_tax_repairs';
@@ -48,7 +48,7 @@ class WCS_Repair_Subtracted_Base_Tax_Line_Item_Meta extends WCS_Background_Repai
* @param int $page The page number to get results from. Base 1 - the first page is 1.
* @return array A list of line item ids.
*
- * @since 3.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
*/
protected function get_items_to_repair( $page ) {
global $wpdb;
@@ -68,7 +68,7 @@ class WCS_Repair_Subtracted_Base_Tax_Line_Item_Meta extends WCS_Background_Repai
*
* @param int $line_item_id The ID for the line item to repair.
*
- * @since 3.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
*/
public function repair_item( $line_item_id ) {
try {
diff --git a/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-repair-suspended-paypal-subscriptions.php b/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-repair-suspended-paypal-subscriptions.php
index a3f6255..9b641d2 100644
--- a/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-repair-suspended-paypal-subscriptions.php
+++ b/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-repair-suspended-paypal-subscriptions.php
@@ -11,7 +11,7 @@
* @author Prospress
* @category Admin
* @package WooCommerce Subscriptions/Admin/Upgrades
- * @version 2.3.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.0
*/
// Exit if accessed directly.
@@ -26,7 +26,7 @@ class WCS_Repair_Suspended_PayPal_Subscriptions extends WCS_Background_Upgrader
*
* @param WC_Logger_Interface $logger The WC Logger instance.
*
- * @since 2.3.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.0
*/
public function __construct( WC_Logger_Interface $logger ) {
$this->scheduled_hook = 'wcs_repair_subscriptions_suspended_paypal_not_woocommerce';
@@ -65,7 +65,7 @@ class WCS_Repair_Suspended_PayPal_Subscriptions extends WCS_Background_Upgrader
/**
* Get a list of subscriptions to repair.
*
- * @since 2.3.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.0
* @return array A list of subscription ids which may need to be repaired.
*/
protected function get_items_to_update() {
diff --git a/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-1-2.php b/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-1-2.php
index be1e60e..c6dfb66 100644
--- a/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-1-2.php
+++ b/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-1-2.php
@@ -13,7 +13,7 @@
* @author Prospress
* @category Admin
* @package WooCommerce Subscriptions/Admin/Upgrades
- * @version 1.2.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v1.2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-1-3.php b/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-1-3.php
index 3e0f6d8..9cea922 100644
--- a/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-1-3.php
+++ b/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-1-3.php
@@ -8,7 +8,7 @@
* @author Prospress
* @category Admin
* @package WooCommerce Subscriptions/Admin/Upgrades
- * @version 1.3.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v1.3.0
*/
if ( ! defined( 'ABSPATH' ) ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-1-4.php b/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-1-4.php
index 1492b78..9a67fa4 100644
--- a/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-1-4.php
+++ b/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-1-4.php
@@ -7,7 +7,7 @@
* @author Prospress
* @category Admin
* @package WooCommerce Subscriptions/Admin/Upgrades
- * @version 1.4.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v1.4.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -167,7 +167,7 @@ class WCS_Upgrade_1_4 {
* Needs to be a separate function so that it can use a static variable (and therefore avoid calling get_option() thousands
* of times when iterating over thousands of users).
*
- * @since 1.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4
*/
public static function is_user_upgraded( $user_id ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-1-5.php b/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-1-5.php
index 8902916..7964057 100644
--- a/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-1-5.php
+++ b/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-1-5.php
@@ -5,7 +5,7 @@
* @author Prospress
* @category Admin
* @package WooCommerce Subscriptions/Admin/Upgrades
- * @version 2.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -20,7 +20,7 @@ class WCS_Upgrade_1_5 {
* Subscriptions 1.5 made it possible for a product to be sold individually or in multiple quantities, whereas
* previously it was possible only to buy a subscription product in a single quantity.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function upgrade_products() {
global $wpdb;
@@ -54,7 +54,7 @@ class WCS_Upgrade_1_5 {
/**
* Update subscription WP-Cron tasks to Action Scheduler.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function upgrade_hooks( $number_hooks_to_upgrade ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-2-0.php b/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-2-0.php
index 2050f49..c9a7cc3 100644
--- a/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-2-0.php
+++ b/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-2-0.php
@@ -5,7 +5,7 @@
* @author Prospress
* @category Admin
* @package WooCommerce Subscriptions/Admin/Upgrades
- * @version 2.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -41,7 +41,7 @@ class WCS_Upgrade_2_0 {
/**
* Migrate subscriptions out of order item meta and into post/post meta tables for their own post type.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function upgrade_subscriptions( $batch_size ) {
global $wpdb;
@@ -193,7 +193,7 @@ class WCS_Upgrade_2_0 {
*
* @param int $batch_size The number of subscriptions to return.
* @return array Subscription details in the v1.5 structure of 'order_item_id' => array()
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
private static function get_subscriptions( $batch_size ) {
global $wpdb;
@@ -246,7 +246,7 @@ class WCS_Upgrade_2_0 {
* @param int $order_item_id ID of the subscription item on the original order
* @param array $order_item An array of order item data in the form returned by WC_Abstract_Order::get_items()
* @return int Subscription $item_id The order item id of the new line item added to the subscription.
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
private static function add_product( $new_subscription, $order_item_id, $order_item ) {
global $wpdb;
@@ -328,7 +328,7 @@ class WCS_Upgrade_2_0 {
* @param int $new_order_item_id ID of the line item on the new subscription post type
* @param int $old_order_item_id ID of the line item on the original order that in v1.5 represented the subscription
* @param array $order_item The line item on the original order that in v1.5 represented the subscription
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
public static function add_line_tax_data( $new_order_item_id, $old_order_item_id, $order_item ) {
@@ -415,7 +415,7 @@ class WCS_Upgrade_2_0 {
* Deprecate order item meta data stored on the original order that used to make up the subscription by prefixing it with with '_wcs_migrated'
*
* @param int $order_item_id ID of the subscription item on the original order
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
private static function deprecate_item_meta( $order_item_id ) {
global $wpdb;
@@ -438,7 +438,7 @@ class WCS_Upgrade_2_0 {
* @param WC_Subscription $subscription A subscription object
* @param int $subscription_item_id ID of the product line item on the subscription
* @param WC_Order $original_order The original order that was created to purchase the subscription
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
private static function migrate_download_permissions( $subscription, $subscription_item_id, $order ) {
global $wpdb;
@@ -467,7 +467,7 @@ class WCS_Upgrade_2_0 {
/**
* Migrate the trial expiration, next payment and expiration/end dates to a new subscription.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
private static function migrate_dates( $new_subscription, $old_subscription ) {
global $wpdb;
@@ -583,7 +583,7 @@ class WCS_Upgrade_2_0 {
* @param int $subscription_id The ID of a 'shop_subscription' post type
* @param WC_Order $order The original order used to purchase a subscription
* @return null
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
private static function migrate_post_meta( $subscription_id, $order ) {
global $wpdb;
@@ -680,7 +680,7 @@ class WCS_Upgrade_2_0 {
* @param int $subscription_id The ID of a 'shop_subscription' post type
* @param WC_Order $order The original order used to purchase a subscription
* @return null
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
private static function deprecate_post_meta( $order_id ) {
global $wpdb;
@@ -723,7 +723,7 @@ class WCS_Upgrade_2_0 {
* @param int $subscription_id The ID of a 'shop_subscription' post type
* @param WC_Order $order The original order used to purchase a subscription
* @return null
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
private static function migrate_order_notes( $subscription_id, $order_id ) {
global $wpdb;
@@ -750,7 +750,7 @@ class WCS_Upgrade_2_0 {
* @param int $subscription_id The ID of a 'shop_subscription' post type
* @param WC_Order $order The original order used to purchase a subscription
* @return null
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
private static function migrate_order_items( $subscription_id, $order_id ) {
global $wpdb;
@@ -783,7 +783,7 @@ class WCS_Upgrade_2_0 {
* @param WC_Subscription $subscription An instance of a 'shop_subscription' post type
* @param int $order_id The ID of a 'shop_order' which created this susbcription
* @return null
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
private static function migrate_renewal_orders( $subscription, $order_id ) {
global $wpdb;
@@ -829,7 +829,7 @@ class WCS_Upgrade_2_0 {
* @param WC_Subscription $new_subscription An instance of a 'shop_subscription' post type
* @param WC_Order $resubscribe_order An instance of a 'shop_order' post type which created this subscription
* @return null
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
private static function migrate_resubscribe_orders( $new_subscription, $resubscribe_order ) {
global $wpdb;
@@ -870,7 +870,7 @@ class WCS_Upgrade_2_0 {
* @param WC_Order $switch_order The original order used to purchase the subscription
* @param int $subscription_item_id The order item ID of the item added to the subscription by self::add_product()
* @return null
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
private static function migrate_switch_meta( $new_subscription, $switch_order, $subscription_item_id ) {
global $wpdb;
diff --git a/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-2-1.php b/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-2-1.php
index bdeb615..ba35857 100644
--- a/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-2-1.php
+++ b/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-2-1.php
@@ -5,7 +5,7 @@
* @author Prospress
* @category Admin
* @package WooCommerce Subscriptions/Admin/Upgrades
- * @version 2.1
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.1
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -19,7 +19,7 @@ class WCS_Upgrade_2_1 {
* date for those subscriptions still in the pending cancellation state, and therefore
* where it is possible to determine the cancellation date.
*
- * @since 2.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1
*/
public static function set_cancelled_dates() {
global $wpdb;
diff --git a/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-2-2-7.php b/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-2-2-7.php
index 0761806..39dcd3b 100644
--- a/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-2-2-7.php
+++ b/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-2-2-7.php
@@ -5,7 +5,7 @@
* @author Prospress
* @category Admin
* @package WooCommerce Subscriptions/Admin/Upgrades
- * @version 2.2.7
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.7
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -20,7 +20,7 @@ class WCS_Upgrade_2_2_7 {
/**
* Schedule an WP-Cron event to run in 5 minutes to repair pending cancelled subscriptions.
*
- * @since 2.2.7
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.7
*/
public static function schedule_end_of_prepaid_term_repair() {
wp_schedule_single_event( gmdate( 'U' ) + ( MINUTE_IN_SECONDS * 3 ), self::$cron_hook );
@@ -33,7 +33,7 @@ class WCS_Upgrade_2_2_7 {
* end of prepaid term actions. This results in pending cancelled subscriptions not transitioning to
* cancelled automatically.
*
- * @since 2.2.7
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.7
*/
public static function repair_pending_cancelled_subscriptions() {
$subscriptions_to_repair = self::get_subscriptions_to_repair();
@@ -94,7 +94,7 @@ class WCS_Upgrade_2_2_7 {
/**
* Get a batch of pending cancelled subscriptions to repair.
*
- * @since 2.2.7
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.7
* @return array An list of subscription ids which may need to be repaired.
*/
public static function get_subscriptions_to_repair() {
@@ -118,7 +118,7 @@ class WCS_Upgrade_2_2_7 {
* Add a message to the wcs-upgrade-end-of-prepaid-term-repair log
*
* @param string The message to be logged
- * @since 2.2.7
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.7
*/
protected static function log( $message ) {
WCS_Upgrade_Logger::add( $message, 'wcs-upgrade-end-of-prepaid-term-repair' );
diff --git a/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-2-2-9.php b/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-2-2-9.php
index 9eb555d..c989bf1 100644
--- a/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-2-2-9.php
+++ b/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-2-2-9.php
@@ -6,7 +6,7 @@
* @author Prospress
* @category Admin
* @package WooCommerce Subscriptions/Admin/Upgrades
- * @version 2.2.9
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.9
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -22,7 +22,7 @@ class WCS_Upgrade_2_2_9 {
/**
* Schedule an WP-Cron event to run in 3 minutes to repair subscription synced post meta.
*
- * @since 2.2.9
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.9
*/
public static function schedule_repair() {
wp_schedule_single_event( gmdate( 'U' ) + ( MINUTE_IN_SECONDS * 3 ), self::$cron_hook );
@@ -35,7 +35,7 @@ class WCS_Upgrade_2_2_9 {
* WC 3.0 was active, to have missing _contains_synced_subscription post meta. This was fixed to prevent new subscriptions
* falling victim to that bug in WCS 2.2.8 however existing subscriptions need to be repaired.
*
- * @since 2.2.9
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.9
*/
public static function repair_subscriptions_containing_synced_variations() {
$repaired_subscriptions = get_option( self::$repaired_subscriptions_option, array() );
@@ -84,7 +84,7 @@ class WCS_Upgrade_2_2_9 {
/**
* Get a batch of subscriptions to repair.
*
- * @since 2.2.9
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.9
* @param array $repaired_subscriptions A list of subscription post IDs to ignore.
* @return array A list of subscription ids which may need to be repaired.
*/
@@ -115,7 +115,7 @@ class WCS_Upgrade_2_2_9 {
* Add a message to the wcs-upgrade-subscriptions-containing-synced-variations log
*
* @param string The message to be logged
- * @since 2.2.9
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.9
*/
protected static function log( $message ) {
WCS_Upgrade_Logger::add( $message, 'wcs-upgrade-subscriptions-containing-synced-variations' );
diff --git a/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-3-1-0.php b/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-3-1-0.php
index f851fce..3e88225 100644
--- a/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-3-1-0.php
+++ b/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-3-1-0.php
@@ -2,7 +2,7 @@
/**
* Upgrade script for version 3.1.0
*
- * @version 3.1.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -16,7 +16,7 @@ class WCS_Upgrade_3_1_0 {
* This is to maintain backwards compatibility with the delivery payloads now that we have added a
* wc/v3/subscriptions endpoint with 3.1
*
- * @since 3.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
*/
public static function migrate_subscription_webhooks_using_api_version_3() {
global $wpdb;
diff --git a/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-logger.php b/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-logger.php
index 6d7c801..e8988a5 100644
--- a/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-logger.php
+++ b/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-logger.php
@@ -5,7 +5,7 @@
* @author Prospress
* @category Admin
* @package WooCommerce Subscriptions/Admin/Upgrades
- * @version 2.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -67,7 +67,7 @@ class WCS_Upgrade_Logger {
/**
* Log more information during upgrade: Information about environment and active plugins
*
- * @since 2.5.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.0
*/
public static function add_more_info() {
global $wp_version;
diff --git a/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-subscription-post-author.php b/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-subscription-post-author.php
index 7446f75..101da39 100644
--- a/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-subscription-post-author.php
+++ b/vendor/woocommerce/subscriptions-core/includes/upgrades/class-wcs-upgrade-subscription-post-author.php
@@ -5,8 +5,8 @@
* @author Prospress
* @category Admin
* @package WooCommerce Subscriptions/Admin/Upgrades
- * @version 2.4.0
- * @deprecated 2.5.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.4.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -19,7 +19,7 @@ class WCS_Upgrade_Subscription_Post_Author extends WCS_Background_Upgrader {
* Constructor
*
* @param WC_Logger $logger The WC_Logger instance.
- * @since 2.4.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.4.0
*/
public function __construct( WC_Logger $logger ) {
wcs_deprecated_function( __METHOD__, '2.5.0' );
@@ -32,7 +32,7 @@ class WCS_Upgrade_Subscription_Post_Author extends WCS_Background_Upgrader {
/**
* Update a subscription, setting its post_author to its customer ID.
*
- * @since 2.4.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.4.0
*/
protected function update_item( $subscription_id ) {
global $wpdb;
@@ -69,7 +69,7 @@ class WCS_Upgrade_Subscription_Post_Author extends WCS_Background_Upgrader {
/**
* Get a batch of subscriptions which need to be updated.
*
- * @since 2.4.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.4.0
* @return array A list of subscription ids which need to be updated.
*/
protected function get_items_to_update() {
@@ -142,7 +142,7 @@ class WCS_Upgrade_Subscription_Post_Author extends WCS_Background_Upgrader {
/**
* Hooks into WC's 3.5 update routine to add the subscription post type to the list of post types affected by this update.
*
- * @since 2.4.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.4.0
*/
public static function hook_into_wc_350_update() {
add_filter( 'woocommerce_update_350_order_customer_id_post_types', array( __CLASS__, 'add_post_type_to_wc_350_update' ) );
@@ -154,7 +154,7 @@ class WCS_Upgrade_Subscription_Post_Author extends WCS_Background_Upgrader {
*
* @param array $post_types
* @return array
- * @since 2.4.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.4.0
*/
public static function add_post_type_to_wc_350_update( $post_types = array() ) {
if ( ! in_array( 'shop_subscription', $post_types ) ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/upgrades/templates/wcs-about-2-0.php b/vendor/woocommerce/subscriptions-core/includes/upgrades/templates/wcs-about-2-0.php
index a0de344..69216cc 100644
--- a/vendor/woocommerce/subscriptions-core/includes/upgrades/templates/wcs-about-2-0.php
+++ b/vendor/woocommerce/subscriptions-core/includes/upgrades/templates/wcs-about-2-0.php
@@ -5,7 +5,7 @@
* @author Prospress
* @category Admin
* @package WooCommerce Subscriptions/Admin/Upgrades
- * @version 2.0.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/upgrades/templates/wcs-about.php b/vendor/woocommerce/subscriptions-core/includes/upgrades/templates/wcs-about.php
index 83e7e5d..2fdf7f5 100644
--- a/vendor/woocommerce/subscriptions-core/includes/upgrades/templates/wcs-about.php
+++ b/vendor/woocommerce/subscriptions-core/includes/upgrades/templates/wcs-about.php
@@ -5,7 +5,7 @@
* @author Prospress
* @category Admin
* @package WooCommerce Subscriptions/Admin/Upgrades
- * @version 2.1.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.1.0
*/
if ( ! defined( 'ABSPATH' ) ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/upgrades/templates/wcs-upgrade-in-progress.php b/vendor/woocommerce/subscriptions-core/includes/upgrades/templates/wcs-upgrade-in-progress.php
index e026731..74aeda5 100644
--- a/vendor/woocommerce/subscriptions-core/includes/upgrades/templates/wcs-upgrade-in-progress.php
+++ b/vendor/woocommerce/subscriptions-core/includes/upgrades/templates/wcs-upgrade-in-progress.php
@@ -5,7 +5,7 @@
* @author Prospress
* @category Admin
* @package WooCommerce Subscriptions/Admin/Upgrades
- * @version 2.0.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/upgrades/templates/wcs-upgrade.php b/vendor/woocommerce/subscriptions-core/includes/upgrades/templates/wcs-upgrade.php
index 1a1ac7a..39154b8 100644
--- a/vendor/woocommerce/subscriptions-core/includes/upgrades/templates/wcs-upgrade.php
+++ b/vendor/woocommerce/subscriptions-core/includes/upgrades/templates/wcs-upgrade.php
@@ -5,7 +5,7 @@
* @author Prospress
* @category Admin
* @package WooCommerce Subscriptions/Admin/Upgrades
- * @version 2.0.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/wcs-cart-functions.php b/vendor/woocommerce/subscriptions-core/includes/wcs-cart-functions.php
index 810d71f..65cf6d2 100644
--- a/vendor/woocommerce/subscriptions-core/includes/wcs-cart-functions.php
+++ b/vendor/woocommerce/subscriptions-core/includes/wcs-cart-functions.php
@@ -8,7 +8,7 @@
* @author Prospress
* @category Core
* @package WooCommerce Subscriptions/Functions
- * @version 2.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -62,7 +62,7 @@ function wcs_cart_totals_shipping_html() {
foreach ( $recurring_cart->get_shipping_packages() as $recurring_cart_package_key => $recurring_cart_package ) {
$package_index = isset( $recurring_cart_package['package_index'] ) ? $recurring_cart_package['package_index'] : 0;
$product_names = array();
- $package = WC_Subscriptions_Cart::get_calculated_shipping_for_package( $recurring_cart_package );
+ $package = WC()->shipping->calculate_shipping_for_package( $recurring_cart_package );
if ( $show_package_details ) {
foreach ( $package['contents'] as $item_id => $values ) {
@@ -442,7 +442,7 @@ function wcs_get_cart_item_name( $cart_item, $include = array() ) {
/**
* Allows protected products to be renewed.
*
- * @since 2.4.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.4.0
*/
function wcs_allow_protected_products_to_renew() {
remove_filter( 'woocommerce_add_to_cart_validation', 'wc_protected_product_add_to_cart' );
@@ -451,7 +451,7 @@ function wcs_allow_protected_products_to_renew() {
/**
* Restores protected products from being added to the cart.
* @see wcs_allow_protected_products_to_renew
- * @since 2.4.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.4.0
*/
function wcs_disallow_protected_product_add_to_cart_validation() {
add_filter( 'woocommerce_add_to_cart_validation', 'wc_protected_product_add_to_cart', 10, 2 );
@@ -460,7 +460,7 @@ function wcs_disallow_protected_product_add_to_cart_validation() {
/**
* Gets all the cart items linked to a given subscription order type.
*
- * @since 3.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
*
* @param string $order_type The order type to get cart items for. Can be 'parent', 'renewal', 'resubscribe', 'switch'.
* @return array[] An array of cart items which are linked to an order or subscription by the order type relationship.
diff --git a/vendor/woocommerce/subscriptions-core/includes/wcs-compatibility-functions.php b/vendor/woocommerce/subscriptions-core/includes/wcs-compatibility-functions.php
index bef6aac..4824f0f 100644
--- a/vendor/woocommerce/subscriptions-core/includes/wcs-compatibility-functions.php
+++ b/vendor/woocommerce/subscriptions-core/includes/wcs-compatibility-functions.php
@@ -7,7 +7,7 @@
* @author Prospress
* @category Core
* @package WooCommerce Subscriptions/Functions
- * @version 2.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -18,7 +18,7 @@ if ( ! defined( 'ABSPATH' ) ) {
/**
* Display a tooltip in the WordPress administration area.
*
- * @since 2.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1.0
*
* @param string $tip The content to display in the tooltip.
* @param bool $allow_html Allow sanitized HTML if true or escape. Optional. False by default.
@@ -51,7 +51,8 @@ function wcs_help_tip( $tip, $allow_html = false, $class = 'woocommerce-help-tip
* @param string $single Whether to return just the first piece of meta data with the given property key, or all meta data.
* @param mixed $default (optional) The value to return if no value is found - defaults to single -> null, multiple -> array().
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
+ * @deprecated 2.4.0 Use of this compatibility function is no longer required, getters should be used on the objects instead. Please note there may be differences in dates between this function and the getter.
* @return mixed
*/
function wcs_get_objects_property( $object, $property, $single = 'single', $default = null ) {
@@ -135,7 +136,8 @@ function wcs_get_objects_property( $object, $property, $single = 'single', $defa
* @param string $save Whether to write the data to the database or not. Use 'save' to write to the database, anything else to only update it in memory.
* @param int $meta_id The meta ID of existing meta data if you wish to overwrite an existing piece of meta.
* @param string $prefix_meta_key Whether the key should be prefixed with an '_' when stored in meta. Defaulted to 'prefix_meta_key', pass any other value to bypass automatic prefixing (optional)
- * @since 2.2.0
+ * @deprecated 2.4.0 Use of this compatibility function is no longer required, setters should be used on the objects instead.
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @return mixed
*/
function wcs_set_objects_property( &$object, $key, $value, $save = 'save', $meta_id = '', $prefix_meta_key = 'prefix_meta_key' ) {
@@ -194,7 +196,8 @@ function wcs_set_objects_property( &$object, $key, $value, $save = 'save', $meta
* @param string $key The meta key name without '_' prefix
* @param mixed $value The data to set as the value of the meta
* @param string $save Whether to save the data or not, 'save' to save the data, otherwise it won't be saved.
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
+ * @deprecated 2.4.0 Use of this compatibility function is no longer required, setters should be used on the objects instead.
* @return mixed
*/
function wcs_delete_objects_property( &$object, $key, $save = 'save', $meta_id = '' ) {
@@ -228,7 +231,7 @@ function wcs_delete_objects_property( &$object, $key, $save = 'save', $meta_id =
* property which returned 'simple', so we need to check for both.
*
* @param WC_Order $order
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @return bool
*/
function wcs_is_order( $order ) {
@@ -252,7 +255,7 @@ function wcs_is_order( $order ) {
*
* @param string $property
* @param WC_Product $product
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @return mixed
*/
function wcs_product_deprecated_property_handler( $property, $product ) {
@@ -325,7 +328,7 @@ function wcs_product_deprecated_property_handler( $property, $product ) {
*
* @param WC_Coupon $coupon The coupon whose property we want to access.
* @param string $property The property name.
- * @since 2.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2
* @return mixed
*/
function wcs_get_coupon_property( $coupon, $property ) {
@@ -371,7 +374,7 @@ function wcs_get_coupon_property( $coupon, $property ) {
* @param WC_Coupon $coupon The coupon whose property we want to set.
* @param string $property The property name.
* @param mixed $value The data to set as the value
- * @since 2.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2
*/
function wcs_set_coupon_property( &$coupon, $property, $value ) {
@@ -416,7 +419,7 @@ function wcs_set_coupon_property( &$coupon, $property, $value ) {
* This is a compatibility wrapper for @see wc_generate_order_key() which was introduced in WC 3.5.4.
*
* @return string $order_key.
- * @since 2.5.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.0
*/
function wcs_generate_order_key() {
@@ -437,7 +440,7 @@ function wcs_generate_order_key() {
* @param WC_Settings_API $settings_api The object to update the option for.
* @param string $key Option key.
* @param mixed $value Value to set.
- * @since 2.5.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.1
*/
function wcs_update_settings_option( $settings_api, $key, $value ) {
@@ -460,7 +463,7 @@ function wcs_update_settings_option( $settings_api, $key, $value ) {
*
* This function is a compatibility wrapper for WC()->is_rest_api_request() which was introduced in WC 3.6.
*
- * @since 2.5.7
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.7
*
* @return bool True if it's a REST API request, false otherwise.
*/
@@ -507,7 +510,7 @@ function wcs_is_checkout_blocks_api_request( $endpoint = '' ) {
*
* This function is a compatibility wrapper for wp_doing_cron() which was introduced in WP 4.8.
*
- * @since 2.5.7
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.7
*
* @return bool True if it's a WordPress cron request, false otherwise.
*/
@@ -518,7 +521,7 @@ function wcs_doing_cron() {
/**
* Determines whether the current request is a WordPress Ajax request.
*
- * @since 2.5.7
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.7
*
* @return bool True if it's a WordPress Ajax request, false otherwise.
*/
@@ -531,7 +534,7 @@ function wcs_doing_ajax() {
*
* WC 3.7 deprecated @see WC_Abstract_Order::get_used_coupons() in favour of WC_Abstract_Order::get_coupon_codes().
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*
* @param WC_Abstract_Order $order An order or subscription object to get the coupon codes for.
* @return array The coupon codes applied to the $order.
@@ -546,7 +549,7 @@ function wcs_get_used_coupon_codes( $order ) {
* Enables attaching a callback if WooCommerce is before, after, equal or not equal to a given version.
* This function is a wrapper for @see WCS_Dependent_Hook_Manager::add_woocommerce_dependent_action().
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*
* @param string $tag The action or filter tag to attach the callback too.
* @param string|array $function The callable function to attach to the hook.
@@ -562,7 +565,7 @@ function wcs_add_woocommerce_dependent_action( $tag, $function, $woocommerce_ver
/**
* Checks if the installed version of WooCommerce is older than a specified version.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*
* @param string The version string to check in a version_compare() compatible format.
* @return bool Whether the installed version of WC is prior to the given version string.
@@ -570,3 +573,107 @@ function wcs_add_woocommerce_dependent_action( $tag, $function, $woocommerce_ver
function wcs_is_woocommerce_pre( $version ) {
return ! defined( 'WC_VERSION' ) || version_compare( WC_VERSION, $version, '<' );
}
+
+/**
+ * Checks if the WooCommerce feature is enabled using WC's new FeaturesUtil class.
+ *
+ * @param string $feature_name The name of the WC feature to check if enabled.
+ *
+ * @return bool
+ */
+function wcs_is_wc_feature_enabled( $feature_name ) {
+ $feature_is_enabled = false;
+
+ if ( class_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil' ) && \Automattic\WooCommerce\Utilities\FeaturesUtil::feature_is_enabled( $feature_name ) ) {
+ $feature_is_enabled = true;
+ }
+
+ return $feature_is_enabled;
+}
+
+/**
+ * Determines whether custom order tables usage is enabled.
+ *
+ * Custom order table feature can be enabled but the store is still using WP posts as the authoriative source of order data,
+ * therefore this function will only return true if:
+ * - the HPOS feature is enabled
+ * - the HPOS tables have been generated
+ * - HPOS is the authoriative source of order data
+ *
+ * @return bool
+ */
+function wcs_is_custom_order_tables_usage_enabled() {
+ if ( ! class_exists( '\Automattic\WooCommerce\Utilities\OrderUtil' ) || ! wcs_is_wc_feature_enabled( 'custom_order_tables' ) ) {
+ return false;
+ }
+
+ return \Automattic\WooCommerce\Utilities\OrderUtil::custom_orders_table_usage_is_enabled();
+}
+
+/**
+ * Determines whether the order tables are synchronized with WP posts.
+ *
+ * @return bool True if the order tables are synchronized with WP posts, false otherwise.
+ */
+function wcs_is_custom_order_tables_data_sync_enabled() {
+ if ( ! class_exists( '\Automattic\WooCommerce\Internal\DataStores\Orders\DataSynchronizer' ) ) {
+ return false;
+ }
+
+ $data_synchronizer = wc_get_container()->get( \Automattic\WooCommerce\Internal\DataStores\Orders\DataSynchronizer::class );
+
+ return $data_synchronizer && $data_synchronizer->data_sync_is_enabled();
+}
+
+/**
+ * Sets the address on an order or subscription using WC 7.1 functions if they exist.
+ *
+ * For stores pre WC 7.1, use the individual addresss type and key setter i.e. `set_billing_address_1()` method.
+ *
+ * @since 5.2.0
+ *
+ * @param WC_Order|WC_Subscription $order The order or subscription object to set the address on.
+ * @param string $address_type The address type to set. Either 'billing' or 'shipping'.
+ * @param array $address The address to set.
+ */
+function wcs_set_order_address( $order, $address, $address_type = 'billing' ) {
+ if ( method_exists( $order, "set_{$address_type}" ) ) {
+ $order->{"set_{$address_type}"}( $address );
+ } else {
+ foreach ( $address as $key => $value ) {
+ if ( method_exists( $order, "set_{$address_type}_{$key}" ) ) {
+ $order->{"set_{$address_type}_{$key}"}( $value );
+ }
+ }
+ }
+}
+
+/**
+ * Gets an object's admin page screen ID in a WC version compatible way.
+ *
+ * This function is a version compatible wrapper for wc_get_page_screen_id().
+ *
+ * @param string $object_type The object type. eg 'shop_subscription', 'shop_order'.
+ * @return string The page screen ID. On CPT stores, the screen ID is equal to the post type. On HPOS, the screen ID is generated by WC and fetched via wc_get_page_screen_id().
+ */
+function wcs_get_page_screen_id( $object_type ) {
+ return wcs_is_woocommerce_pre( '7.3.0' ) ? $object_type : wc_get_page_screen_id( $object_type );
+}
+
+/**
+ * Outputs a select input box.
+ *
+ * This function is a compatibility wrapper for woocommerce_wp_select() which introduced the second parameter necessary for working with HPOS in WC 6.9.0.
+ *
+ * @since 5.2.0
+ *
+ * @param array $field_args Field data.
+ * @param WC_Data $object The WC object to get the field value from. Only used in WC 6.9.0+. On older versions of WC, the value is fetched from the global $post object.
+ */
+function wcs_woocommerce_wp_select( $field_args, $object ) {
+ if ( wcs_is_woocommerce_pre( '6.9.0' ) ) {
+ woocommerce_wp_select( $field_args );
+ } else {
+ woocommerce_wp_select( $field_args, $object );
+ }
+}
diff --git a/vendor/woocommerce/subscriptions-core/includes/wcs-conditional-functions.php b/vendor/woocommerce/subscriptions-core/includes/wcs-conditional-functions.php
index affd15c..ab540ad 100644
--- a/vendor/woocommerce/subscriptions-core/includes/wcs-conditional-functions.php
+++ b/vendor/woocommerce/subscriptions-core/includes/wcs-conditional-functions.php
@@ -7,7 +7,7 @@
* @author Prospress
* @category Core
* @package WooCommerce Subscriptions/Functions
- * @version 2.0.13
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.13
*/
if ( ! defined( 'ABSPATH' ) ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/wcs-deprecated-functions.php b/vendor/woocommerce/subscriptions-core/includes/wcs-deprecated-functions.php
index 318efc6..74a3532 100644
--- a/vendor/woocommerce/subscriptions-core/includes/wcs-deprecated-functions.php
+++ b/vendor/woocommerce/subscriptions-core/includes/wcs-deprecated-functions.php
@@ -9,7 +9,7 @@
* @author Prospress
* @category Core
* @package WooCommerce Subscriptions/Functions
- * @version 2.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -19,7 +19,7 @@ if ( ! defined( 'ABSPATH' ) ) {
/**
* Wrapper for wc_doing_it_wrong.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @param string $function
* @param string $version
* @param string $replacement
@@ -44,7 +44,7 @@ function wcs_doing_it_wrong( $function, $message, $version ) {
* Wrapper for wcs_deprecated_function to improve handling of ajax requests, even when
* WooCommerce 3.0's wcs_deprecated_function method is not available.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @param string $function
* @param string $version
* @param string $replacement
@@ -69,7 +69,7 @@ function wcs_deprecated_function( $function, $version, $replacement = null ) {
/**
* Reimplement similar logic to wc_deprecated_argument() without the first parameter confusion.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @param string $argument
* @param string $version
* @param string $message
@@ -99,7 +99,7 @@ function wcs_deprecated_argument( $function, $version, $message = null ) {
*
* @param WC_Subscription $subscription An instance of WC_Subscription
* @return string $subscription_key A subscription key in the deprecated form previously created by @see self::get_subscription_key()
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_get_old_subscription_key( WC_Subscription $subscription ) {
@@ -118,7 +118,7 @@ function wcs_get_old_subscription_key( WC_Subscription $subscription ) {
*
* @param string $subscription_key A subscription key in the deprecated form created by @see WC_Subscriptions_Manager::get_subscription_key()
* @return int|null The post ID for the subscription if it can be found (i.e. an order exists) or null if no order exists for the subscription.
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_get_subscription_id_from_key( $subscription_key ) {
global $wpdb;
@@ -165,7 +165,7 @@ function wcs_get_subscription_id_from_key( $subscription_key ) {
*
* @param string $subscription_key A subscription key in the deprecated form created by @see self::get_subscription_key()
* @return WC_Subscription|null The subscription object if it can be found (i.e. an order exists) or null if no order exists for the subscription (i.e. it was manually created).
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_get_subscription_from_key( $subscription_key ) {
@@ -188,7 +188,7 @@ function wcs_get_subscription_from_key( $subscription_key ) {
*
* @param WC_Subscription $subscription An instance of WC_Subscription
* @return array Subscription details
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_get_subscription_in_deprecated_structure( WC_Subscription $subscription ) {
@@ -262,7 +262,7 @@ function wcs_get_subscription_in_deprecated_structure( WC_Subscription $subscrip
* Wrapper for wc_deprecated_hook to improve handling of ajax requests, even when
* WooCommerce 3.3.0's wc_deprecated_hook method is not available.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
* @param string $hook The hook that was used.
* @param string $version The version that deprecated the hook.
* @param string $replacement The hook that should have been used.
diff --git a/vendor/woocommerce/subscriptions-core/includes/wcs-formatting-functions.php b/vendor/woocommerce/subscriptions-core/includes/wcs-formatting-functions.php
index 4dd7803..1bcf3eb 100644
--- a/vendor/woocommerce/subscriptions-core/includes/wcs-formatting-functions.php
+++ b/vendor/woocommerce/subscriptions-core/includes/wcs-formatting-functions.php
@@ -7,7 +7,7 @@
* @author Prospress
* @category Core
* @package WooCommerce Subscriptions/Functions
- * @version 2.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -27,7 +27,7 @@ if ( ! defined( 'ABSPATH' ) ) {
* 'trial_length': The total number of periods the subscription trial period should continue for. Default 0, meaning no trial period.
* 'trial_period': The temporal period for the subscription's trial period. Should be one of {day|week|month|year} as used by @see wcs_get_subscription_period_strings()
* 'use_per_slash': Allow calling code to determine if they want the shorter price string using a slash for singular billing intervals, e.g. $5 / month, or the longer form, e.g. $5 every month, which is normally reserved for intervals > 1
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
* @return string The price string with translated and billing periods included
*/
function wcs_price_string( $subscription_details ) {
@@ -232,7 +232,7 @@ function wcs_price_string( $subscription_details ) {
*
* @param int $timestamp_gmt
* @return string A human friendly string to display for the timestamp's date
- * @since 2.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1
*/
function wcs_get_human_time_diff( $timestamp_gmt ) {
@@ -260,7 +260,7 @@ function wcs_get_human_time_diff( $timestamp_gmt ) {
* @param string $content Content to filter through kses.
* @param array $allowed_html List of allowed HTML elements.
* @return string Filtered string of HTML.
- * @since 2.2.17
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.17
*/
function wp_kses_allow_underscores( $content, $allowed_html ) {
@@ -283,7 +283,7 @@ function wp_kses_allow_underscores( $content, $allowed_html ) {
*
* eg. Given 2, the function returns 2nd.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*
* @param string The number to append the ordinal suffix to.
* @return string
diff --git a/vendor/woocommerce/subscriptions-core/includes/wcs-helper-functions.php b/vendor/woocommerce/subscriptions-core/includes/wcs-helper-functions.php
index 1dec874..973861d 100644
--- a/vendor/woocommerce/subscriptions-core/includes/wcs-helper-functions.php
+++ b/vendor/woocommerce/subscriptions-core/includes/wcs-helper-functions.php
@@ -5,7 +5,7 @@
* @author Prospress
* @category Core
* @package WooCommerce Subscriptions/Functions
- * @version 2.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -23,7 +23,7 @@ if ( ! defined( 'ABSPATH' ) ) {
* 'include_time': (bool) whether to include a specific time for the selector. Default true.
* 'include_year': (bool) whether to include a the year field. Default true.
* 'include_buttons': (bool) whether to include submit buttons on the selector. Default true.
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_date_input( $timestamp = 0, $args = array() ) {
@@ -59,7 +59,7 @@ function wcs_date_input( $timestamp = 0, $args = array() ) {
* Get the edit post link without checking if the user can edit that post or not.
*
* @param int $post_id
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_get_edit_post_link( $post_id ) {
$object = wc_get_order( $post_id ); // works for both WC Order and WC Subscription objects.
@@ -81,7 +81,7 @@ function wcs_get_edit_post_link( $post_id ) {
*
* @param string $string string to make ASCII
* @return string|null ASCII string or null if error occurred
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_str_to_ascii( $string ) {
@@ -166,7 +166,7 @@ function wcs_get_rounding_precision() {
*
* @param string
* @param string
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @return string
*/
function wcs_maybe_prefix_key( $key, $prefix = '_' ) {
@@ -178,7 +178,7 @@ function wcs_maybe_prefix_key( $key, $prefix = '_' ) {
*
* @param string $key
* @param string $prefix
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @return string
*/
function wcs_maybe_unprefix_key( $key, $prefix = '_' ) {
@@ -188,7 +188,7 @@ function wcs_maybe_unprefix_key( $key, $prefix = '_' ) {
/**
* Find the name of the function which called the function which called this function.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @return string
*/
function wcs_get_calling_function_name() {
@@ -227,7 +227,7 @@ function wcs_get_transient_even_if_expired( $transient_key ) {
*
* @param string $version Version string (eg 1.0.1).
* @return string The minor release version string (eg 1.0).
- * @since 2.3.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.0
*/
function wcs_get_minor_version_string( $version ) {
$version_parts = array_pad( array_map( 'intval', explode( '.', $version ) ), 2, 0 );
@@ -240,7 +240,7 @@ function wcs_get_minor_version_string( $version ) {
*
* The logic in this function is based off WooCommerce::is_request( 'frontend' ).
*
- * @since 2.5.7
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.7
*
* @return bool True if it's a frontend request, false otherwise.
*/
@@ -251,7 +251,7 @@ function wcs_is_frontend_request() {
/**
* Sorts an array of objects by a given property in a given order.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*
* @param array $objects An array of objects to sort.
* @param string $property The property to sort by.
@@ -275,7 +275,7 @@ function wcs_sort_objects( &$objects, $property, $sort_order = 'ascending' ) {
* @param int|WC_Subscription $subscription
*
* @return bool|WP_Error
- * @since 3.0.6
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.0.6
*/
function wcs_trial_has_passed( $subscription ) {
$subscription = wcs_get_subscription( $subscription );
@@ -293,7 +293,7 @@ function wcs_trial_has_passed( $subscription ) {
* This function behaves similar to PHP's array_filter(), except instead of a callback it uses a filter.
* This allows third-parties via WP filter callbacks to filter the array.
*
- * @since 3.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
*
* @param string $filter The WP filter to apply to each element.
* @param array $array The array of items to check.
@@ -311,3 +311,41 @@ function wcs_apply_array_filter( $filter, $array, $property = '' ) {
return $array;
}
+
+/**
+ * Compares an order's billing address and shipping address and returns true if they are the same.
+ *
+ * @since 5.3.0
+ *
+ * @see woocommerce_ship_to_different_address_checked
+ *
+ * @param WC_Order $order
+ * @return bool True if the order's billing address and shipping address are the same, false otherwise.
+ */
+function wcs_compare_order_billing_shipping_address( $order ) {
+ $billing_address = $order->get_address( 'billing' );
+ $shipping_address = $order->get_address( 'shipping' );
+
+ // Remove extraneous fields from each address when comparing
+ if ( isset( $billing_address['email'] ) ) {
+ unset( $billing_address['email'] );
+ }
+
+ if ( isset( $billing_address['phone'] ) ) {
+ unset( $billing_address['phone'] );
+ }
+
+ if ( isset( $shipping_address['email'] ) ) {
+ unset( $shipping_address['email'] );
+ }
+
+ if ( isset( $shipping_address['phone'] ) ) {
+ unset( $shipping_address['phone'] );
+ }
+
+ // Compare the two addresses using array equality operator.
+ // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- using `==` is suitable here to ignore the order of array keys.
+ $addresses_are_equal = $shipping_address == $billing_address;
+
+ return $addresses_are_equal;
+}
diff --git a/vendor/woocommerce/subscriptions-core/includes/wcs-limit-functions.php b/vendor/woocommerce/subscriptions-core/includes/wcs-limit-functions.php
index f5e269d..d06f657 100644
--- a/vendor/woocommerce/subscriptions-core/includes/wcs-limit-functions.php
+++ b/vendor/woocommerce/subscriptions-core/includes/wcs-limit-functions.php
@@ -5,7 +5,7 @@
* @author Prospress
* @category Core
* @package WooCommerce Subscriptions/Functions
- * @version 2.1
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.1
*/
if ( ! defined( 'ABSPATH' ) ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/wcs-order-functions.php b/vendor/woocommerce/subscriptions-core/includes/wcs-order-functions.php
index 6710f66..a880b16 100644
--- a/vendor/woocommerce/subscriptions-core/includes/wcs-order-functions.php
+++ b/vendor/woocommerce/subscriptions-core/includes/wcs-order-functions.php
@@ -5,7 +5,7 @@
* @author Prospress
* @category Core
* @package WooCommerce Subscriptions/Functions
- * @version 2.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -27,7 +27,7 @@ if ( ! defined( 'ABSPATH' ) ) {
* 'subscription_status' Any valid subscription status. Can be 'any', 'active', 'cancelled', 'on-hold', 'expired', 'pending' or 'trash'. Defaults to 'any'.
* 'order_type' Get subscriptions for the any order type in this array. Can include 'any', 'parent', 'renewal' or 'switch', defaults to parent.
* @return WC_Subscription[] Subscription details in post_id => WC_Subscription form.
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_get_subscriptions_for_order( $order, $args = array() ) {
@@ -59,10 +59,11 @@ function wcs_get_subscriptions_for_order( $order, $args = array() ) {
if ( $get_all || in_array( 'parent', $args['order_type'] ) ) {
$get_subscriptions_args = array_merge( $args, array(
- 'order_id' => wcs_get_objects_property( $order, 'id' ),
+ 'order_id' => $order->get_id(),
) );
$subscriptions = wcs_get_subscriptions( $get_subscriptions_args );
+
}
$all_relation_types = WCS_Related_Order_Store::instance()->get_relation_types();
@@ -83,66 +84,59 @@ function wcs_get_subscriptions_for_order( $order, $args = array() ) {
}
/**
- * Copy the billing, shipping or all addresses from one order to another (including custom order types, like the
- * WC_Subscription order type).
+ * Copy the billing, shipping or all addresses from one order or subscription to another.
+ *
+ * @since 2.0.0
+ *
+ * @param WC_Order $to_order The WC_Order object to copy the address to.
+ * @param WC_Order $from_order The WC_Order object to copy the address from.
+ * @param string $address_type The address type to copy, can be 'shipping', 'billing' or 'all'. Optional. Default is "all".
*
- * @param WC_Order $to_order The WC_Order object to copy the address to.
- * @param WC_Order $from_order The WC_Order object to copy the address from.
- * @param string $address_type The address type to copy, can be 'shipping', 'billing' or 'all'
* @return WC_Order The WC_Order object with the new address set.
- * @since 2.0
*/
function wcs_copy_order_address( $from_order, $to_order, $address_type = 'all' ) {
- if ( in_array( $address_type, array( 'shipping', 'all' ) ) ) {
- $to_order->set_address( array(
- 'first_name' => wcs_get_objects_property( $from_order, 'shipping_first_name' ),
- 'last_name' => wcs_get_objects_property( $from_order, 'shipping_last_name' ),
- 'company' => wcs_get_objects_property( $from_order, 'shipping_company' ),
- 'address_1' => wcs_get_objects_property( $from_order, 'shipping_address_1' ),
- 'address_2' => wcs_get_objects_property( $from_order, 'shipping_address_2' ),
- 'city' => wcs_get_objects_property( $from_order, 'shipping_city' ),
- 'state' => wcs_get_objects_property( $from_order, 'shipping_state' ),
- 'postcode' => wcs_get_objects_property( $from_order, 'shipping_postcode' ),
- 'country' => wcs_get_objects_property( $from_order, 'shipping_country' ),
- ), 'shipping' );
+ if ( 'all' === $address_type || 'shipping' === $address_type ) {
+ $to_order->set_shipping_first_name( $from_order->get_shipping_first_name() );
+ $to_order->set_shipping_last_name( $from_order->get_shipping_last_name() );
+ $to_order->set_shipping_company( $from_order->get_shipping_company() );
+ $to_order->set_shipping_address_1( $from_order->get_shipping_address_1() );
+ $to_order->set_shipping_address_2( $from_order->get_shipping_address_2() );
+ $to_order->set_shipping_city( $from_order->get_shipping_city() );
+ $to_order->set_shipping_state( $from_order->get_shipping_state() );
+ $to_order->set_shipping_postcode( $from_order->get_shipping_postcode() );
+ $to_order->set_shipping_country( $from_order->get_shipping_country() );
}
- if ( in_array( $address_type, array( 'billing', 'all' ) ) ) {
- $to_order->set_address( array(
- 'first_name' => wcs_get_objects_property( $from_order, 'billing_first_name' ),
- 'last_name' => wcs_get_objects_property( $from_order, 'billing_last_name' ),
- 'company' => wcs_get_objects_property( $from_order, 'billing_company' ),
- 'address_1' => wcs_get_objects_property( $from_order, 'billing_address_1' ),
- 'address_2' => wcs_get_objects_property( $from_order, 'billing_address_2' ),
- 'city' => wcs_get_objects_property( $from_order, 'billing_city' ),
- 'state' => wcs_get_objects_property( $from_order, 'billing_state' ),
- 'postcode' => wcs_get_objects_property( $from_order, 'billing_postcode' ),
- 'country' => wcs_get_objects_property( $from_order, 'billing_country' ),
- 'email' => wcs_get_objects_property( $from_order, 'billing_email' ),
- 'phone' => wcs_get_objects_property( $from_order, 'billing_phone' ),
- ), 'billing' );
+ if ( 'all' === $address_type || 'billing' === $address_type ) {
+ $to_order->set_billing_first_name( $from_order->get_billing_first_name() );
+ $to_order->set_billing_last_name( $from_order->get_billing_last_name() );
+ $to_order->set_billing_company( $from_order->get_billing_company() );
+ $to_order->set_billing_address_1( $from_order->get_billing_address_1() );
+ $to_order->set_billing_address_2( $from_order->get_billing_address_2() );
+ $to_order->set_billing_city( $from_order->get_billing_city() );
+ $to_order->set_billing_state( $from_order->get_billing_state() );
+ $to_order->set_billing_postcode( $from_order->get_billing_postcode() );
+ $to_order->set_billing_country( $from_order->get_billing_country() );
+ $to_order->set_billing_email( $from_order->get_billing_email() );
+ $to_order->set_billing_phone( $from_order->get_billing_phone() );
}
+ $to_order->save();
+
return apply_filters( 'woocommerce_subscriptions_copy_order_address', $to_order, $from_order, $address_type );
}
/**
- * Utility function to copy order meta between two orders. Originally intended to copy meta between
- * first order and subscription object, then between subscription and renewal orders.
+ * Copies order meta between two order objects (orders or subscriptions).
*
- * The hooks used here in those cases are
- * - wcs_subscription_meta_query
- * - wcs_subscription_meta
- * - wcs_renewal_order_meta_query
- * - wcs_renewal_order_meta
+ * Intended to copy meta between first order and subscription object, then between subscription and renewal orders.
*
- * @param WC_Order $from_order Order to copy meta from
- * @param WC_Order $to_order Order to copy meta to
- * @param string $type type of copy
+ * @param WC_Order $from_order Order|Subscription to copy meta from.
+ * @param WC_Order $to_order Order|Subscription to copy meta to.
+ * @param string $type The type of copy. Can be 'subscription' or 'renewal'. Optional. Default is 'subscription'.
*/
function wcs_copy_order_meta( $from_order, $to_order, $type = 'subscription' ) {
- global $wpdb;
if ( ! is_a( $from_order, 'WC_Abstract_Order' ) || ! is_a( $to_order, 'WC_Abstract_Order' ) ) {
throw new InvalidArgumentException( _x( 'Invalid data. Orders expected aren\'t orders.', 'In wcs_copy_order_meta error message. Refers to origin and target order objects.', 'woocommerce-subscriptions' ) );
@@ -156,58 +150,7 @@ function wcs_copy_order_meta( $from_order, $to_order, $type = 'subscription' ) {
$type = 'copy_order';
}
- $meta_query = $wpdb->prepare(
- "SELECT `meta_key`, `meta_value`
- FROM {$wpdb->postmeta}
- WHERE `post_id` = %d
- AND `meta_key` NOT LIKE '_schedule_%%'
- AND `meta_key` NOT IN (
- '_paid_date',
- '_date_paid',
- '_completed_date',
- '_date_completed',
- '_edit_last',
- '_subscription_switch_data',
- '_order_key',
- '_edit_lock',
- '_wc_points_earned',
- '_transaction_id',
- '_billing_interval',
- '_billing_period',
- '_subscription_resubscribe',
- '_subscription_renewal',
- '_subscription_switch',
- '_payment_method',
- '_payment_method_title',
- '_suspension_count',
- '_requires_manual_renewal',
- '_cancelled_email_sent',
- '_trial_period',
- '_created_via',
- '_order_stock_reduced'
- )",
- wcs_get_objects_property( $from_order, 'id' )
- );
-
- if ( in_array( $type, array( 'renewal_order', 'parent' ) ) ) {
- $meta_query .= " AND `meta_key` NOT LIKE '_download_permissions_granted' ";
- }
-
- // Allow extensions to add/remove order meta
- $meta_query = apply_filters( 'wcs_' . $type . '_meta_query', $meta_query, $to_order, $from_order );
- $meta = $wpdb->get_results( $meta_query, 'ARRAY_A' );
- $meta = apply_filters( 'wcs_' . $type . '_meta', $meta, $to_order, $from_order );
-
- // Pre WC 3.0 we need to save each meta individually, post 3.0 we can save the object once
- $save = wcs_is_woocommerce_pre( '3.0' ) ? 'save' : 'set_prop_only';
-
- foreach ( $meta as $meta_item ) {
- wcs_set_objects_property( $to_order, $meta_item['meta_key'], maybe_unserialize( $meta_item['meta_value'] ), $save, '', 'omit_key_prefix' );
- }
-
- if ( is_callable( array( $to_order, 'save' ) ) ) {
- $to_order->save();
- }
+ WC_Subscriptions_Data_Copier::copy( $from_order, $to_order, $type );
}
/**
@@ -271,7 +214,17 @@ function wcs_create_order_from_subscription( $subscription, $type ) {
// If we got here, the subscription was created without problems
$transaction->commit();
- return apply_filters( 'wcs_new_order_created', $new_order, $subscription, $type );
+ /**
+ * Filters the new order created from the subscription.
+ *
+ * Fetches a fresh instance of the order because the current order instance has an empty line item cache generated before we had copied the line items.
+ * Fetching a new instance will ensure the line items are available via $new_order->get_items().
+ *
+ * @param WC_Order $new_order The new order created from the subscription.
+ * @param WC_Subscription $subscription The subscription the order was created from.
+ * @param string $type The type of order being created. Either 'renewal_order' or 'resubscribe_order'.
+ */
+ return apply_filters( 'wcs_new_order_created', wc_get_order( $new_order->get_id() ), $subscription, $type );
} catch ( Exception $e ) {
// There was an error adding the subscription
@@ -380,7 +333,7 @@ function wcs_get_order_address( $order, $address_type = 'shipping' ) {
* @param mixed $order A WC_Order object or the ID of the order which the subscription was purchased in.
* @param array|string $order_type Can include 'parent', 'renewal', 'resubscribe' and/or 'switch'. Defaults to 'parent', 'resubscribe' and 'switch' orders.
* @return bool True if the order contains a subscription that belongs to any of the given order types, otherwise false.
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_order_contains_subscription( $order, $order_type = array( 'parent', 'resubscribe', 'switch' ) ) {
@@ -391,21 +344,25 @@ function wcs_order_contains_subscription( $order, $order_type = array( 'parent',
if ( ! is_a( $order, 'WC_Abstract_Order' ) ) {
$order = wc_get_order( $order );
+
+ if ( ! $order ) {
+ return false;
+ }
}
$contains_subscription = false;
- $get_all = in_array( 'any', $order_type );
+ $get_all = in_array( 'any', $order_type, true );
- if ( ( in_array( 'parent', $order_type ) || $get_all ) && count( wcs_get_subscriptions_for_order( wcs_get_objects_property( $order, 'id' ), array( 'order_type' => 'parent' ) ) ) > 0 ) {
+ if ( ( in_array( 'parent', $order_type, true ) || $get_all ) && count( wcs_get_subscriptions_for_order( $order->get_id(), array( 'order_type' => 'parent' ) ) ) > 0 ) {
$contains_subscription = true;
- } elseif ( ( in_array( 'renewal', $order_type ) || $get_all ) && wcs_order_contains_renewal( $order ) ) {
+ } elseif ( ( in_array( 'renewal', $order_type, true ) || $get_all ) && wcs_order_contains_renewal( $order ) ) {
$contains_subscription = true;
- } elseif ( ( in_array( 'resubscribe', $order_type ) || $get_all ) && wcs_order_contains_resubscribe( $order ) ) {
+ } elseif ( ( in_array( 'resubscribe', $order_type, true ) || $get_all ) && wcs_order_contains_resubscribe( $order ) ) {
$contains_subscription = true;
- } elseif ( ( in_array( 'switch', $order_type ) || $get_all ) && wcs_order_contains_switch( $order ) ) {
+ } elseif ( ( in_array( 'switch', $order_type, true ) || $get_all ) && wcs_order_contains_switch( $order ) ) {
$contains_subscription = true;
}
@@ -413,6 +370,67 @@ function wcs_order_contains_subscription( $order, $order_type = array( 'parent',
return $contains_subscription;
}
+/**
+ * Fetches Orders and Subscriptions using wc_get_orders() with a built-in handler for the meta_query arg.
+ *
+ * This function is a replacement for the get_posts() function to help aid with transitioning over to using wc_get_orders.
+ * Args and usage: https://github.com/woocommerce/woocommerce/wiki/wc_get_orders-and-WC_Order_Query
+ *
+ * @since 5.0.0
+ *
+ * @param array $args Accepts the same arguments as wc_get_orders().
+ * @return array An array of WC_Order or WC_Subscription objects or IDs based on the args.
+ */
+function wcs_get_orders_with_meta_query( $args ) {
+ $is_hpos_in_use = wcs_is_custom_order_tables_usage_enabled();
+
+ // In CPT datastores, we have to hook into the orders query to insert any meta query args.
+ if ( ! $is_hpos_in_use ) {
+ $meta = $args['meta_query'] ?? [];
+ unset( $args['meta_query'] );
+
+ $handle_meta = function ( $query, $query_vars ) use ( $meta ) {
+ if ( [] === $meta ) {
+ return $query;
+ }
+
+ if ( ! isset( $query['meta_query'] ) ) {
+ $query['meta_query'] = $meta; // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
+ } else {
+ $query['meta_query'] = array_merge( $query['meta_query'], $meta ); // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
+ }
+
+ return $query;
+ };
+
+ add_filter( 'woocommerce_order_data_store_cpt_get_orders_query', $handle_meta, 10, 2 );
+ }
+
+ /**
+ * Map the 'any' status to wcs_get_subscription_statuses() in HPOS environments.
+ *
+ * In HPOS environments, the 'any' status now maps to wc_get_order_statuses() statuses. Whereas, in
+ * WP Post architecture 'any' meant any status except for ‘inherit’, ‘trash’ and ‘auto-draft’.
+ *
+ * If we're querying for subscriptions, we need to map 'any' to be all valid subscription statuses otherwise it would just search for order statuses.
+ */
+ if ( isset( $args['status'], $args['type'] ) &&
+ [ 'any' ] === (array) $args['status'] &&
+ 'shop_subscription' === $args['type'] &&
+ $is_hpos_in_use
+ ) {
+ $args['status'] = array_keys( wcs_get_subscription_statuses() );
+ }
+
+ $results = wc_get_orders( $args );
+
+ if ( ! $is_hpos_in_use ) {
+ remove_filter( 'woocommerce_order_data_store_cpt_get_orders_query', $handle_meta, 10 );
+ }
+
+ return $results;
+}
+
/**
* Get all the orders that relate to a subscription in some form (rather than only the orders associated with
* a specific subscription).
@@ -420,7 +438,7 @@ function wcs_order_contains_subscription( $order, $order_type = array( 'parent',
* @param string $return_fields The columns to return, either 'all' or 'ids'
* @param array|string $order_type Can include 'any', 'parent', 'renewal', 'resubscribe' and/or 'switch'. Defaults to 'parent'.
* @return array The orders that relate to a subscription, if any. Will contain either as just IDs or WC_Order objects depending on $return_fields value.
- * @since 2.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1
*/
function wcs_get_subscription_orders( $return_fields = 'ids', $order_type = 'parent' ) {
global $wpdb;
@@ -473,19 +491,24 @@ function wcs_get_subscription_orders( $return_fields = 'ids', $order_type = 'par
}
if ( count( $meta_query ) > 1 ) {
- $order_ids = array_merge( $order_ids, get_posts( array(
- 'posts_per_page' => -1,
- 'post_type' => 'shop_order',
- 'post_status' => 'any',
- 'fields' => 'ids',
- 'orderby' => 'ID',
- 'order' => 'DESC',
- 'meta_query' => $meta_query,
- ) ) );
+ $order_ids = array_merge(
+ $order_ids,
+ wcs_get_orders_with_meta_query(
+ [
+ 'limit' => -1,
+ 'type' => 'shop_order',
+ 'status' => 'any',
+ 'return' => 'ids',
+ 'orderby' => 'ID',
+ 'order' => 'DESC',
+ 'meta_query' => $meta_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
+ ]
+ )
+ );
}
}
- if ( 'all' == $return_fields ) {
+ if ( 'all' === $return_fields ) {
foreach ( $order_ids as $order_id ) {
$orders[ $order_id ] = wc_get_order( $order_id );
}
@@ -509,7 +532,7 @@ function wcs_get_subscription_orders( $return_fields = 'ids', $order_type = 'par
*
* @return WC_Order_Item|array The order item object or an empty array if the item doesn't exist.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_get_order_item( $item_id, $order ) {
@@ -539,7 +562,7 @@ function wcs_get_order_item( $item_id, $order ) {
* @param int $item_id The ID of an order item
* @param string $new_type The new type to set as the 'order_item_type' value on the order item.
* @param int $order_or_subscription_id The order or subscription ID the line item belongs to - optional. Deletes the order item cache if provided.
- * @since 2.2.12
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.12
*/
function wcs_update_order_item_type( $item_id, $new_type, $order_or_subscription_id = 0 ) {
wc_update_order_item( $item_id, array( 'order_item_type' => $new_type ) );
@@ -556,7 +579,7 @@ function wcs_update_order_item_type( $item_id, $new_type, $order_or_subscription
*
* @param array
* @return WC_Order_Item_Meta
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_get_order_item_meta( $item, $product = null ) {
if ( false === wcs_is_woocommerce_pre( '3.0' ) ) {
@@ -569,7 +592,7 @@ function wcs_get_order_item_meta( $item, $product = null ) {
* Create a string representing an order item's name and optionally include attributes.
*
* @param array $order_item An order item.
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_get_order_item_name( $order_item, $include = array() ) {
@@ -684,7 +707,7 @@ function wcs_get_line_item_name( $line_item ) {
/**
* Display item meta data in a version compatible way.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @param WC_Item $item
* @param WC_Order $order
* @return void
@@ -700,7 +723,7 @@ function wcs_display_item_meta( $item, $order ) {
/**
* Display item download links in a version compatible way.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @param WC_Item $item
* @param WC_Order $order
* @return void
@@ -718,7 +741,7 @@ function wcs_display_item_downloads( $item, $order ) {
/**
* Copy the order item data and meta data from one item to another.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @param WC_Order_Item $from_item The order item to copy data from
* @param WC_Order_Item $to_item The order item to copy data to
*/
@@ -805,7 +828,7 @@ function wcs_copy_order_item( $from_item, &$to_item ) {
/**
* Checks an order to see if it contains a manual subscription.
*
- * @since 2.4.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.4.3
* @param WC_Order|int $order The WC_Order object or ID to get related subscriptions from.
* @param string|array $order_type The order relationship type(s). Can be single string or an array of order types. Optional. Default is 'any'.
* @return bool
@@ -827,7 +850,7 @@ function wcs_order_contains_manual_subscription( $order, $order_type = 'any' ) {
/**
* Copy payment method from a subscription to an order.
*
- * @since 2.4.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.4.3
* @param WC_Subscription $subscription
* @param WC_Order $order
*/
@@ -854,7 +877,7 @@ function wcs_copy_payment_method_to_order( $subscription, $order ) {
* @param WC_Order $order
*
* @return int
- * @since 2.5.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.3
*/
function wcs_minutes_since_order_created( $order ) {
$now = new WC_DateTime( 'now', $order->get_date_created()->getTimezone() );
@@ -869,7 +892,7 @@ function wcs_minutes_since_order_created( $order ) {
* @param WC_Order $order
*
* @return int
- * @since 2.5.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.3
*/
function wcs_seconds_since_order_created( $order ) {
return time() - $order->get_date_created()->getTimestamp();
@@ -878,7 +901,7 @@ function wcs_seconds_since_order_created( $order ) {
/**
* Finds a corresponding subscription line item on an order.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*
* @param WC_Abstract_Order $order The order object to look for the item in.
* @param WC_Order_Item $subscription_item The line item on the the subscription to find on the order.
@@ -915,7 +938,7 @@ function wcs_find_matching_line_item( $order, $subscription_item, $match_type =
/**
* Checks if an order contains a product.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*
* @param WC_Order $order An order object
* @param WC_Product $product A product object
@@ -940,7 +963,7 @@ function wcs_order_contains_product( $order, $product ) {
* Check if a given order is a subscription renewal order.
*
* @param WC_Order|int $order The WC_Order object or ID of a WC_Order order.
- * @since 2.3.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.0
* @return bool True if the order contains an early renewal, otherwise false.
*/
function wcs_order_contains_early_renewal( $order ) {
@@ -955,7 +978,7 @@ function wcs_order_contains_early_renewal( $order ) {
/**
* Allow third-parties to filter whether this order contains the early renewal flag.
*
- * @since 2.3.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.0
* @param bool $is_renewal True if early renewal meta was found on the order, otherwise false.
* @param WC_Order $order The WC_Order object.
*/
diff --git a/vendor/woocommerce/subscriptions-core/includes/wcs-product-functions.php b/vendor/woocommerce/subscriptions-core/includes/wcs-product-functions.php
index fe77559..81bb6ea 100644
--- a/vendor/woocommerce/subscriptions-core/includes/wcs-product-functions.php
+++ b/vendor/woocommerce/subscriptions-core/includes/wcs-product-functions.php
@@ -7,13 +7,13 @@
* @author Prospress
* @category Core
* @package WooCommerce Subscriptions/Functions
- * @version 2.2.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
/**
* For a given product, and optionally price/qty, work out the sign-up with tax included, based on store settings.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @param WC_Product $product
* @param array $args
* @return float
@@ -37,7 +37,7 @@ function wcs_get_price_including_tax( $product, $args = array() ) {
/**
* For a given product, and optionally price/qty, work out the sign-up fee with tax excluded, based on store settings.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @param WC_Product $product
* @param array $args
* @return float
@@ -61,7 +61,7 @@ function wcs_get_price_excluding_tax( $product, $args = array() ) {
/**
* Returns a 'from' prefix if you want to show where prices start at.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @return string
*/
function wcs_get_price_html_from_text( $product = '' ) {
@@ -78,7 +78,7 @@ function wcs_get_price_html_from_text( $product = '' ) {
/**
* Get an array of the prices, used to help determine min/max values.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
function wcs_get_variation_prices( $variation, $variable_product ) {
@@ -95,7 +95,7 @@ function wcs_get_variation_prices( $variation, $variable_product ) {
*
* @param array $child_variation_ids the IDs of product variation children ids
* @return array Array containing the min and max variation prices and billing data
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
function wcs_get_min_max_variation_data( $variable_product, $child_variation_ids = array() ) {
@@ -146,7 +146,7 @@ function wcs_get_min_max_variation_data( $variable_product, $child_variation_ids
*
* @param array $child_variation_ids the IDs of product variation children ids
* @return array
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
*/
function wcs_calculate_min_max_variations( $variations_data ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/wcs-renewal-functions.php b/vendor/woocommerce/subscriptions-core/includes/wcs-renewal-functions.php
index 0ca717c..f63b450 100644
--- a/vendor/woocommerce/subscriptions-core/includes/wcs-renewal-functions.php
+++ b/vendor/woocommerce/subscriptions-core/includes/wcs-renewal-functions.php
@@ -7,7 +7,7 @@
* @author Prospress
* @category Core
* @package WooCommerce Subscriptions/Functions
- * @version 2.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -22,7 +22,7 @@ if ( ! defined( 'ABSPATH' ) ) {
*
* @param int | WC_Subscription $subscription Post ID of a 'shop_subscription' post, or instance of a WC_Subscription object
* @return WC_Order | WP_Error
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_create_renewal_order( $subscription ) {
@@ -42,7 +42,7 @@ function wcs_create_renewal_order( $subscription ) {
* Check if a given order is a subscription renewal order.
*
* @param WC_Order|int $order The WC_Order object or ID of a WC_Order order.
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_order_contains_renewal( $order ) {
@@ -66,7 +66,7 @@ function wcs_order_contains_renewal( $order ) {
*
* @param bool | Array The cart item containing the renewal, else false.
* @return string
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_cart_contains_renewal() {
@@ -88,7 +88,7 @@ function wcs_cart_contains_renewal() {
* Checks the cart to see if it contains a subscription product renewal for a failed renewal payment.
*
* @return bool|array The cart item containing the renewal, else false.
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_cart_contains_failed_renewal_order_payment() {
@@ -111,7 +111,7 @@ function wcs_cart_contains_failed_renewal_order_payment() {
* Get the subscription/s to which a resubscribe order relates.
*
* @param WC_Order|int $order The WC_Order object or ID of a WC_Order order.
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_get_subscriptions_for_renewal_order( $order ) {
return wcs_get_subscriptions_for_order( $order, array( 'order_type' => 'renewal' ) );
@@ -120,7 +120,7 @@ function wcs_get_subscriptions_for_renewal_order( $order ) {
/**
* Get the last renewal order which isn't an early renewal order.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*
* @param WC_Subscription $subscription The subscription object.
* @return WC_Order|bool The last non-early renewal order, otherwise false.
@@ -145,7 +145,7 @@ function wcs_get_last_non_early_renewal_order( $subscription ) {
/**
* Checks if manual renewals are required - automatic renewals are disabled.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
* @return bool Weather manual renewal are required.
*/
function wcs_is_manual_renewal_required() {
@@ -155,7 +155,7 @@ function wcs_is_manual_renewal_required() {
/**
* Checks if manual renewals are enabled.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
* @return bool Weather manual renewal are enabled.
*/
function wcs_is_manual_renewal_enabled() {
diff --git a/vendor/woocommerce/subscriptions-core/includes/wcs-resubscribe-functions.php b/vendor/woocommerce/subscriptions-core/includes/wcs-resubscribe-functions.php
index 2faea23..a4200d9 100644
--- a/vendor/woocommerce/subscriptions-core/includes/wcs-resubscribe-functions.php
+++ b/vendor/woocommerce/subscriptions-core/includes/wcs-resubscribe-functions.php
@@ -7,7 +7,7 @@
* @author Prospress
* @category Core
* @package WooCommerce Subscriptions/Functions
- * @version 2.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -18,7 +18,7 @@ if ( ! defined( 'ABSPATH' ) ) {
* Check if a given order was created to resubscribe to a cancelled or expired subscription.
*
* @param WC_Order|int $order The WC_Order object or ID of a WC_Order order.
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_order_contains_resubscribe( $order ) {
@@ -46,7 +46,7 @@ function wcs_order_contains_resubscribe( $order ) {
*
* @param int | WC_Subscription $subscription Post ID of a 'shop_subscription' post, or instance of a WC_Subscription object
* @return WC_Subscription
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_create_resubscribe_order( $subscription ) {
@@ -68,7 +68,7 @@ function wcs_create_resubscribe_order( $subscription ) {
*
* @param int | WC_Subscription $subscription Post ID of a 'shop_subscription' post, or instance of a WC_Subscription object
* @return string
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_get_users_resubscribe_link( $subscription ) {
@@ -84,7 +84,7 @@ function wcs_get_users_resubscribe_link( $subscription ) {
* Returns a URL including required parameters for an authenticated user to renew a subscription by product ID.
*
* @param int $product_id The ID of a product post type.
- * @since 1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.2
*/
function wcs_get_users_resubscribe_link_for_product( $product_id ) {
@@ -109,7 +109,7 @@ function wcs_get_users_resubscribe_link_for_product( $product_id ) {
*
* @param bool | Array The cart item containing the renewal, else false.
* @return string
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_cart_contains_resubscribe( $cart = '' ) {
@@ -135,7 +135,7 @@ function wcs_cart_contains_resubscribe( $cart = '' ) {
* Get the subscription to which a renewal order relates.
*
* @param WC_Order|int $order The WC_Order object or ID of a WC_Order order.
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_get_subscriptions_for_resubscribe_order( $order ) {
return wcs_get_subscriptions_for_order( $order, array( 'order_type' => 'resubscribe' ) );
@@ -158,7 +158,7 @@ function wcs_get_subscriptions_for_resubscribe_order( $order ) {
* @param int | WC_Subscription $subscription Post ID of a 'shop_subscription' post, or instance of a WC_Subscription object
* @param int The ID of a user
* @return bool
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_can_user_resubscribe_to( $subscription, $user_id = '' ) {
diff --git a/vendor/woocommerce/subscriptions-core/includes/wcs-switch-functions.php b/vendor/woocommerce/subscriptions-core/includes/wcs-switch-functions.php
index 6f1c60b..261c1a3 100644
--- a/vendor/woocommerce/subscriptions-core/includes/wcs-switch-functions.php
+++ b/vendor/woocommerce/subscriptions-core/includes/wcs-switch-functions.php
@@ -5,7 +5,7 @@
* @author Prospress
* @category Core
* @package WooCommerce Subscriptions/Functions
- * @version 2.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -16,7 +16,7 @@ if ( ! defined( 'ABSPATH' ) ) {
* Check if a given order was to switch a subscription
*
* @param WC_Order|int $order The WC_Order object or ID of a WC_Order order.
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_order_contains_switch( $order ) {
@@ -47,7 +47,7 @@ function wcs_order_contains_switch( $order ) {
*
* @param int|WC_Order $order_id The post_id of a shop_order post or an instance of a WC_Order object
* @return array Subscription details in post_id => WC_Subscription form.
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_get_subscriptions_for_switch_order( $order ) {
return wcs_get_subscriptions_for_order( $order, array( 'order_type' => 'switch' ) );
@@ -58,7 +58,7 @@ function wcs_get_subscriptions_for_switch_order( $order ) {
*
* @param int|WC_Subscription $subscription_id The post_id of a shop_subscription post or an instance of a WC_Subscription object
* @return array Order details in post_id => WC_Order form.
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_get_switch_orders_for_subscription( $subscription_id ) {
$subscription = wcs_get_subscription( $subscription_id );
@@ -70,7 +70,7 @@ function wcs_get_switch_orders_for_subscription( $subscription_id ) {
*
* @param int|WC_Product $product A WC_Product object or the ID of a product to check
* @return bool
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_is_product_switchable_type( $product ) {
@@ -117,7 +117,7 @@ function wcs_is_product_switchable_type( $product ) {
/**
* Check if the cart includes any items which are to switch an existing subscription's contents.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
* @param string $item_action Types of items to include ("any", "switch", or "add").
* @return bool|array Returns cart items that modify subscription contents, or false if no such items exist.
*/
@@ -128,7 +128,7 @@ function wcs_cart_contains_switches( $item_action = 'any' ) {
/**
* Gets the switch direction of a cart item.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
* @param array $cart_item Cart item object.
* @return string|null Cart item subscription switch direction or null.
*/
diff --git a/vendor/woocommerce/subscriptions-core/includes/wcs-time-functions.php b/vendor/woocommerce/subscriptions-core/includes/wcs-time-functions.php
index c0ff897..f69febe 100644
--- a/vendor/woocommerce/subscriptions-core/includes/wcs-time-functions.php
+++ b/vendor/woocommerce/subscriptions-core/includes/wcs-time-functions.php
@@ -7,7 +7,7 @@
* @author Prospress
* @category Core
* @package WooCommerce Subscriptions/Functions
- * @version 2.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -20,7 +20,7 @@ if ( ! defined( 'ABSPATH' ) ) {
*
* @param int (optional) An interval in the range 1-6
* @param string (optional) One of day, week, month or year. If empty, all subscription ranges are returned.
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_get_subscription_period_strings( $number = 1, $period = '' ) {
@@ -48,7 +48,7 @@ function wcs_get_subscription_period_strings( $number = 1, $period = '' ) {
*
* @param int (optional) An interval in the range 1-6
* @param string (optional) One of day, week, month or year. If empty, all subscription ranges are returned.
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_get_subscription_trial_period_strings( $number = 1, $period = '' ) {
@@ -78,7 +78,7 @@ function wcs_get_subscription_trial_period_strings( $number = 1, $period = '' )
* M – for months; allowable range is 1 to 24
* Y – for years; allowable range is 1 to 5
*
- * @since 2.1.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1.2
*/
function wcs_get_non_cached_subscription_ranges() {
@@ -152,7 +152,7 @@ function wcs_get_subscription_ranges( $subscription_period = '' ) {
* Return an i18n'ified associative array of all possible subscription periods.
*
* @param int (optional) An interval in the range 1-6
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_get_subscription_period_interval_strings( $interval = '' ) {
@@ -176,7 +176,7 @@ function wcs_get_subscription_period_interval_strings( $interval = '' ) {
* Return an i18n'ified associative array of all time periods allowed for subscriptions.
*
* @param string (Optional) Either 'singular' for singular trial periods or 'plural'.
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_get_available_time_periods( $form = 'singular' ) {
@@ -200,7 +200,7 @@ function wcs_get_available_time_periods( $form = 'singular' ) {
* Returns an array of allowed trial period lengths.
*
* @param string (optional) One of day, week, month or year. If empty, all subscription trial period lengths are returned.
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_get_subscription_trial_lengths( $subscription_period = '' ) {
@@ -224,7 +224,7 @@ function wcs_get_subscription_trial_lengths( $subscription_period = '' ) {
* @param string $period One of day, week, month or year.
* @param int $from_timestamp A Unix timestamp to add the time too.
* @param string $timezone_behaviour Optional. If the $from_timestamp parameter should be offset to the site time or not, either 'offset_site_time' or 'no_offset'. Default 'no_offset'.
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_add_time( $number_of_periods, $period, $from_timestamp, $timezone_behaviour = 'no_offset' ) {
@@ -254,7 +254,7 @@ function wcs_add_time( $number_of_periods, $period, $from_timestamp, $timezone_b
* @param int $from_timestamp A Unix timestamp to add the months too.
* @param int $months_to_add The number of months to add to the timestamp.
* @param string $timezone_behaviour Optional. If the $from_timestamp parameter should be offset to the site time or not, either 'offset_site_time' or 'no_offset'. Default 'no_offset'.
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_add_months( $from_timestamp, $months_to_add, $timezone_behaviour = 'no_offset' ) {
@@ -290,7 +290,7 @@ function wcs_add_months( $from_timestamp, $months_to_add, $timezone_behaviour =
* @param int $end_timestamp A Unix timestamp at some time in the future
* @param string $unit_of_time A unit of time, either day, week month or year.
* @param string $rounding_method A rounding method, either ceil (default) or floor for anything else
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_estimate_periods_between( $start_timestamp, $end_timestamp, $unit_of_time = 'month', $rounding_method = 'ceil' ) {
@@ -618,29 +618,28 @@ function wcs_sort_by_fractions( $a, $b ) {
}
/**
- * PHP on Windows does not have strptime function. Therefore this is what we're using to check
- * whether the given time is of a specific format.
+ * Validate whether a given datetime matches the mysql pattern of YYYY-MM-DD HH:MM:SS
+ * This function will return false when the date or time is invalid (e.g. 2015-02-29 00:00:00)
*
* @param string $time the mysql time string
- * @return boolean true if it matches our mysql pattern of YYYY-MM-DD HH:MM:SS
+ * @return boolean if the string is valid
*/
function wcs_is_datetime_mysql_format( $time ) {
if ( ! is_string( $time ) ) {
return false;
}
- if ( function_exists( 'strptime' ) ) {
- $valid_time = $match = ( false !== strptime( $time, '%Y-%m-%d %H:%M:%S' ) );
- } else {
- // parses for the pattern of YYYY-MM-DD HH:MM:SS, but won't check whether it's a valid timedate
- $match = preg_match( '/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/', $time );
+ $format = 'Y-m-d H:i:s';
- // parses time, returns false for invalid dates
- $valid_time = wcs_date_to_time( $time );
- }
+ $date_object = DateTime::createFromFormat( $format, $time );
- // magic number -2209078800 is strtotime( '1900-01-00 00:00:00' ). Needed to achieve parity with strptime
- return $match && false !== $valid_time && -2209078800 <= $valid_time;
+ // DateTime::createFromFormat will return false if it is an invalid date.
+ return $date_object
+ // We also need to check the output of the format() method against the provided string as it will sometimes return
+ // the closest date. Passing `2022-02-29 01:02:03` will return `2022-03-01 01:02:03`
+ && $date_object->format( $format ) === $time
+ // we check the year is greater than or equal to 1900 as mysql will not accept dates before this.
+ && (int) $date_object->format( 'Y' ) >= 1900;
}
/**
@@ -730,7 +729,7 @@ function wcs_get_days_in_cycle( $period, $interval ) {
* Set a DateTime's timezone to the WordPress site's timezone, or a UTC offset
* if no timezone string is available.
*
- * @since 2.4.2
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.4.2
* @param WC_DateTime $date
* @return WC_DateTime
*/
@@ -751,7 +750,7 @@ function wcs_set_local_timezone( WC_DateTime $date ) {
* Get an instance of the site's timezone.
*
* @return DateTimeZone Timezone object for the timezone the site is using.
- * @deprecated 2.4.2
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions v2.4.2
*/
function wcs_get_sites_timezone() {
_deprecated_function( __FUNCTION__, '2.4.2' );
@@ -807,7 +806,7 @@ function wcs_get_sites_timezone() {
* Y – for years; allowable range is 1 to 5
*
* @param string (optional) One of day, week, month or year. If empty, all subscription ranges are returned.
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_get_subscription_ranges_tlc() {
_deprecated_function( __FUNCTION__, '2.1.2', 'wcs_get_non_cached_subscription_ranges' );
@@ -819,7 +818,7 @@ function wcs_get_subscription_ranges_tlc() {
* Take a date in the form of a timestamp, MySQL date/time string or DateTime object (or perhaps
* a WC_Datetime object when WC > 3.0 is active) and create a WC_DateTime object.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @param string|integer|null $date UTC timestamp, or ISO 8601 DateTime. If the DateTime string has no timezone or offset, WordPress site timezone will be assumed. Null if their is no date.
* @return null|WC_DateTime in site's timezone
*/
@@ -846,7 +845,7 @@ function wcs_get_datetime_from( $variable_date_type ) {
/**
* Get a MySQL date/time string in UTC timezone from a WC_Datetime object.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @param WC_DateTime
* @return string MySQL date/time string representation of the DateTime object in UTC timezone
*/
@@ -859,7 +858,7 @@ function wcs_get_datetime_utc_string( $datetime ) {
/**
* Format a date for output, a wrapper for wcs_format_datetime() introduced with WC 3.0.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @param WC_DateTime $date
* @param string $format Defaults to the wc_date_format function if not set.
* @return string
@@ -885,7 +884,7 @@ function wcs_format_datetime( $date, $format = '' ) {
/**
* Compares two periods and returns the longest period.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*
* @param string $current_period Period string. Can be 'day', 'week', 'month', 'year'.
* @param string $new_period Period string. Can be 'day', 'week', 'month', 'year'.
@@ -910,7 +909,7 @@ function wcs_get_longest_period( $current_period, $new_period ) {
/**
* Compares two periods and returns the shortest period.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*
* @param string $current_period A period string. Can be 'day', 'week', 'month', 'year'.
* @param string $new_period A period string. Can be 'day', 'week', 'month', 'year'.
diff --git a/vendor/woocommerce/subscriptions-core/includes/wcs-user-functions.php b/vendor/woocommerce/subscriptions-core/includes/wcs-user-functions.php
index 6d1d210..7cce6fd 100644
--- a/vendor/woocommerce/subscriptions-core/includes/wcs-user-functions.php
+++ b/vendor/woocommerce/subscriptions-core/includes/wcs-user-functions.php
@@ -5,7 +5,7 @@
* @author Prospress
* @category Core
* @package WooCommerce Subscriptions/Functions
- * @version 2.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -15,7 +15,7 @@ if ( ! defined( 'ABSPATH' ) ) {
/**
* Give a user the Subscription's default subscriber role
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_make_user_active( $user_id ) {
wcs_update_users_role( $user_id, 'default_subscriber_role' );
@@ -24,7 +24,7 @@ function wcs_make_user_active( $user_id ) {
/**
* Give a user the Subscription's default subscriber's inactive role
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_make_user_inactive( $user_id ) {
wcs_update_users_role( $user_id, 'default_inactive_role' );
@@ -33,7 +33,7 @@ function wcs_make_user_inactive( $user_id ) {
/**
* Give a user the Subscription's default subscriber's inactive role if they do not have an active subscription
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_maybe_make_user_inactive( $user_id ) {
if ( ! wcs_user_has_subscription( $user_id, '', 'active' ) ) {
@@ -45,7 +45,7 @@ function wcs_maybe_make_user_inactive( $user_id ) {
* Wrapper for wcs_maybe_make_user_inactive() that accepts a subscription instead of a user ID.
* Handy for hooks that pass a subscription object.
*
- * @since 2.2.9
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.9
* @param WC_Subscription|WC_Order
*/
function wcs_maybe_make_user_inactive_for( $subscription ) {
@@ -63,7 +63,7 @@ add_action( 'woocommerce_subscription_status_expired', 'wcs_maybe_make_user_inac
* @param int $user_id The ID of a user
* @param string $role_new The special name assigned to the role by Subscriptions, one of 'default_subscriber_role', 'default_inactive_role' or 'default_cancelled_role'
* @return WP_User The user with the new role.
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_update_users_role( $user_id, $role_new ) {
@@ -126,7 +126,7 @@ function wcs_get_new_user_role_names( $role_new ) {
* @param int $user_id (optional) The ID of a user in the store. If left empty, the current user's ID will be used.
* @param int $product_id (optional) The ID of a product in the store. If left empty, the function will see if the user has any subscription.
* @param mixed $status (optional) A valid subscription status string or array. If left empty, the function will see if the user has a subscription of any status.
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*
* @return bool
*/
@@ -165,7 +165,7 @@ function wcs_user_has_subscription( $user_id = 0, $product_id = '', $status = 'a
* Gets all the active and inactive subscriptions for a user, as specified by $user_id
*
* @param int $user_id (optional) The id of the user whose subscriptions you want. Defaults to the currently logged in user.
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*
* @return WC_Subscription[]
*/
@@ -241,7 +241,7 @@ function wcs_get_cached_user_subscription_ids( $user_id = 0 ) {
* @param int $subscription_id A subscription's post ID
* @param string $status A subscription's post ID
* @param string $current_status A subscription's current status
- * @since 1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.0
*/
function wcs_get_users_change_status_link( $subscription_id, $status, $current_status = '' ) {
@@ -270,7 +270,7 @@ function wcs_get_users_change_status_link( $subscription_id, $status, $current_s
* By default, a store manager can put all subscriptions on hold, while other users can only suspend their own subscriptions.
*
* @param int|WC_Subscription $subscription An instance of a WC_Snbscription object or ID representing a 'shop_subscription' post
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_can_user_put_subscription_on_hold( $subscription, $user = '' ) {
$user_can_suspend = false;
@@ -291,7 +291,7 @@ function wcs_can_user_put_subscription_on_hold( $subscription, $user = '' ) {
/**
* Retrieve available actions that a user can perform on the subscription
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*
* @param WC_Subscription $subscription The subscription.
* @param int $user_id The user.
@@ -416,7 +416,7 @@ add_filter( 'user_has_cap', 'wcs_user_has_capability', 15, 3 );
/**
* Grants shop managers the capability to edit subscribers.
*
- * @since 3.0.4
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.0.4
* @param array $roles The user roles shop managers can edit.
* @return array The list of roles editable by shop managers.
*/
@@ -430,7 +430,7 @@ add_filter( 'woocommerce_shop_manager_editable_roles', 'wcs_grant_shop_manager_e
/**
* Gets the subscriber role.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*
* @return string The role to apply to subscribers.
*/
@@ -445,7 +445,7 @@ function wcs_get_subscriber_role() {
/**
* Gets the inactive subscriber role.
*
- * @since 4.0.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v4.0.0
*
* @return string The role to apply to inactive subscribers.
*/
diff --git a/vendor/woocommerce/subscriptions-core/templates/admin/html-admin-notice.php b/vendor/woocommerce/subscriptions-core/templates/admin/html-admin-notice.php
index 3149748..4a07820 100644
--- a/vendor/woocommerce/subscriptions-core/templates/admin/html-admin-notice.php
+++ b/vendor/woocommerce/subscriptions-core/templates/admin/html-admin-notice.php
@@ -2,7 +2,7 @@
/**
* The template for displaying an admin notice.
*
- * @version 2.3.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.0
* @var WCS_Admin_Notice $notice
*/
if ( ! defined( 'ABSPATH' ) ) {
diff --git a/vendor/woocommerce/subscriptions-core/templates/admin/html-failed-scheduled-action-notice.php b/vendor/woocommerce/subscriptions-core/templates/admin/html-failed-scheduled-action-notice.php
index af4d808..d3339bf 100644
--- a/vendor/woocommerce/subscriptions-core/templates/admin/html-failed-scheduled-action-notice.php
+++ b/vendor/woocommerce/subscriptions-core/templates/admin/html-failed-scheduled-action-notice.php
@@ -2,7 +2,7 @@
/**
* The template for displaying an admin notice to report failed Subscriptions related scheduled actions.
*
- * @version 2.5.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.0
* @var array $failed_scheduled_actions
* @var string $affected_subscription_events
*/
diff --git a/vendor/woocommerce/subscriptions-core/templates/admin/html-variation-price.php b/vendor/woocommerce/subscriptions-core/templates/admin/html-variation-price.php
index 932c338..6bb0a18 100644
--- a/vendor/woocommerce/subscriptions-core/templates/admin/html-variation-price.php
+++ b/vendor/woocommerce/subscriptions-core/templates/admin/html-variation-price.php
@@ -2,7 +2,7 @@
/**
* Outputs a subscription variation's pricing fields for WooCommerce 2.3+
*
- * @version 2.2.12
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.12
*
* @var int $loop
* @var WP_POST $variation
diff --git a/vendor/woocommerce/subscriptions-core/templates/admin/html-variation-synchronisation.php b/vendor/woocommerce/subscriptions-core/templates/admin/html-variation-synchronisation.php
index 007c76c..30e03f4 100644
--- a/vendor/woocommerce/subscriptions-core/templates/admin/html-variation-synchronisation.php
+++ b/vendor/woocommerce/subscriptions-core/templates/admin/html-variation-synchronisation.php
@@ -2,7 +2,7 @@
/**
* Outputs a subscription variation's payment date synchronisation fields for WooCommerce 2.3+
*
- * @version 2.1.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.1.0
*
* @var int $loop
* @var WP_POST $variation
diff --git a/vendor/woocommerce/subscriptions-core/templates/admin/status.php b/vendor/woocommerce/subscriptions-core/templates/admin/status.php
index 66f2ce6..2367e08 100644
--- a/vendor/woocommerce/subscriptions-core/templates/admin/status.php
+++ b/vendor/woocommerce/subscriptions-core/templates/admin/status.php
@@ -2,7 +2,7 @@
/**
* Outputs the Status section for Subscriptions.
*
- * @version 2.6.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
diff --git a/vendor/woocommerce/subscriptions-core/templates/cart/cart-recurring-shipping.php b/vendor/woocommerce/subscriptions-core/templates/cart/cart-recurring-shipping.php
index c8ef878..dc8a421 100644
--- a/vendor/woocommerce/subscriptions-core/templates/cart/cart-recurring-shipping.php
+++ b/vendor/woocommerce/subscriptions-core/templates/cart/cart-recurring-shipping.php
@@ -6,7 +6,7 @@
*
* @author Prospress
* @package WooCommerce Subscriptions/Templates
- * @version 2.6.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
diff --git a/vendor/woocommerce/subscriptions-core/templates/checkout/form-change-payment-method.php b/vendor/woocommerce/subscriptions-core/templates/checkout/form-change-payment-method.php
index 18812e8..1b307aa 100644
--- a/vendor/woocommerce/subscriptions-core/templates/checkout/form-change-payment-method.php
+++ b/vendor/woocommerce/subscriptions-core/templates/checkout/form-change-payment-method.php
@@ -5,7 +5,7 @@
*
* @author Prospress
* @package WooCommerce/Templates
- * @version 2.6.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
diff --git a/vendor/woocommerce/subscriptions-core/templates/checkout/recurring-coupon-totals.php b/vendor/woocommerce/subscriptions-core/templates/checkout/recurring-coupon-totals.php
index c3223d8..be3337c 100644
--- a/vendor/woocommerce/subscriptions-core/templates/checkout/recurring-coupon-totals.php
+++ b/vendor/woocommerce/subscriptions-core/templates/checkout/recurring-coupon-totals.php
@@ -4,7 +4,7 @@
*
* @author WooCommerce
* @package WooCommerce Subscriptions/Templates
- * @version 3.1.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
*/
defined( 'ABSPATH' ) || exit;
diff --git a/vendor/woocommerce/subscriptions-core/templates/checkout/recurring-fee-totals.php b/vendor/woocommerce/subscriptions-core/templates/checkout/recurring-fee-totals.php
index 348798c..1693f44 100644
--- a/vendor/woocommerce/subscriptions-core/templates/checkout/recurring-fee-totals.php
+++ b/vendor/woocommerce/subscriptions-core/templates/checkout/recurring-fee-totals.php
@@ -4,7 +4,7 @@
*
* @author WooCommerce
* @package WooCommerce Subscriptions/Templates
- * @version 3.1.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
*/
defined( 'ABSPATH' ) || exit;
diff --git a/vendor/woocommerce/subscriptions-core/templates/checkout/recurring-itemized-tax-totals.php b/vendor/woocommerce/subscriptions-core/templates/checkout/recurring-itemized-tax-totals.php
index cbee8cf..9d84d78 100644
--- a/vendor/woocommerce/subscriptions-core/templates/checkout/recurring-itemized-tax-totals.php
+++ b/vendor/woocommerce/subscriptions-core/templates/checkout/recurring-itemized-tax-totals.php
@@ -4,7 +4,7 @@
*
* @author WooCommerce
* @package WooCommerce Subscriptions/Templates
- * @version 3.1.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
*/
defined( 'ABSPATH' ) || exit;
@@ -20,7 +20,7 @@ foreach ( WC()->cart->get_taxes() as $tax_id => $tax_total ) {
/**
* Allow third-parties to filter the tax displayed.
*
- * @since 3.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
* @param string The recurring cart's tax total price string for this tax code.
* @param WC_Cart $recurring_cart The recurring cart.
* @param string $recurring_code The tax code.
diff --git a/vendor/woocommerce/subscriptions-core/templates/checkout/recurring-subscription-totals.php b/vendor/woocommerce/subscriptions-core/templates/checkout/recurring-subscription-totals.php
index 7dd580c..c33a3ba 100644
--- a/vendor/woocommerce/subscriptions-core/templates/checkout/recurring-subscription-totals.php
+++ b/vendor/woocommerce/subscriptions-core/templates/checkout/recurring-subscription-totals.php
@@ -4,7 +4,7 @@
*
* @author WooCommerce
* @package WooCommerce Subscriptions/Templates
- * @version 3.1.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
*/
defined( 'ABSPATH' ) || exit;
diff --git a/vendor/woocommerce/subscriptions-core/templates/checkout/recurring-subtotals.php b/vendor/woocommerce/subscriptions-core/templates/checkout/recurring-subtotals.php
index 6b27c58..75ba2af 100644
--- a/vendor/woocommerce/subscriptions-core/templates/checkout/recurring-subtotals.php
+++ b/vendor/woocommerce/subscriptions-core/templates/checkout/recurring-subtotals.php
@@ -4,7 +4,7 @@
*
* @author WooCommerce
* @package WooCommerce Subscriptions/Templates
- * @version 3.1.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
*/
defined( 'ABSPATH' ) || exit;
diff --git a/vendor/woocommerce/subscriptions-core/templates/checkout/recurring-tax-totals.php b/vendor/woocommerce/subscriptions-core/templates/checkout/recurring-tax-totals.php
index 02e69d6..4d7746b 100644
--- a/vendor/woocommerce/subscriptions-core/templates/checkout/recurring-tax-totals.php
+++ b/vendor/woocommerce/subscriptions-core/templates/checkout/recurring-tax-totals.php
@@ -4,7 +4,7 @@
*
* @author WooCommerce
* @package WooCommerce Subscriptions/Templates
- * @version 3.1.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
*/
defined( 'ABSPATH' ) || exit;
@@ -14,7 +14,7 @@ foreach ( $recurring_carts as $recurring_cart_key => $recurring_cart ) {
/**
* Allow third-parties to filter the tax displayed.
*
- * @since 3.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
* @param string The recurring cart's total tax price string.
* @param WC_Cart $recurring_cart The recurring cart.
*/
diff --git a/vendor/woocommerce/subscriptions-core/templates/checkout/recurring-totals.php b/vendor/woocommerce/subscriptions-core/templates/checkout/recurring-totals.php
index 67f1cfc..1954ebf 100644
--- a/vendor/woocommerce/subscriptions-core/templates/checkout/recurring-totals.php
+++ b/vendor/woocommerce/subscriptions-core/templates/checkout/recurring-totals.php
@@ -4,9 +4,9 @@
*
* @author Prospress
* @package WooCommerce Subscriptions/Templates
- * @version 3.1.0
- * @deprecated $carts_with_multiple_payments. This variable is no longer used to set row spans. It is now dynamically generated by the number of rows displayed.
- * @deprecated $shipping_methods. This variable is no longer used.
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v3.1.0
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions, $carts_with_multiple_payments. This variable is no longer used to set row spans. It is now dynamically generated by the number of rows displayed.
+ * @deprecated 1.0.0 - Migrated from WooCommerce Subscriptions, $shipping_methods. This variable is no longer used.
*/
defined( 'ABSPATH' ) || exit;
@@ -20,37 +20,37 @@ $display_th = true;
/**
* @hooked WC_Emails::order_details() Shows the order details table.
- * @since 2.5.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.0
*/
do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email );
diff --git a/vendor/woocommerce/subscriptions-core/templates/emails/cancelled-subscription.php b/vendor/woocommerce/subscriptions-core/templates/emails/cancelled-subscription.php
index 15fd867..1db81cc 100644
--- a/vendor/woocommerce/subscriptions-core/templates/emails/cancelled-subscription.php
+++ b/vendor/woocommerce/subscriptions-core/templates/emails/cancelled-subscription.php
@@ -4,7 +4,7 @@
*
* @author Prospress
* @package WooCommerce_Subscriptions/Templates/Emails
- * @version 2.6.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
diff --git a/vendor/woocommerce/subscriptions-core/templates/emails/customer-completed-renewal-order.php b/vendor/woocommerce/subscriptions-core/templates/emails/customer-completed-renewal-order.php
index 6e1fa99..e3f52c0 100644
--- a/vendor/woocommerce/subscriptions-core/templates/emails/customer-completed-renewal-order.php
+++ b/vendor/woocommerce/subscriptions-core/templates/emails/customer-completed-renewal-order.php
@@ -4,7 +4,7 @@
*
* @author Brent Shepherd
* @package WooCommerce_Subscriptions/Templates/Emails
- * @version 2.6.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
diff --git a/vendor/woocommerce/subscriptions-core/templates/emails/customer-completed-switch-order.php b/vendor/woocommerce/subscriptions-core/templates/emails/customer-completed-switch-order.php
index 7be5029..acff5d0 100644
--- a/vendor/woocommerce/subscriptions-core/templates/emails/customer-completed-switch-order.php
+++ b/vendor/woocommerce/subscriptions-core/templates/emails/customer-completed-switch-order.php
@@ -4,7 +4,7 @@
*
* @author Brent Shepherd
* @package WooCommerce_Subscriptions/Templates/Emails
- * @version 2.6.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
diff --git a/vendor/woocommerce/subscriptions-core/templates/emails/customer-on-hold-renewal-order.php b/vendor/woocommerce/subscriptions-core/templates/emails/customer-on-hold-renewal-order.php
index c2623e9..8835675 100644
--- a/vendor/woocommerce/subscriptions-core/templates/emails/customer-on-hold-renewal-order.php
+++ b/vendor/woocommerce/subscriptions-core/templates/emails/customer-on-hold-renewal-order.php
@@ -3,7 +3,7 @@
* Customer on-hold renewal order email.
*
* @package WooCommerce_Subscriptions/Templates/Emails
- * @version 3.0.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v3.0.0
*/
defined( 'ABSPATH' ) || exit;
diff --git a/vendor/woocommerce/subscriptions-core/templates/emails/customer-payment-retry.php b/vendor/woocommerce/subscriptions-core/templates/emails/customer-payment-retry.php
index ed8d6eb..abc6e14 100644
--- a/vendor/woocommerce/subscriptions-core/templates/emails/customer-payment-retry.php
+++ b/vendor/woocommerce/subscriptions-core/templates/emails/customer-payment-retry.php
@@ -4,7 +4,7 @@
*
* @author Prospress
* @package WooCommerce_Subscriptions/Templates/Emails
- * @version 2.6.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
diff --git a/vendor/woocommerce/subscriptions-core/templates/emails/customer-processing-renewal-order.php b/vendor/woocommerce/subscriptions-core/templates/emails/customer-processing-renewal-order.php
index f87fb0c..edaed15 100644
--- a/vendor/woocommerce/subscriptions-core/templates/emails/customer-processing-renewal-order.php
+++ b/vendor/woocommerce/subscriptions-core/templates/emails/customer-processing-renewal-order.php
@@ -4,7 +4,7 @@
*
* @author Brent Shepherd
* @package WooCommerce_Subscriptions/Templates/Emails
- * @version 2.6.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
diff --git a/vendor/woocommerce/subscriptions-core/templates/emails/customer-renewal-invoice.php b/vendor/woocommerce/subscriptions-core/templates/emails/customer-renewal-invoice.php
index 94522a0..5b63588 100644
--- a/vendor/woocommerce/subscriptions-core/templates/emails/customer-renewal-invoice.php
+++ b/vendor/woocommerce/subscriptions-core/templates/emails/customer-renewal-invoice.php
@@ -4,7 +4,7 @@
*
* @author Brent Shepherd
* @package WooCommerce_Subscriptions/Templates/Emails
- * @version 2.6.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
diff --git a/vendor/woocommerce/subscriptions-core/templates/emails/email-order-details.php b/vendor/woocommerce/subscriptions-core/templates/emails/email-order-details.php
index eca9bc8..c68c597 100644
--- a/vendor/woocommerce/subscriptions-core/templates/emails/email-order-details.php
+++ b/vendor/woocommerce/subscriptions-core/templates/emails/email-order-details.php
@@ -4,7 +4,7 @@
*
* @author Prospress
* @package WooCommerce_Subscriptions/Templates/Emails
- * @version 3.0.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v3.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
diff --git a/vendor/woocommerce/subscriptions-core/templates/emails/expired-subscription.php b/vendor/woocommerce/subscriptions-core/templates/emails/expired-subscription.php
index 5c62c88..f1408c3 100644
--- a/vendor/woocommerce/subscriptions-core/templates/emails/expired-subscription.php
+++ b/vendor/woocommerce/subscriptions-core/templates/emails/expired-subscription.php
@@ -4,7 +4,7 @@
*
* @author Prospress
* @package WooCommerce_Subscriptions/Templates/Emails
- * @version 2.6.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
diff --git a/vendor/woocommerce/subscriptions-core/templates/emails/on-hold-subscription.php b/vendor/woocommerce/subscriptions-core/templates/emails/on-hold-subscription.php
index 358aae5..0c8f323 100644
--- a/vendor/woocommerce/subscriptions-core/templates/emails/on-hold-subscription.php
+++ b/vendor/woocommerce/subscriptions-core/templates/emails/on-hold-subscription.php
@@ -4,7 +4,7 @@
*
* @author Prospress
* @package WooCommerce_Subscriptions/Templates/Emails
- * @version 2.6.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
diff --git a/vendor/woocommerce/subscriptions-core/templates/emails/plain/admin-new-renewal-order.php b/vendor/woocommerce/subscriptions-core/templates/emails/plain/admin-new-renewal-order.php
index d459b9e..1f88627 100644
--- a/vendor/woocommerce/subscriptions-core/templates/emails/plain/admin-new-renewal-order.php
+++ b/vendor/woocommerce/subscriptions-core/templates/emails/plain/admin-new-renewal-order.php
@@ -4,7 +4,7 @@
*
* @author Brent Shepherd
* @package WooCommerce_Subscriptions/Templates/Emails/Plain
- * @version 2.6.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
@@ -21,7 +21,7 @@ echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n"
/**
* @hooked WC_Subscriptions_Email::order_details() Shows the order details table.
- * @since 2.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1.0
*/
do_action( 'woocommerce_subscriptions_email_order_details', $order, $sent_to_admin, $plain_text, $email );
diff --git a/vendor/woocommerce/subscriptions-core/templates/emails/plain/admin-new-switch-order.php b/vendor/woocommerce/subscriptions-core/templates/emails/plain/admin-new-switch-order.php
index ae6993e..94b95fc 100644
--- a/vendor/woocommerce/subscriptions-core/templates/emails/plain/admin-new-switch-order.php
+++ b/vendor/woocommerce/subscriptions-core/templates/emails/plain/admin-new-switch-order.php
@@ -4,7 +4,7 @@
*
* @author Brent Shepherd
* @package WooCommerce_Subscriptions/Templates/Emails/Plain
- * @version 2.6.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
@@ -21,7 +21,7 @@ echo "\n\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\
/**
* @hooked WC_Subscriptions_Email::order_details() Shows the order details table.
- * @since 2.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1.0
*/
do_action( 'woocommerce_subscriptions_email_order_details', $order, $sent_to_admin, $plain_text, $email );
diff --git a/vendor/woocommerce/subscriptions-core/templates/emails/plain/admin-payment-retry.php b/vendor/woocommerce/subscriptions-core/templates/emails/plain/admin-payment-retry.php
index f05c535..a88e7c9 100644
--- a/vendor/woocommerce/subscriptions-core/templates/emails/plain/admin-payment-retry.php
+++ b/vendor/woocommerce/subscriptions-core/templates/emails/plain/admin-payment-retry.php
@@ -7,7 +7,7 @@
*
* @author Prospress
* @package WooCommerce_Subscriptions/Templates/Emails/Plain
- * @version 2.6.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -24,7 +24,7 @@ echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n"
/**
* @hooked WC_Emails::order_details() Shows the order details table.
- * @since 2.5.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.0
*/
do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email );
diff --git a/vendor/woocommerce/subscriptions-core/templates/emails/plain/cancelled-subscription.php b/vendor/woocommerce/subscriptions-core/templates/emails/plain/cancelled-subscription.php
index c9cd104..95e0656 100644
--- a/vendor/woocommerce/subscriptions-core/templates/emails/plain/cancelled-subscription.php
+++ b/vendor/woocommerce/subscriptions-core/templates/emails/plain/cancelled-subscription.php
@@ -4,7 +4,7 @@
*
* @author Prospress
* @package WooCommerce_Subscriptions/Templates/Emails/Plain
- * @version 2.6.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
@@ -19,7 +19,7 @@ echo "\n\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\
/**
* @hooked WC_Subscriptions_Email::order_details() Shows the order details table.
- * @since 2.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1.0
*/
do_action( 'woocommerce_subscriptions_email_order_details', $subscription, $sent_to_admin, $plain_text, $email );
diff --git a/vendor/woocommerce/subscriptions-core/templates/emails/plain/customer-completed-renewal-order.php b/vendor/woocommerce/subscriptions-core/templates/emails/plain/customer-completed-renewal-order.php
index 5ed1318..8bf2786 100644
--- a/vendor/woocommerce/subscriptions-core/templates/emails/plain/customer-completed-renewal-order.php
+++ b/vendor/woocommerce/subscriptions-core/templates/emails/plain/customer-completed-renewal-order.php
@@ -4,7 +4,7 @@
*
* @author Brent Shepherd
* @package WooCommerce_Subscriptions/Templates/Emails/Plain
- * @version 2.6.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
diff --git a/vendor/woocommerce/subscriptions-core/templates/emails/plain/customer-completed-switch-order.php b/vendor/woocommerce/subscriptions-core/templates/emails/plain/customer-completed-switch-order.php
index 070cd76..adc6b16 100644
--- a/vendor/woocommerce/subscriptions-core/templates/emails/plain/customer-completed-switch-order.php
+++ b/vendor/woocommerce/subscriptions-core/templates/emails/plain/customer-completed-switch-order.php
@@ -4,7 +4,7 @@
*
* @author Brent Shepherd
* @package WooCommerce_Subscriptions/Templates/Emails/Plain
- * @version 2.6.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
diff --git a/vendor/woocommerce/subscriptions-core/templates/emails/plain/customer-on-hold-renewal-order.php b/vendor/woocommerce/subscriptions-core/templates/emails/plain/customer-on-hold-renewal-order.php
index 6c64a95..acd0827 100644
--- a/vendor/woocommerce/subscriptions-core/templates/emails/plain/customer-on-hold-renewal-order.php
+++ b/vendor/woocommerce/subscriptions-core/templates/emails/plain/customer-on-hold-renewal-order.php
@@ -3,7 +3,7 @@
* Customer on-hold renewal order email.
*
* @package WooCommerce_Subscriptions/Templates/Emails/Plain
- * @version 3.0.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v3.0.0
*/
defined( 'ABSPATH' ) || exit;
@@ -20,7 +20,7 @@ echo esc_html__( 'Thanks for your renewal order. It’s on-hold until we confirm
* @hooked WC_Emails::order_details() Shows the order details table.
* @hooked WC_Structured_Data::generate_order_data() Generates structured data.
* @hooked WC_Structured_Data::output_structured_data() Outputs structured data.
- * @since 2.5.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.5.0
*/
do_action( 'woocommerce_subscriptions_email_order_details', $order, $sent_to_admin, $plain_text, $email );
diff --git a/vendor/woocommerce/subscriptions-core/templates/emails/plain/customer-payment-retry.php b/vendor/woocommerce/subscriptions-core/templates/emails/plain/customer-payment-retry.php
index 774f729..3747ea0 100644
--- a/vendor/woocommerce/subscriptions-core/templates/emails/plain/customer-payment-retry.php
+++ b/vendor/woocommerce/subscriptions-core/templates/emails/plain/customer-payment-retry.php
@@ -4,7 +4,7 @@
*
* @author Prospress
* @package WooCommerce_Subscriptions/Templates/Emails
- * @version 2.6.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
diff --git a/vendor/woocommerce/subscriptions-core/templates/emails/plain/customer-processing-renewal-order.php b/vendor/woocommerce/subscriptions-core/templates/emails/plain/customer-processing-renewal-order.php
index 4be518e..2b27e0f 100644
--- a/vendor/woocommerce/subscriptions-core/templates/emails/plain/customer-processing-renewal-order.php
+++ b/vendor/woocommerce/subscriptions-core/templates/emails/plain/customer-processing-renewal-order.php
@@ -4,7 +4,7 @@
*
* @author Brent Shepherd
* @package WooCommerce_Subscriptions/Templates/Emails/Plain
- * @version 2.6.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
diff --git a/vendor/woocommerce/subscriptions-core/templates/emails/plain/customer-renewal-invoice.php b/vendor/woocommerce/subscriptions-core/templates/emails/plain/customer-renewal-invoice.php
index 9cf4dbe..f6c38e8 100644
--- a/vendor/woocommerce/subscriptions-core/templates/emails/plain/customer-renewal-invoice.php
+++ b/vendor/woocommerce/subscriptions-core/templates/emails/plain/customer-renewal-invoice.php
@@ -4,7 +4,7 @@
*
* @author Brent Shepherd
* @package WooCommerce_Subscriptions/Templates/Emails/Plain
- * @version 2.6.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
diff --git a/vendor/woocommerce/subscriptions-core/templates/emails/plain/email-order-details.php b/vendor/woocommerce/subscriptions-core/templates/emails/plain/email-order-details.php
index d44a4de..2764688 100644
--- a/vendor/woocommerce/subscriptions-core/templates/emails/plain/email-order-details.php
+++ b/vendor/woocommerce/subscriptions-core/templates/emails/plain/email-order-details.php
@@ -4,7 +4,7 @@
*
* @author Prospress
* @package WooCommerce_Subscriptions/Templates/Emails/Plain
- * @version 2.1.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.1.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
diff --git a/vendor/woocommerce/subscriptions-core/templates/emails/plain/expired-subscription.php b/vendor/woocommerce/subscriptions-core/templates/emails/plain/expired-subscription.php
index d03ad6c..538afb1 100644
--- a/vendor/woocommerce/subscriptions-core/templates/emails/plain/expired-subscription.php
+++ b/vendor/woocommerce/subscriptions-core/templates/emails/plain/expired-subscription.php
@@ -4,7 +4,7 @@
*
* @author Prospress
* @package WooCommerce_Subscriptions/Templates/Emails/Plain
- * @version 2.1.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.1.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
@@ -19,7 +19,7 @@ echo "\n\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\
/**
* @hooked WC_Subscriptions_Email::order_details() Shows the order details table.
- * @since 2.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1.0
*/
do_action( 'woocommerce_subscriptions_email_order_details', $subscription, $sent_to_admin, $plain_text, $email );
diff --git a/vendor/woocommerce/subscriptions-core/templates/emails/plain/on-hold-subscription.php b/vendor/woocommerce/subscriptions-core/templates/emails/plain/on-hold-subscription.php
index 235095c..95de646 100644
--- a/vendor/woocommerce/subscriptions-core/templates/emails/plain/on-hold-subscription.php
+++ b/vendor/woocommerce/subscriptions-core/templates/emails/plain/on-hold-subscription.php
@@ -4,7 +4,7 @@
*
* @author Prospress
* @package WooCommerce_Subscriptions/Templates/Emails/Plain
- * @version 2.1.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.1.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
@@ -19,7 +19,7 @@ echo "\n\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\
/**
* @hooked WC_Subscriptions_Email::order_details() Shows the order details table.
- * @since 2.1.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1.0
*/
do_action( 'woocommerce_subscriptions_email_order_details', $subscription, $sent_to_admin, $plain_text, $email );
diff --git a/vendor/woocommerce/subscriptions-core/templates/emails/plain/subscription-info.php b/vendor/woocommerce/subscriptions-core/templates/emails/plain/subscription-info.php
index 6b9dad9..a309935 100644
--- a/vendor/woocommerce/subscriptions-core/templates/emails/plain/subscription-info.php
+++ b/vendor/woocommerce/subscriptions-core/templates/emails/plain/subscription-info.php
@@ -4,7 +4,7 @@
*
* @author Brent Shepherd / Chuck Mac
* @package WooCommerce_Subscriptions/Templates/Emails
- * @version 3.0.4
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v3.0.4
*/
if ( ! defined( 'ABSPATH' ) ) {
diff --git a/vendor/woocommerce/subscriptions-core/templates/emails/subscription-info.php b/vendor/woocommerce/subscriptions-core/templates/emails/subscription-info.php
index 1c30116..ac20171 100644
--- a/vendor/woocommerce/subscriptions-core/templates/emails/subscription-info.php
+++ b/vendor/woocommerce/subscriptions-core/templates/emails/subscription-info.php
@@ -4,7 +4,7 @@
*
* @author Brent Shepherd / Chuck Mac
* @package WooCommerce_Subscriptions/Templates/Emails
- * @version 3.0.4
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v3.0.4
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
diff --git a/vendor/woocommerce/subscriptions-core/templates/html-modal.php b/vendor/woocommerce/subscriptions-core/templates/html-modal.php
index c2b7593..e7f8f44 100644
--- a/vendor/woocommerce/subscriptions-core/templates/html-modal.php
+++ b/vendor/woocommerce/subscriptions-core/templates/html-modal.php
@@ -2,7 +2,7 @@
/**
* The template for displaying a modal.
*
- * @version 2.6.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
* @var WCS_Modal $modal
*/
if ( ! defined( 'ABSPATH' ) ) {
diff --git a/vendor/woocommerce/subscriptions-core/templates/myaccount/my-subscriptions.php b/vendor/woocommerce/subscriptions-core/templates/myaccount/my-subscriptions.php
index e21b8f4..cb5a827 100644
--- a/vendor/woocommerce/subscriptions-core/templates/myaccount/my-subscriptions.php
+++ b/vendor/woocommerce/subscriptions-core/templates/myaccount/my-subscriptions.php
@@ -4,7 +4,7 @@
*
* @author Prospress
* @category WooCommerce Subscriptions/Templates
- * @version 2.6.4
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.4
*/
if ( ! defined( 'ABSPATH' ) ) {
diff --git a/vendor/woocommerce/subscriptions-core/templates/myaccount/related-orders.php b/vendor/woocommerce/subscriptions-core/templates/myaccount/related-orders.php
index dc8a0f1..9b264a7 100644
--- a/vendor/woocommerce/subscriptions-core/templates/myaccount/related-orders.php
+++ b/vendor/woocommerce/subscriptions-core/templates/myaccount/related-orders.php
@@ -4,7 +4,7 @@
*
* @author Prospress
* @category WooCommerce Subscriptions/Templates
- * @version 2.6.2
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.2
*/
if ( ! defined( 'ABSPATH' ) ) {
diff --git a/vendor/woocommerce/subscriptions-core/templates/myaccount/related-subscriptions.php b/vendor/woocommerce/subscriptions-core/templates/myaccount/related-subscriptions.php
index aed83ce..69b02dd 100644
--- a/vendor/woocommerce/subscriptions-core/templates/myaccount/related-subscriptions.php
+++ b/vendor/woocommerce/subscriptions-core/templates/myaccount/related-subscriptions.php
@@ -4,7 +4,7 @@
*
* @author Prospress
* @category WooCommerce Subscriptions/Templates
- * @version 2.6.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
diff --git a/vendor/woocommerce/subscriptions-core/templates/myaccount/subscription-details.php b/vendor/woocommerce/subscriptions-core/templates/myaccount/subscription-details.php
index 8cbbb8a..4017707 100644
--- a/vendor/woocommerce/subscriptions-core/templates/myaccount/subscription-details.php
+++ b/vendor/woocommerce/subscriptions-core/templates/myaccount/subscription-details.php
@@ -4,8 +4,8 @@
*
* @author Prospress
* @package WooCommerce_Subscription/Templates
- * @since 2.2.19
- * @version 2.6.5
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.19
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.5
*/
if ( ! defined( 'ABSPATH' ) ) {
diff --git a/vendor/woocommerce/subscriptions-core/templates/myaccount/subscription-totals-table.php b/vendor/woocommerce/subscriptions-core/templates/myaccount/subscription-totals-table.php
index ac72cf1..427f76f 100644
--- a/vendor/woocommerce/subscriptions-core/templates/myaccount/subscription-totals-table.php
+++ b/vendor/woocommerce/subscriptions-core/templates/myaccount/subscription-totals-table.php
@@ -4,8 +4,8 @@
*
* @author Prospress
* @package WooCommerce_Subscription/Templates
- * @since 2.6.0
- * @version 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
diff --git a/vendor/woocommerce/subscriptions-core/templates/myaccount/subscription-totals.php b/vendor/woocommerce/subscriptions-core/templates/myaccount/subscription-totals.php
index 3ee3795..556e28d 100644
--- a/vendor/woocommerce/subscriptions-core/templates/myaccount/subscription-totals.php
+++ b/vendor/woocommerce/subscriptions-core/templates/myaccount/subscription-totals.php
@@ -4,8 +4,8 @@
*
* @author Prospress
* @package WooCommerce_Subscription/Templates
- * @since 2.2.19
- * @version 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.19
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
diff --git a/vendor/woocommerce/subscriptions-core/templates/myaccount/subscriptions.php b/vendor/woocommerce/subscriptions-core/templates/myaccount/subscriptions.php
index 4ec147a..6a145ae 100644
--- a/vendor/woocommerce/subscriptions-core/templates/myaccount/subscriptions.php
+++ b/vendor/woocommerce/subscriptions-core/templates/myaccount/subscriptions.php
@@ -4,7 +4,7 @@
*
* @author Prospress
* @category WooCommerce Subscriptions/Templates
- * @version 2.0.15
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.15
*/
if ( ! defined( 'ABSPATH' ) ) {
diff --git a/vendor/woocommerce/subscriptions-core/templates/myaccount/view-subscription.php b/vendor/woocommerce/subscriptions-core/templates/myaccount/view-subscription.php
index c774f3c..44398fe 100644
--- a/vendor/woocommerce/subscriptions-core/templates/myaccount/view-subscription.php
+++ b/vendor/woocommerce/subscriptions-core/templates/myaccount/view-subscription.php
@@ -6,7 +6,7 @@
*
* @author Prospress
* @package WooCommerce_Subscription/Templates
- * @version 2.6.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -18,14 +18,14 @@ wc_print_notices();
/**
* Gets subscription details table template
* @param WC_Subscription $subscription A subscription object
- * @since 2.2.19
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.19
*/
do_action( 'woocommerce_subscription_details_table', $subscription );
/**
* Gets subscription totals table template
* @param WC_Subscription $subscription A subscription object
- * @since 2.2.19
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.19
*/
do_action( 'woocommerce_subscription_totals_table', $subscription );
diff --git a/vendor/woocommerce/subscriptions-core/templates/single-product/add-to-cart/subscription.php b/vendor/woocommerce/subscriptions-core/templates/single-product/add-to-cart/subscription.php
index 1cc84d1..f7f2b19 100644
--- a/vendor/woocommerce/subscriptions-core/templates/single-product/add-to-cart/subscription.php
+++ b/vendor/woocommerce/subscriptions-core/templates/single-product/add-to-cart/subscription.php
@@ -4,7 +4,7 @@
*
* @author Prospress
* @package WooCommerce-Subscriptions/Templates
- * @version 2.6.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
defined( 'ABSPATH' ) || exit;
diff --git a/vendor/woocommerce/subscriptions-core/templates/single-product/add-to-cart/variable-subscription.php b/vendor/woocommerce/subscriptions-core/templates/single-product/add-to-cart/variable-subscription.php
index 7fc8c36..9232bbc 100644
--- a/vendor/woocommerce/subscriptions-core/templates/single-product/add-to-cart/variable-subscription.php
+++ b/vendor/woocommerce/subscriptions-core/templates/single-product/add-to-cart/variable-subscription.php
@@ -4,7 +4,7 @@
*
* @author Prospress
* @package WooCommerce-Subscriptions/Templates
- * @version 2.6.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*/
defined( 'ABSPATH' ) || exit;
@@ -69,7 +69,7 @@ do_action( 'woocommerce_before_add_to_cart_form' ); ?>
/**
* woocommerce_single_variation hook. Used to output the cart button and placeholder for variation data.
*
- * @since 2.4.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.4.0
* @hooked woocommerce_single_variation - 10 Empty div for variation data.
* @hooked woocommerce_single_variation_add_to_cart_button - 20 Qty and cart button.
*/
diff --git a/vendor/woocommerce/subscriptions-core/wcs-functions.php b/vendor/woocommerce/subscriptions-core/wcs-functions.php
index f49c8a4..80701de 100644
--- a/vendor/woocommerce/subscriptions-core/wcs-functions.php
+++ b/vendor/woocommerce/subscriptions-core/wcs-functions.php
@@ -2,7 +2,7 @@
/**
* WooCommerce Subscriptions Functions
*
- * @version 2.0
+ * @version 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -30,16 +30,18 @@ if ( is_admin() ) {
/**
* Check if a given object is a WC_Subscription (or child class of WC_Subscription), or if a given ID
- * belongs to a post with the subscription post type ('shop_subscription')
+ * belongs to a post or order with type ('shop_subscription').
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
+ *
+ * @param mixed $subscription A WC_Subscription object or an ID.
* @return boolean true if anything is found
*/
function wcs_is_subscription( $subscription ) {
if ( is_object( $subscription ) && is_a( $subscription, 'WC_Subscription' ) ) {
$is_subscription = true;
- } elseif ( is_numeric( $subscription ) && 'shop_subscription' == get_post_type( $subscription ) ) {
+ } elseif ( is_numeric( $subscription ) && 'shop_subscription' === WC_Data_Store::load( 'subscription' )->get_order_type( $subscription ) ) {
$is_subscription = true;
} else {
$is_subscription = false;
@@ -49,26 +51,29 @@ function wcs_is_subscription( $subscription ) {
}
/**
- * A very simple check. Basically if we have ANY subscriptions in the database, then the user has probably set at
- * least one up, so we can give them the standard message. Otherwise
+ * Determines if there are any subscriptions in the database (active or inactive).
*
- * @since 2.0
- * @return boolean true if anything is found
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
+ * @return bool True if the store has any subscriptions, otherwise false.
*/
function wcs_do_subscriptions_exist() {
- global $wpdb;
- $sql = $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_type = %s LIMIT 1;", 'shop_subscription' );
+ $results = wc_get_orders(
+ array(
+ 'type' => 'shop_subscription',
+ 'status' => 'all',
+ 'limit' => 1,
+ 'return' => 'ids',
+ )
+ );
+ $subscriptions_exist = count( $results ) > 0;
- // query is the fastest, every other built in method uses this. Plus, the return value is the number of rows found
- $num_rows_found = $wpdb->query( $sql );
-
- return 0 !== $num_rows_found;
+ return $subscriptions_exist;
}
/**
* Main function for returning subscriptions. Wrapper for the wc_get_order() method.
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
* @param mixed $the_subscription Post object or post ID of the order.
* @return WC_Subscription|false The subscription object, or false if it cannot be found.
*/
@@ -93,39 +98,50 @@ function wcs_get_subscription( $the_subscription ) {
* Returns a new WC_Subscription object on success which can then be used to add additional data.
*
* @return WC_Subscription | WP_Error A WC_Subscription on success or WP_Error object on failure
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_create_subscription( $args = array() ) {
-
$now = gmdate( 'Y-m-d H:i:s' );
$order = ( isset( $args['order_id'] ) ) ? wc_get_order( $args['order_id'] ) : null;
- if ( ! empty( $order ) ) {
- $default_start_date = wcs_get_datetime_utc_string( wcs_get_objects_property( $order, 'date_created' ) );
- } else {
- $default_start_date = ( isset( $args['date_created'] ) ) ? $args['date_created'] : $now;
- }
-
$default_args = array(
'status' => '',
'order_id' => 0,
'customer_note' => null,
- 'customer_id' => ( ! empty( $order ) ) ? $order->get_user_id() : null,
- 'start_date' => $default_start_date,
+ 'customer_id' => null,
+ 'start_date' => $args['date_created'] ?? $now,
'date_created' => $now,
- 'created_via' => ( ! empty( $order ) ) ? wcs_get_objects_property( $order, 'created_via' ) : '',
- 'order_version' => ( ! empty( $order ) ) ? wcs_get_objects_property( $order, 'version' ) : WC_VERSION,
- 'currency' => ( ! empty( $order ) ) ? wcs_get_objects_property( $order, 'currency' ) : get_woocommerce_currency(),
- 'prices_include_tax' => ( ! empty( $order ) ) ? ( ( wcs_get_objects_property( $order, 'prices_include_tax' ) ) ? 'yes' : 'no' ) : get_option( 'woocommerce_prices_include_tax' ), // we don't use wc_prices_include_tax() here because WC doesn't use it in wc_create_order(), not 100% sure why it doesn't also check the taxes are enabled, but there could forseeably be a reason
+ 'created_via' => '',
+ 'currency' => get_woocommerce_currency(),
+ 'prices_include_tax' => get_option( 'woocommerce_prices_include_tax' ), // we don't use wc_prices_include_tax() here because WC doesn't use it in wc_create_order(), not 100% sure why it doesn't also check the taxes are enabled, but there could forseeably be a reason
);
- $args = wp_parse_args( $args, $default_args );
- $subscription_data = array();
+ // If we are creating a subscription from an order, we use some of the order's data as defaults.
+ if ( $order instanceof \WC_Order ) {
+ $default_args['customer_id'] = $order->get_user_id();
+ $default_args['created_via'] = $order->get_created_via( 'edit' );
+ $default_args['currency'] = $order->get_currency( 'edit' );
+ $default_args['prices_include_tax'] = $order->get_prices_include_tax( 'edit' ) ? 'yes' : 'no';
+ $default_args['date_created'] = wcs_get_datetime_utc_string( $order->get_date_created( 'edit' ) );
+ }
+
+ if ( isset( $args['order_version'] ) ) {
+ wcs_deprecated_argument( __FUNCTION__, '2.4', 'The "order_version" argument is no longer changeable due to a change in the WC order creation process.' );
+ }
+
+ $args = wp_parse_args( $args, $default_args );
+
+ // Check that the given status exists.
+ if ( ! empty( $args['status'] ) && ! array_key_exists( 'wc-' . $args['status'], wcs_get_subscription_statuses() ) ) {
+ return new WP_Error( 'woocommerce_invalid_subscription_status', __( 'Invalid subscription status given.', 'woocommerce-subscriptions' ) );
+ }
// Validate the date_created arg.
if ( ! is_string( $args['date_created'] ) || false === wcs_is_datetime_mysql_format( $args['date_created'] ) ) {
return new WP_Error( 'woocommerce_subscription_invalid_date_created_format', _x( 'Invalid created date. The date must be a string and of the format: "Y-m-d H:i:s".', 'Error message while creating a subscription', 'woocommerce-subscriptions' ) );
- } elseif ( wcs_date_to_time( $args['date_created'] ) > current_time( 'timestamp', true ) ) {
+ }
+ // Check if the date is in the future.
+ if ( wcs_date_to_time( $args['date_created'] ) > time() ) {
return new WP_Error( 'woocommerce_subscription_invalid_date_created', _x( 'Subscription created date must be before current day.', 'Error message while creating a subscription', 'woocommerce-subscriptions' ) );
}
@@ -134,82 +150,57 @@ function wcs_create_subscription( $args = array() ) {
return new WP_Error( 'woocommerce_subscription_invalid_start_date_format', _x( 'Invalid date. The date must be a string and of the format: "Y-m-d H:i:s".', 'Error message while creating a subscription', 'woocommerce-subscriptions' ) );
}
- // check customer id is set
+ // Check customer id is set.
if ( empty( $args['customer_id'] ) || ! is_numeric( $args['customer_id'] ) || $args['customer_id'] <= 0 ) {
return new WP_Error( 'woocommerce_subscription_invalid_customer_id', _x( 'Invalid subscription customer_id.', 'Error message while creating a subscription', 'woocommerce-subscriptions' ) );
}
- // check the billing period
- if ( empty( $args['billing_period'] ) || ! in_array( strtolower( $args['billing_period'] ), array_keys( wcs_get_subscription_period_strings() ) ) ) {
+ // Check the billing period.
+ if ( empty( $args['billing_period'] ) || ! array_key_exists( strtolower( $args['billing_period'] ), wcs_get_subscription_period_strings() ) ) {
return new WP_Error( 'woocommerce_subscription_invalid_billing_period', __( 'Invalid subscription billing period given.', 'woocommerce-subscriptions' ) );
}
- // check the billing interval
+ // Check the billing interval.
if ( empty( $args['billing_interval'] ) || ! is_numeric( $args['billing_interval'] ) || absint( $args['billing_interval'] ) <= 0 ) {
return new WP_Error( 'woocommerce_subscription_invalid_billing_interval', __( 'Invalid subscription billing interval given. Must be an integer greater than 0.', 'woocommerce-subscriptions' ) );
}
- $subscription_data['post_type'] = 'shop_subscription';
- $subscription_data['post_status'] = 'wc-' . apply_filters( 'woocommerce_default_subscription_status', 'pending' );
- $subscription_data['ping_status'] = 'closed';
- $subscription_data['post_author'] = 1;
- $subscription_data['post_password'] = uniqid( 'order_' );
- // translators: Order date parsed by strftime
- $post_title_date = strftime( _x( '%b %d, %Y @ %I:%M %p', 'Used in subscription post title. "Subscription renewal order - "', 'woocommerce-subscriptions' ) ); // phpcs:ignore WordPress.WP.I18n.UnorderedPlaceholdersText
- // translators: placeholder is order date parsed by strftime
- $subscription_data['post_title'] = sprintf( _x( 'Subscription – %s', 'The post title for the new subscription', 'woocommerce-subscriptions' ), $post_title_date );
- $subscription_data['post_date_gmt'] = $args['date_created'];
- $subscription_data['post_date'] = get_date_from_gmt( $args['date_created'] );
+ $subscription = new \WC_Subscription();
+
+ // Only call set_status() if required as this triggers a number of WC flows. Default status of 'wc-pending' is during
+ if ( $args['status'] ) {
+ $subscription->set_status( $args['status'] );
+ }
+
+ $subscription->set_customer_note( $args['customer_note'] ?? '' );
+ $subscription->set_customer_id( $args['customer_id'] );
+ $subscription->set_date_created( $args['date_created'] );
+ $subscription->set_created_via( $args['created_via'] );
+ $subscription->set_currency( $args['currency'] );
+ $subscription->set_prices_include_tax( 'no' !== $args['prices_include_tax'] );
+ $subscription->set_billing_period( $args['billing_period'] );
+ $subscription->set_billing_interval( absint( $args['billing_interval'] ) );
+ $subscription->set_start_date( $args['start_date'] );
if ( $args['order_id'] > 0 ) {
- $subscription_data['post_parent'] = absint( $args['order_id'] );
+ $subscription->set_parent_id( $args['order_id'] );
}
- if ( ! is_null( $args['customer_note'] ) && ! empty( $args['customer_note'] ) ) {
- $subscription_data['post_excerpt'] = $args['customer_note'];
- }
-
- // Only set the status if creating a new subscription, use wcs_update_subscription to update the status
- if ( $args['status'] ) {
- if ( ! in_array( 'wc-' . $args['status'], array_keys( wcs_get_subscription_statuses() ) ) ) {
- return new WP_Error( 'woocommerce_invalid_subscription_status', __( 'Invalid subscription status given.', 'woocommerce-subscriptions' ) );
- }
- $subscription_data['post_status'] = 'wc-' . $args['status'];
- }
-
- $subscription_id = wp_insert_post( apply_filters( 'woocommerce_new_subscription_data', $subscription_data, $args ), true );
-
- if ( is_wp_error( $subscription_id ) ) {
- return $subscription_id;
- }
-
- // Default order meta data.
- update_post_meta( $subscription_id, '_order_key', wcs_generate_order_key() );
- update_post_meta( $subscription_id, '_order_currency', $args['currency'] );
- update_post_meta( $subscription_id, '_prices_include_tax', $args['prices_include_tax'] );
- update_post_meta( $subscription_id, '_created_via', sanitize_text_field( $args['created_via'] ) );
-
- // add/update the billing
- update_post_meta( $subscription_id, '_billing_period', $args['billing_period'] );
- update_post_meta( $subscription_id, '_billing_interval', absint( $args['billing_interval'] ) );
-
- update_post_meta( $subscription_id, '_customer_user', $args['customer_id'] );
- update_post_meta( $subscription_id, '_order_version', $args['order_version'] );
-
- update_post_meta( $subscription_id, '_schedule_start', $args['start_date'] );
+ $subscription->save();
/**
* Filter the newly created subscription object.
+ * We need to fetch the subscription from the database as the current object state doesn't match the loaded state.
*
- * @since 2.2.22
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.22
* @param WC_Subscription $subscription
*/
- $subscription = apply_filters( 'wcs_created_subscription', wcs_get_subscription( $subscription_id ) );
+ $subscription = apply_filters( 'wcs_created_subscription', wcs_get_subscription( $subscription ) );
/**
* Triggered after a new subscription is created.
*
- * @since 2.2.22
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.22
* @param WC_Subscription $subscription
*/
do_action( 'wcs_create_subscription', $subscription );
@@ -220,7 +211,7 @@ function wcs_create_subscription( $args = array() ) {
/**
* Return an array of subscription status types, similar to @see wc_get_order_statuses()
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
* @return array
*/
function wcs_get_subscription_statuses() {
@@ -241,7 +232,7 @@ function wcs_get_subscription_statuses() {
/**
* Get the nice name for a subscription's status
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
* @param string $status
* @return string
*/
@@ -291,7 +282,7 @@ function wcs_get_address_type_to_display( $address_type ) {
/**
* Returns an array of subscription dates
*
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
* @return array
*/
function wcs_get_subscription_date_types() {
@@ -313,7 +304,7 @@ function wcs_get_subscription_date_types() {
*
* @param string A subscription date type key. One of the array key values returned by @see wcs_get_subscription_date_types().
* @param WC_Subscription
- * @since 2.1
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.1
* @return bool
*/
function wcs_display_date_type( $date_type, $subscription ) {
@@ -333,7 +324,7 @@ function wcs_display_date_type( $date_type, $subscription ) {
* Get the meta key value for storing a date in the subscription's post meta table.
*
* @param string $date_type Internally, 'trial_end', 'next_payment' or 'end', but can be any string
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_get_date_meta_key( $date_type ) {
if ( ! is_string( $date_type ) ) {
@@ -351,7 +342,7 @@ function wcs_get_date_meta_key( $date_type ) {
* to make sure they pass the correct date type key, which can involve transforming a prop key or
* deprecated date type key.
*
- * @since 2.2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.0
* @param string $date_type_key String referring to a valid date type, can be: 'date_created', 'trial_end', 'next_payment', 'last_order_date_created' or 'end', or any other value returned by @see this->get_valid_date_types()
* @return string
*/
@@ -401,27 +392,28 @@ function wcs_sanitize_subscription_status_key( $status_key ) {
}
/**
- * A general purpose function for grabbing an array of subscriptions in form of post_id => WC_Subscription
+ * Gets a list of subscriptions that match a certain set of query arguments.
*
- * The $args parameter is based on the parameter of the same name used by the core WordPress @see get_posts() function.
- * It can be used to choose which subscriptions should be returned by the function, how many subscriptions should be returned
- * and in what order those subscriptions should be returned.
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0.
*
- * @param array $args A set of name value pairs to determine the return value.
- * 'subscriptions_per_page' The number of subscriptions to return. Set to -1 for unlimited. Default 10.
- * 'offset' An optional number of subscription to displace or pass over. Default 0.
- * 'orderby' The field which the subscriptions should be ordered by. Can be 'start_date', 'trial_end_date', 'end_date', 'status' or 'order_id'. Defaults to 'start_date'.
- * 'order' The order of the values returned. Can be 'ASC' or 'DESC'. Defaults to 'DESC'
- * 'customer_id' The user ID of a customer on the site.
- * 'product_id' The post ID of a WC_Product_Subscription, WC_Product_Variable_Subscription or WC_Product_Subscription_Variation object
- * 'order_id' The post ID of a shop_order post/WC_Order object which was used to create the subscription
- * 'subscription_status' Any valid subscription status. Can be 'any', 'active', 'cancelled', 'on-hold', 'expired', 'pending' or 'trash'. Defaults to 'any'.
- * @return array Subscription details in post_id => WC_Subscription form.
- * @since 2.0
+ * @param array $args {
+ * A set of name value pairs to query for subscriptions - similar to args supported by wc_get_orders().
+ *
+ * @type string $subscriptions_per_page The number of subscriptions to return. Set to -1 for unlimited. Default 10.
+ * @type int $paged The page of subscriptions to return. Default 1.
+ * @type int $offset An optional number of subscription to displace or pass over. Default 0.
+ * @type string $orderby The field which the subscriptions should be ordered by. Can be 'start_date', 'trial_end_date', 'end_date', 'status' or 'order_id'. Defaults to 'start_date'.
+ * @type string $order The direction to order subscriptions by. Can be 'ASC' or 'DESC'. Defaults to 'DESC'.
+ * @type int $customer_id The ID of the customer whose subscriptions should be returned. Default 0 - No customer restriction.
+ * @type int $product_id To restrict subscriptions to those which contain a certain product ID. Default 0 - No product restriction.
+ * @type int $variation_id To restrict subscriptions to those which contain a certain product variation ID. Default 0 - No variation restriction.
+ * @type int $order_id To restrict subscriptions to those which have a certain parent order ID. Default 0 - No parent order restriction.
+ * @type string $subscription_status The status of the subscriptions to return. Can be 'any', 'active', 'on-hold', 'pending', 'cancelled', 'expired', 'trash', 'pending-cancel'. Default 'any'.
+ * }
+ *
+ * @return WC_Subscription[] An array of WC_Subscription objects keyed by their ID matching the query args.
*/
function wcs_get_subscriptions( $args ) {
- global $wpdb;
-
$args = wp_parse_args(
$args,
array(
@@ -439,20 +431,20 @@ function wcs_get_subscriptions( $args ) {
)
);
- // if order_id is not a shop_order
+ // If the order ID arg is not a shop_order then there's no need to proceed with the query.
if ( 0 !== $args['order_id'] && 'shop_order' !== WC_Data_Store::load( 'order' )->get_order_type( $args['order_id'] ) ) {
return array();
}
// Ensure subscription_status is an array.
- $args['subscription_status'] = $args['subscription_status'] ? (array) $args['subscription_status'] : array();
+ $args['subscription_status'] = $args['subscription_status'] ? (array) $args['subscription_status'] : [];
// Grab the native post stati, removing pending and adding any.
- $builtin = get_post_stati( array( '_builtin' => true ) );
+ $builtin = get_post_stati( [ '_builtin' => true ] );
unset( $builtin['pending'] );
$builtin['any'] = 'any';
- // Make sure status starts with 'wc-'
+ // Make sure statuses start with 'wc-'.
foreach ( $args['subscription_status'] as &$status ) {
if ( isset( $builtin[ $status ] ) ) {
continue;
@@ -461,27 +453,28 @@ function wcs_get_subscriptions( $args ) {
$status = wcs_sanitize_subscription_status_key( $status );
}
- // Prepare the args for WP_Query
+ // Prepare the args for WC_Order_Query.
$query_args = array(
- 'post_type' => 'shop_subscription',
- 'post_status' => $args['subscription_status'],
- 'posts_per_page' => $args['subscriptions_per_page'],
- 'paged' => $args['paged'],
- 'offset' => $args['offset'],
- 'order' => $args['order'],
- 'fields' => 'ids',
- 'meta_query' => isset( $args['meta_query'] ) ? $args['meta_query'] : array(), // just in case we need to filter or order by meta values later
+ 'type' => 'shop_subscription',
+ 'status' => $args['subscription_status'],
+ 'limit' => $args['subscriptions_per_page'],
+ 'page' => $args['paged'],
+ 'offset' => $args['offset'],
+ 'order' => $args['order'],
+ 'return' => 'ids',
+ // just in case we need to filter or order by meta values later
+ 'meta_query' => isset( $args['meta_query'] ) ? $args['meta_query'] : array(), // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
);
// Maybe only get subscriptions created by a certain order
- if ( 0 != $args['order_id'] && is_numeric( $args['order_id'] ) ) {
- $query_args['post_parent'] = $args['order_id'];
+ if ( 0 !== $args['order_id'] && is_numeric( $args['order_id'] ) ) {
+ $query_args['parent'] = $args['order_id'];
}
- // Map subscription specific orderby values to internal/WordPress keys
+ // Map subscription specific orderby values to internal keys.
switch ( $args['orderby'] ) {
case 'status':
- $query_args['orderby'] = 'post_status';
+ wcs_deprecated_argument( __FUNCTION__, 'subscriptions-core 5.0.0', 'The "status" orderby value is deprecated.' );
break;
case 'start_date':
$query_args['orderby'] = 'date';
@@ -506,14 +499,13 @@ function wcs_get_subscriptions( $args ) {
break;
}
- // Maybe filter to a specific user
- if ( 0 != $args['customer_id'] && is_numeric( $args['customer_id'] ) ) {
- $users_subscription_ids = WCS_Customer_Store::instance()->get_users_subscription_ids( $args['customer_id'] );
- $query_args = WCS_Admin_Post_Types::set_post__in_query_var( $query_args, $users_subscription_ids );
- };
+ // Maybe filter to a specific customer.
+ if ( 0 !== $args['customer_id'] && is_numeric( $args['customer_id'] ) ) {
+ $query_args['customer_id'] = $args['customer_id'];
+ }
// We need to restrict subscriptions to those which contain a certain product/variation
- if ( ( 0 != $args['product_id'] && is_numeric( $args['product_id'] ) ) || ( 0 != $args['variation_id'] && is_numeric( $args['variation_id'] ) ) ) {
+ if ( ( 0 !== $args['product_id'] && is_numeric( $args['product_id'] ) ) || ( 0 !== $args['variation_id'] && is_numeric( $args['variation_id'] ) ) ) {
$subscriptions_for_product = wcs_get_subscriptions_for_product( array( $args['product_id'], $args['variation_id'] ) );
$query_args = WCS_Admin_Post_Types::set_post__in_query_var( $query_args, $subscriptions_for_product );
}
@@ -522,14 +514,17 @@ function wcs_get_subscriptions( $args ) {
$query_args['meta_query']['relation'] = $args['meta_query_relation'];
}
- $query_args = apply_filters( 'woocommerce_get_subscriptions_query_args', $query_args, $args );
-
- $subscription_post_ids = get_posts( $query_args );
-
+ /**
+ * Filters the query arguments used to retrieve subscriptions in wcs_get_subscriptions().
+ *
+ * @param array $query_args The query arguments used to retrieve subscriptions.
+ * @param array $args The original wcs_get_subscription() $args parameter.
+ */
+ $query_args = apply_filters( 'woocommerce_get_subscriptions_query_args', $query_args, $args );
$subscriptions = array();
- foreach ( $subscription_post_ids as $post_id ) {
- $subscriptions[ $post_id ] = wcs_get_subscription( $post_id );
+ foreach ( wcs_get_orders_with_meta_query( $query_args ) as $subscription_id ) {
+ $subscriptions[ $subscription_id ] = wcs_get_subscription( $subscription_id );
}
return apply_filters( 'woocommerce_got_subscriptions', $subscriptions, $args );
@@ -545,9 +540,9 @@ function wcs_get_subscriptions( $args ) {
* 'limit' The number of subscriptions to return. Default is all (-1).
* 'offset' An optional number of subscriptions to displace or pass over. Default 0. A limit arg is required for the offset to be applied.
* @return array
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
-function wcs_get_subscriptions_for_product( $product_ids, $fields = 'ids', $args = array() ) {
+function wcs_get_subscriptions_for_product( $product_ids, $fields = 'ids', $args = [] ) {
global $wpdb;
$args = wp_parse_args( $args, array(
@@ -561,12 +556,19 @@ function wcs_get_subscriptions_for_product( $product_ids, $fields = 'ids', $args
$args['limit'] = (int) $args['limit'];
$args['offset'] = (int) $args['offset'];
+ // Set variables to be used in the DB query based on whether HPOS is enabled or not.
+ $is_hpos_in_use = wcs_is_custom_order_tables_usage_enabled();
+ $orders_table_name = $is_hpos_in_use ? 'wc_orders' : 'posts';
+ $orders_type_column_name = $is_hpos_in_use ? 'type' : 'post_type';
+ $orders_status_column_name = $is_hpos_in_use ? 'status' : 'post_status';
+ $orders_id_column_name = $is_hpos_in_use ? 'id' : 'ID';
+
// Start to build the query WHERE array.
- $where = array(
- "posts.post_type = 'shop_subscription'",
+ $where = [
+ "orders.{$orders_type_column_name} = 'shop_subscription'",
"itemmeta.meta_key IN ( '_variation_id', '_product_id' )",
"order_items.order_item_type = 'line_item'",
- );
+ ];
$product_ids = implode( "', '", array_map( 'absint', array_unique( array_filter( (array) $product_ids ) ) ) );
$where[] = sprintf( "itemmeta.meta_value IN ( '%s' )", $product_ids );
@@ -575,23 +577,25 @@ function wcs_get_subscriptions_for_product( $product_ids, $fields = 'ids', $args
// Sanitize and format statuses into status string keys.
$statuses = array_map( 'wcs_sanitize_subscription_status_key', array_map( 'esc_sql', array_unique( array_filter( $args['subscription_status'] ) ) ) );
$statuses = implode( "', '", $statuses );
- $where[] = sprintf( "posts.post_status IN ( '%s' )", $statuses );
+ $where[] = sprintf( "orders.%s IN ( '%s' )", $orders_status_column_name, $statuses );
}
$limit = ( $args['limit'] > 0 ) ? $wpdb->prepare( 'LIMIT %d', $args['limit'] ) : '';
$offset = ( $args['limit'] > 0 && $args['offset'] > 0 ) ? $wpdb->prepare( 'OFFSET %d', $args['offset'] ) : '';
$where = implode( ' AND ', $where );
+ // @codingStandardsIgnoreStart
$subscription_ids = $wpdb->get_col(
"SELECT DISTINCT order_items.order_id
FROM {$wpdb->prefix}woocommerce_order_items as order_items
LEFT JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS itemmeta ON order_items.order_item_id = itemmeta.order_item_id
- LEFT JOIN {$wpdb->posts} AS posts ON order_items.order_id = posts.ID
+ LEFT JOIN {$wpdb->prefix}{$orders_table_name} AS orders ON order_items.order_id = orders.{$orders_id_column_name}
WHERE {$where}
ORDER BY order_items.order_id {$limit} {$offset}"
);
+ // @codingStandardsIgnoreEnd
- $subscriptions = array();
+ $subscriptions = [];
foreach ( $subscription_ids as $post_id ) {
$subscriptions[ $post_id ] = ( 'ids' !== $fields ) ? wcs_get_subscription( $post_id ) : $post_id;
@@ -605,7 +609,7 @@ function wcs_get_subscriptions_for_product( $product_ids, $fields = 'ids', $args
*
* @param mixed WC_Subscription|post_id
* @return array
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_get_line_items_with_a_trial( $subscription_id ) {
@@ -626,7 +630,7 @@ function wcs_get_line_items_with_a_trial( $subscription_id ) {
* Checks if the user can be granted the permission to remove a line item from the subscription.
*
* @param WC_Subscription $subscription An instance of a WC_Subscription object
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_can_items_be_removed( $subscription ) {
$allow_remove = false;
@@ -643,7 +647,7 @@ function wcs_can_items_be_removed( $subscription ) {
*
* @param WC_Order_item $item An instance of a WC_Order_item object
* @param WC_Subscription $subscription An instance of a WC_Subscription object
- * @since 2.2.15
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.15
*/
function wcs_can_item_be_removed( $item, $subscription ) {
return apply_filters( 'wcs_can_item_be_removed', true, $item, $subscription );
@@ -654,7 +658,7 @@ function wcs_can_item_be_removed( $item, $subscription ) {
* is for a variation).
*
* @param int An order item ID
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_get_order_items_product_id( $item_id ) {
global $wpdb;
@@ -695,7 +699,7 @@ function wcs_get_canonical_product_id( $item_or_product ) {
* Return an array statuses used to describe when a subscriptions has been marked as ending or has ended.
*
* @return array
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_get_subscription_ended_statuses() {
return apply_filters( 'wcs_subscription_ended_statuses', array( 'cancelled', 'trash', 'expired', 'switched', 'pending-cancel' ) );
@@ -705,7 +709,7 @@ function wcs_get_subscription_ended_statuses() {
* Returns true when on the My Account > View Subscription front end page.
*
* @return bool
- * @since 2.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
*/
function wcs_is_view_subscription_page() {
global $wp;
@@ -718,7 +722,7 @@ function wcs_is_view_subscription_page() {
*
* @param string $file_name The image file name.
* @return string The image asset url.
- * @since 2.2.20
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.2.20
*/
function wcs_get_image_asset_url( $file_name ) {
return WC_Subscriptions_Core_Plugin::instance()->get_subscriptions_core_directory_url( "assets/images/{$file_name}" );
@@ -729,7 +733,7 @@ function wcs_get_image_asset_url( $file_name ) {
*
* @param string $term Term to search
* @return array of subscription ids
- * @since 2.3.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.3.0
*/
function wcs_subscription_search( $term ) {
global $wpdb;
@@ -815,7 +819,7 @@ function wcs_subscription_search( $term ) {
/**
* Set payment method meta data for a subscription or order.
*
- * @since 2.4.3
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.4.3
* @param WC_Subscription|WC_Order $subscription The subscription or order to set the post payment meta on.
* @param array $payment_meta Associated array of the form: $database_table => array( 'meta_key' => array( 'value' => '' ) )
* @throws InvalidArgumentException
@@ -852,7 +856,7 @@ function wcs_set_payment_meta( $subscription, $payment_meta ) {
/**
* Get total quantity of a product on a subscription or order, even across multiple line items. So we can determine if product has stock available.
*
- * @since 2.6.0
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.6.0
*
* @param WC_Order|WC_Subscription $subscription Order or subscription object.
* @param WC_Product $product The product to get the total quantity of.
@@ -901,7 +905,7 @@ function wcs_get_total_line_item_product_quantity( $order, $product, $product_ma
*
* Sites are considered large if they have more than 3000 subscriptions or more than 25000 orders.
*
- * @since 3.0.7
+ * @since 1.0.0 - Migrated from WooCommerce Subscriptions v3.0.7
* @return bool True for large sites, otherwise false.
*/
function wcs_is_large_site() {
@@ -910,7 +914,10 @@ function wcs_is_large_site() {
// If an option has been set previously, convert it to a bool.
if ( false !== $is_large_site ) {
$is_large_site = wc_string_to_bool( $is_large_site );
- } elseif ( array_sum( (array) wp_count_posts( 'shop_subscription' ) ) > 3000 || array_sum( (array) wp_count_posts( 'shop_order' ) ) > 25000 ) {
+ } elseif (
+ array_sum( WC_Data_Store::load( 'subscription' )->get_subscriptions_count_by_status() ) > 3000
+ || ( ! wcs_is_custom_order_tables_usage_enabled() && array_sum( (array) wp_count_posts( 'shop_order' ) ) > 25000 )
+ ) {
$is_large_site = true;
update_option( 'wcs_is_large_site', wc_bool_to_string( $is_large_site ), false );
} else {
diff --git a/vendor/woocommerce/subscriptions-core/woocommerce-subscriptions-core.php b/vendor/woocommerce/subscriptions-core/woocommerce-subscriptions-core.php
index 3c537fd..c961785 100644
--- a/vendor/woocommerce/subscriptions-core/woocommerce-subscriptions-core.php
+++ b/vendor/woocommerce/subscriptions-core/woocommerce-subscriptions-core.php
@@ -6,5 +6,5 @@
* Author: Automattic
* Author URI: https://woocommerce.com/
* Requires WP: 5.6
- * Version: 2.3.0
+ * Version: 5.8.0
*/
diff --git a/woo-includes/class-wc-dependencies.php b/woo-includes/class-wc-dependencies.php
deleted file mode 100644
index 2064ea6..0000000
--- a/woo-includes/class-wc-dependencies.php
+++ /dev/null
@@ -1,28 +0,0 @@
-file = $file;
- $plugin->file_id = $file_id;
- $plugin->product_id = $product_id;
-
- $woothemes_queued_updates[] = $plugin;
- }
-}
-
-/**
- * Load installer for the WooThemes Updater.
- * @return Object $api
- */
-if ( ! class_exists( 'WooThemes_Updater' ) && ! function_exists( 'woothemes_updater_install' ) ) {
- function woothemes_updater_install( $api, $action, $args ) {
- $download_url = 'http://woodojo.s3.amazonaws.com/downloads/woothemes-updater/woothemes-updater.zip';
-
- if ( 'plugin_information' != $action ||
- false !== $api ||
- ! isset( $args->slug ) ||
- 'woothemes-updater' != $args->slug
- ) return $api;
-
- $api = new stdClass();
- $api->name = 'WooThemes Updater';
- $api->version = '1.0.0';
- $api->download_link = esc_url( $download_url );
- return $api;
- }
-
- add_filter( 'plugins_api', 'woothemes_updater_install', 10, 3 );
-}
-
-/**
- * Prevent conflicts with older versions
- */
-if ( ! class_exists( 'WooThemes_Plugin_Updater' ) ) {
- class WooThemes_Plugin_Updater { function init() {} }
-}
diff --git a/woocommerce-subscriptions.php b/woocommerce-subscriptions.php
index 4aa84ac..5b74595 100644
--- a/woocommerce-subscriptions.php
+++ b/woocommerce-subscriptions.php
@@ -5,10 +5,10 @@
* Description: Sell products and services with recurring payments in your WooCommerce Store.
* Author: WooCommerce
* Author URI: https://woocommerce.com/
- * Version: 4.6.0
+ * Version: 5.2.0
*
- * WC requires at least: 4.4
- * WC tested up to: 6.5.0
+ * WC requires at least: 6.5
+ * WC tested up to: 7.8.0
* Woo: 27147:6115e6d7e297b623a169fdcf5728b224
*
* Copyright 2019 WooCommerce
@@ -31,33 +31,25 @@
* @since 1.0
*/
-/**
- * Required functions
- */
-if ( ! function_exists( 'woothemes_queue_update' ) || ! function_exists( 'is_woocommerce_active' ) ) {
- require_once dirname( __FILE__ ) . '/woo-includes/woo-functions.php';
-}
+require_once( 'includes/class-wc-subscriptions-dependency-manager.php' );
+$dependency_manager = new WC_Subscriptions_Dependency_Manager( WC_Subscriptions::$wc_minimum_supported_version );
-/**
- * Check if WooCommerce is active and at the required minimum version, and if it isn't, disable Subscriptions.
- *
- * @since 1.0
- */
-if ( ! is_woocommerce_active() || version_compare( get_option( 'woocommerce_db_version' ), WC_Subscriptions::$wc_minimum_supported_version, '<' ) ) {
- add_action( 'admin_notices', 'WC_Subscriptions::woocommerce_inactive_notice' );
+// Check the dependencies before loading the plugin. If the dependencies are not met, display an admin notice and exit
+if ( ! $dependency_manager->has_valid_dependencies() ) {
+ add_action( 'admin_notices', [ $dependency_manager, 'display_dependency_admin_notice' ] );
return;
}
/**
- * Declare plugin incompatibility with WooCommerce HPOS.
+ * Declare plugin compatibility with WooCommerce HPOS.
*
- * @since 4.6.0
+ * @since 4.9.0
*/
add_action(
'before_woocommerce_init',
function() {
if ( class_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil' ) ) {
- \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, false );
+ \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
}
}
);
@@ -85,10 +77,10 @@ class WC_Subscriptions {
public static $plugin_file = __FILE__;
/** @var string */
- public static $version = '4.6.0';
+ public static $version = '5.2.0'; // WRCS: DEFINED_VERSION.
/** @var string */
- public static $wc_minimum_supported_version = '4.4';
+ public static $wc_minimum_supported_version = '6.5';
/** @var WCS_Cache_Manager */
public static $cache;
@@ -116,37 +108,14 @@ class WC_Subscriptions {
/**
* Called when WooCommerce is inactive or running and out-of-date version to display an inactive notice.
*
+ * @deprecated 5.0.0
+ *
* @since 1.2
*/
public static function woocommerce_inactive_notice() {
- if ( current_user_can( 'activate_plugins' ) ) {
- $admin_notice_content = '';
-
- if ( ! is_woocommerce_active() ) {
- $install_url = wp_nonce_url(
- add_query_arg(
- array(
- 'action' => 'install-plugin',
- 'plugin' => 'woocommerce',
- ),
- admin_url( 'update.php' )
- ),
- 'install-plugin_woocommerce'
- );
-
- // translators: 1$-2$: opening and closing tags, 3$-4$: link tags, takes to woocommerce plugin on wp.org, 5$-6$: opening and closing link tags, leads to plugins.php in admin
- $admin_notice_content = sprintf( esc_html__( '%1$sWooCommerce Subscriptions is inactive.%2$s The %3$sWooCommerce plugin%4$s must be active for WooCommerce Subscriptions to work. Please %5$sinstall & activate WooCommerce »%6$s', 'woocommerce-subscriptions' ), '', ' ', '', ' ', '', ' ' );
- } elseif ( version_compare( get_option( 'woocommerce_db_version' ), self::$wc_minimum_supported_version, '<' ) ) {
- // translators: 1$-2$: opening and closing tags, 3$: minimum supported WooCommerce version, 4$-5$: opening and closing link tags, leads to plugin admin
- $admin_notice_content = sprintf( esc_html__( '%1$sWooCommerce Subscriptions is inactive.%2$s This version of Subscriptions requires WooCommerce %3$s or newer. Please %4$supdate WooCommerce to version %3$s or newer »%5$s', 'woocommerce-subscriptions' ), '', ' ', self::$wc_minimum_supported_version, '', ' ' );
- }
-
- if ( $admin_notice_content ) {
- echo '';
- echo '
' . wp_kses_post( $admin_notice_content ) . '
';
- echo '
';
- }
- }
+ _deprecated_function( __METHOD__, '5.0.0', 'WC_Subscriptions_Dependency_Manager::display_dependency_admin_notice' );
+ $dependency_manager = new WC_Subscriptions_Dependency_Manager( WC_Subscriptions::$wc_minimum_supported_version );
+ $dependency_manager->display_dependency_admin_notice();
}
/* Deprecated Functions */
@@ -212,7 +181,7 @@ register_activation_hook( __FILE__, 'add_woocommerce_inbox_variant' );
*/
function wcs_init_autoloader() {
if ( ! function_exists( 'is_plugin_active' ) ) {
- include_once ABSPATH . 'wp-admin/includes/plugin.php';
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$wcs_core_plugin_slug = 'woocommerce-subscriptions-core/woocommerce-subscriptions-core.php';