This commit is contained in:
Prospress Inc
2019-12-24 15:29:44 +01:00
committed by Remco Tolsma
parent 091a1c9089
commit 92239cc451
38 changed files with 947 additions and 615 deletions

View File

@@ -434,6 +434,8 @@ class WC_Subscription extends WC_Order {
break;
case 'pending-cancel' :
// Store the subscription's end date before overriding it. Used for restoring the dates if the customer reactivates the subscription.
$this->update_meta_data( 'end_date_pre_cancellation', $this->get_date( 'end' ) );
$end_date = $this->calculate_date( 'end_of_prepaid_term' );
@@ -456,7 +458,7 @@ class WC_Subscription extends WC_Order {
if ( 'pending-cancel' === $old_status ) {
$this->update_dates( array(
'cancelled' => 0,
'end' => 0,
'end' => $this->meta_exists( 'end_date_pre_cancellation' ) ? $this->get_meta( 'end_date_pre_cancellation' ) : 0,
'next_payment' => $this->get_date( 'end' ),
) );
} else {
@@ -1016,7 +1018,7 @@ class WC_Subscription extends WC_Order {
$date->setTimezone( new DateTimeZone( 'UTC' ) );
}
$date = $date->format( 'Y-m-d H:i:s' );
$date = $date->date( 'Y-m-d H:i:s' );
}
return apply_filters( 'woocommerce_subscription_get_' . $date_type . '_date', $date, $this, $timezone );
@@ -1228,8 +1230,6 @@ class WC_Subscription extends WC_Order {
* @param string $timezone The timezone of the $datetime param. Default 'gmt'.
*/
public function update_dates( $dates, $timezone = 'gmt' ) {
global $wpdb;
$dates = $this->validate_date_updates( $dates, $timezone );
// If an exception hasn't been thrown by this point, we can safely update the dates
@@ -2338,7 +2338,7 @@ class WC_Subscription extends WC_Order {
continue;
}
// We don't want to validate dates for relates orders when instantiating the subscription
// We don't want to validate dates for related orders when instantiating the subscription
if ( false === $this->object_read && ( 0 === strpos( $date_type, 'last_order_date_' ) || in_array( $date_type, array( 'date_paid', 'date_completed' ) ) ) ) {
continue;
}