mirror of
https://github.com/pronamic/woocommerce-subscriptions.git
synced 2025-10-07 18:14:03 +00:00
2.3.7
This commit is contained in:

committed by
Remco Tolsma

parent
a3be3724dc
commit
ce24e61a4c
@@ -743,4 +743,27 @@ jQuery(document).ready(function($){
|
|||||||
};
|
};
|
||||||
wcs_prevent_variation_removal.init();
|
wcs_prevent_variation_removal.init();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Prevents changing of the product type for subscription products in use by a subscription.
|
||||||
|
*/
|
||||||
|
var wcs_prevent_product_type_change = {
|
||||||
|
init: function() {
|
||||||
|
if ( 'yes' !== WCSubscriptions.productHasSubscriptions ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var $select = $( 'select#product-type' );
|
||||||
|
var $options = $select.find( 'option' );
|
||||||
|
var $selection = $options.filter( 'option:selected' );
|
||||||
|
|
||||||
|
if ( 'subscription' !== $selection.val() && 'variable-subscription' !== $selection.val() ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$options.not( $selection ).prop( 'disabled', true );
|
||||||
|
$select.addClass( 'tips' ).attr( 'data-tip', WCSubscriptions.productTypeWarning );
|
||||||
|
},
|
||||||
|
};
|
||||||
|
wcs_prevent_product_type_change.init();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,25 @@
|
|||||||
*** WooCommerce Subscriptions Changelog ***
|
*** WooCommerce Subscriptions Changelog ***
|
||||||
|
|
||||||
|
2018.09.25 - version 2.3.7
|
||||||
|
* Fix: Don't apply subscription payment gateway filters while on the order-pay page. PR#2927
|
||||||
|
* Fix: Prevent admin users from changing product type when the product has active subscriptions. PR#2932
|
||||||
|
* Fix: Avoid calculating the initial order carts shipping without an address. PR#2923
|
||||||
|
* Fix: Remove unnecessary empty() check for PHP < 5.5 compat. PR#2940
|
||||||
|
* Fix: Reinstate switch orders being returned from WC_Subscription::get_related_orders() when called with the default $order_type param. This returns the behavior of this function to what it was pre v2.3. PR#2946
|
||||||
|
* Tweak: [WC 3.4] Dont escape the product attribute labels in the add-to-cart/variable-subscription.php template. PR#2914
|
||||||
|
* Tweak: Add a link to the subscription customer's profile on the admin edit subscription screen. PR#2911
|
||||||
|
* Tweak: [dev] Update calls of remove_action() and remove_filter() removing the unused 4th parameter. PR#2926
|
||||||
|
|
||||||
|
2018.09.10 - version 2.3.6
|
||||||
|
* New: Include subscription paid and completed UTC dates in REST API subscriptions response. PR#2895
|
||||||
|
* Fix: When switching during a free trial the days in the new cycle are equal to the days in the old cycle. This returns next payment date calculations to what it was pre 2.3.3. PR#2887
|
||||||
|
* Fix: Make sure to display the inactive plugin notice on sites running unsupported WC versions. PR#2878
|
||||||
|
* Fix: Reinstate the _customer_user admin subscriptions table filter by customer $_GET arg. PR#2884
|
||||||
|
* Tweak: Automatically add download permissions for manually created subscriptions. PR#2836
|
||||||
|
* Tweak: Modify renewal order staging note to include URLs of the live and staging site. PR#2881
|
||||||
|
* Tweak: Rename WC_Subscriptions_Change_Payment_Gateway::store_pay_shortcode_mesages(). PR#2899
|
||||||
|
* Tweak: Set "add to cart" and "place order" button text settings to default if no value is provided. PR#2676
|
||||||
|
|
||||||
2018.08.27 - version 2.3.5
|
2018.08.27 - version 2.3.5
|
||||||
* Fix: Exclude customers with at least 1 subscription from the WC inactivity user cleanup query. PR#2830
|
* Fix: Exclude customers with at least 1 subscription from the WC inactivity user cleanup query. PR#2830
|
||||||
* Fix: Calculate PayPal trial args from the next payment date while resubscribing before the subscription's end date. PR#2828
|
* Fix: Calculate PayPal trial args from the next payment date while resubscribing before the subscription's end date. PR#2828
|
||||||
|
@@ -713,8 +713,8 @@ class WC_Subscriptions_Admin {
|
|||||||
// Get admin screen id
|
// Get admin screen id
|
||||||
$screen = get_current_screen();
|
$screen = get_current_screen();
|
||||||
|
|
||||||
$is_woocommerce_screen = ( in_array( $screen->id, array( 'product', 'edit-shop_order', 'shop_order', 'edit-shop_subscription', 'shop_subscription', 'users', 'woocommerce_page_wc-settings' ) ) ) ? true : false;
|
$is_woocommerce_screen = in_array( $screen->id, array( 'product', 'edit-shop_order', 'shop_order', 'edit-shop_subscription', 'shop_subscription', 'users', 'woocommerce_page_wc-settings' ) );
|
||||||
$is_activation_screen = ( get_transient( WC_Subscriptions::$activation_transient ) == true ) ? true : false;
|
$is_activation_screen = (bool) get_transient( WC_Subscriptions::$activation_transient );
|
||||||
|
|
||||||
if ( $is_woocommerce_screen ) {
|
if ( $is_woocommerce_screen ) {
|
||||||
|
|
||||||
@@ -739,6 +739,8 @@ class WC_Subscriptions_Admin {
|
|||||||
'bulkEditIntervalhMessage' => __( 'Enter a new interval as a single number (e.g. to charge every 2nd month, enter 2):', 'woocommerce-subscriptions' ),
|
'bulkEditIntervalhMessage' => __( 'Enter a new interval as a single number (e.g. to charge every 2nd month, enter 2):', 'woocommerce-subscriptions' ),
|
||||||
'bulkDeleteOptionLabel' => __( 'Delete all variations without a subscription', 'woocommerce-subscriptions' ),
|
'bulkDeleteOptionLabel' => __( 'Delete all variations without a subscription', 'woocommerce-subscriptions' ),
|
||||||
'oneTimeShippingCheckNonce' => wp_create_nonce( 'one_time_shipping' ),
|
'oneTimeShippingCheckNonce' => wp_create_nonce( 'one_time_shipping' ),
|
||||||
|
'productHasSubscriptions' => wcs_get_subscriptions_for_product( $post->ID ) ? 'yes' : 'no',
|
||||||
|
'productTypeWarning' => __( 'Product type can not be changed because this product is associated with active subscriptions', 'woocommerce-subscriptions' ),
|
||||||
);
|
);
|
||||||
} else if ( 'edit-shop_order' == $screen->id ) {
|
} else if ( 'edit-shop_order' == $screen->id ) {
|
||||||
$script_params = array(
|
$script_params = array(
|
||||||
@@ -965,7 +967,31 @@ class WC_Subscriptions_Admin {
|
|||||||
unset( $_POST[ self::$option_prefix . '_turn_off_automatic_payments' ] );
|
unset( $_POST[ self::$option_prefix . '_turn_off_automatic_payments' ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
woocommerce_update_options( self::get_settings() );
|
$settings = self::get_settings();
|
||||||
|
$defaults_to_find = array(
|
||||||
|
self::$option_prefix . '_add_to_cart_button_text' => '',
|
||||||
|
self::$option_prefix . '_order_button_text' => '',
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ( $settings as $setting ) {
|
||||||
|
if ( ! isset( $setting['id'], $setting['default'], $defaults_to_find[ $setting['id'] ], $_POST[ $setting['id'] ] ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the setting to its default if no value has been submitted.
|
||||||
|
if ( '' === wc_clean( $_POST[ $setting['id'] ] ) ) {
|
||||||
|
$_POST[ $setting['id'] ] = $setting['default'];
|
||||||
|
}
|
||||||
|
|
||||||
|
unset( $defaults_to_find[ $setting['id'] ] );
|
||||||
|
|
||||||
|
// If all defaults have been found, exit.
|
||||||
|
if ( ! count( $defaults_to_find ) ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
woocommerce_update_options( $settings );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1044,6 +1070,7 @@ class WC_Subscriptions_Admin {
|
|||||||
'default' => __( 'Sign Up Now', 'woocommerce-subscriptions' ),
|
'default' => __( 'Sign Up Now', 'woocommerce-subscriptions' ),
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'desc_tip' => true,
|
'desc_tip' => true,
|
||||||
|
'placeholder' => __( 'Sign Up Now', 'woocommerce-subscriptions' ),
|
||||||
),
|
),
|
||||||
|
|
||||||
array(
|
array(
|
||||||
@@ -1055,6 +1082,7 @@ class WC_Subscriptions_Admin {
|
|||||||
'default' => __( 'Sign Up Now', 'woocommerce-subscriptions' ),
|
'default' => __( 'Sign Up Now', 'woocommerce-subscriptions' ),
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'desc_tip' => true,
|
'desc_tip' => true,
|
||||||
|
'placeholder' => __( 'Sign Up Now', 'woocommerce-subscriptions' ),
|
||||||
),
|
),
|
||||||
|
|
||||||
array( 'type' => 'sectionend', 'id' => self::$option_prefix . '_button_text' ),
|
array( 'type' => 'sectionend', 'id' => self::$option_prefix . '_button_text' ),
|
||||||
@@ -1502,7 +1530,7 @@ class WC_Subscriptions_Admin {
|
|||||||
$screen = get_current_screen();
|
$screen = get_current_screen();
|
||||||
|
|
||||||
if ( is_object( $screen ) && 'shop_order' == $screen->id ) {
|
if ( is_object( $screen ) && 'shop_order' == $screen->id ) {
|
||||||
remove_filter( 'woocommerce_get_formatted_order_total', 'WC_Subscriptions_Order::get_formatted_order_total', 10, 2 );
|
remove_filter( 'woocommerce_get_formatted_order_total', 'WC_Subscriptions_Order::get_formatted_order_total', 10 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1533,7 +1561,7 @@ class WC_Subscriptions_Admin {
|
|||||||
$screen = get_current_screen();
|
$screen = get_current_screen();
|
||||||
|
|
||||||
if ( is_object( $screen ) && 'shop_subscription' == $screen->id ) {
|
if ( is_object( $screen ) && 'shop_subscription' == $screen->id ) {
|
||||||
remove_filter( 'gettext', __CLASS__ . '::change_order_item_editable_text', 10, 3 );
|
remove_filter( 'gettext', __CLASS__ . '::change_order_item_editable_text', 10 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -81,7 +81,7 @@ class WCS_Admin_Meta_Boxes {
|
|||||||
public function remove_meta_box_save( $post_id, $post ) {
|
public function remove_meta_box_save( $post_id, $post ) {
|
||||||
|
|
||||||
if ( 'shop_subscription' == $post->post_type ) {
|
if ( 'shop_subscription' == $post->post_type ) {
|
||||||
remove_action( 'woocommerce_process_shop_order_meta', 'WC_Meta_Box_Order_Data::save', 40, 2 );
|
remove_action( 'woocommerce_process_shop_order_meta', 'WC_Meta_Box_Order_Data::save', 40 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -85,18 +85,20 @@ class WCS_Admin_Notice {
|
|||||||
* @since 2.3.0
|
* @since 2.3.0
|
||||||
*/
|
*/
|
||||||
public function display() {
|
public function display() {
|
||||||
|
|
||||||
if ( 'admin_notices' !== current_filter() ) {
|
if ( 'admin_notices' !== current_filter() ) {
|
||||||
add_action( 'admin_notices', array( $this, __FUNCTION__ ) );
|
add_action( 'admin_notices', array( $this, __FUNCTION__ ) );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wc_get_template(
|
$template_name = 'html-admin-notice.php';
|
||||||
'html-admin-notice.php',
|
$template_path = plugin_dir_path( WC_Subscriptions::$plugin_file ) . 'templates/admin/';
|
||||||
array( 'notice' => $this ),
|
|
||||||
'',
|
if ( function_exists( 'wc_get_template' ) ) {
|
||||||
plugin_dir_path( WC_Subscriptions::$plugin_file ) . 'templates/admin/'
|
wc_get_template( $template_name, array( 'notice' => $this ), '', $template_path );
|
||||||
);
|
} else {
|
||||||
|
$notice = $this;
|
||||||
|
include( $template_path . $template_name );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -745,8 +745,8 @@ class WCS_Admin_Post_Types {
|
|||||||
if ( 'shop_subscription' === $typenow ) {
|
if ( 'shop_subscription' === $typenow ) {
|
||||||
|
|
||||||
// Filter the orders by the posted customer.
|
// Filter the orders by the posted customer.
|
||||||
if ( isset( $_GET['_subscriber_id'] ) && $_GET['_subscriber_id'] > 0 ) {
|
if ( isset( $_GET['_customer_user'] ) && $_GET['_customer_user'] > 0 ) {
|
||||||
$subscription_ids = WCS_Customer_Store::instance()->get_users_subscription_ids( absint( $_GET['_subscriber_id'] ) );
|
$subscription_ids = WCS_Customer_Store::instance()->get_users_subscription_ids( absint( $_GET['_customer_user'] ) );
|
||||||
$vars = self::set_post__in_query_var( $vars, $subscription_ids );
|
$vars = self::set_post__in_query_var( $vars, $subscription_ids );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1105,8 +1105,8 @@ class WCS_Admin_Post_Types {
|
|||||||
$user_string = '';
|
$user_string = '';
|
||||||
$user_id = '';
|
$user_id = '';
|
||||||
|
|
||||||
if ( ! empty( $_GET['_subscriber_id'] ) ) {
|
if ( ! empty( $_GET['_customer_user'] ) ) {
|
||||||
$user_id = absint( $_GET['_subscriber_id'] );
|
$user_id = absint( $_GET['_customer_user'] );
|
||||||
$user = get_user_by( 'id', $user_id );
|
$user = get_user_by( 'id', $user_id );
|
||||||
|
|
||||||
$user_string = sprintf(
|
$user_string = sprintf(
|
||||||
@@ -1118,7 +1118,7 @@ class WCS_Admin_Post_Types {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<select class="wc-customer-search" name="_subscriber_id" data-placeholder="<?php esc_attr_e( 'Search for a customer…', 'woocommerce-subscriptions' ); ?>" data-allow_clear="true">
|
<select class="wc-customer-search" name="_customer_user" data-placeholder="<?php esc_attr_e( 'Search for a customer…', 'woocommerce-subscriptions' ); ?>" data-allow_clear="true">
|
||||||
<option value="<?php echo esc_attr( $user_id ); ?>" selected="selected"><?php echo wp_kses_post( $user_string ); ?></option>
|
<option value="<?php echo esc_attr( $user_id ); ?>" selected="selected"><?php echo wp_kses_post( $user_string ); ?></option>
|
||||||
</select>
|
</select>
|
||||||
<?php
|
<?php
|
||||||
|
@@ -62,6 +62,11 @@ class WCS_Meta_Box_Subscription_Data extends WC_Meta_Box_Order_Data {
|
|||||||
esc_url( add_query_arg( $args, admin_url( 'edit.php' ) ) ),
|
esc_url( add_query_arg( $args, admin_url( 'edit.php' ) ) ),
|
||||||
esc_html__( 'View other subscriptions', 'woocommerce-subscriptions' )
|
esc_html__( 'View other subscriptions', 'woocommerce-subscriptions' )
|
||||||
);
|
);
|
||||||
|
printf(
|
||||||
|
'<a href="%s">%s</a>',
|
||||||
|
esc_url( add_query_arg( 'user_id', $subscription->get_user_id(), admin_url( 'user-edit.php' ) ) ),
|
||||||
|
esc_html__( 'Profile', 'woocommerce-subscriptions' )
|
||||||
|
);
|
||||||
}
|
}
|
||||||
?></label>
|
?></label>
|
||||||
<?php
|
<?php
|
||||||
@@ -302,7 +307,10 @@ class WCS_Meta_Box_Subscription_Data extends WC_Meta_Box_Order_Data {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update meta
|
// Update meta
|
||||||
update_post_meta( $post_id, '_customer_user', absint( $_POST['customer_user'] ) );
|
$customer_id = isset( $_POST['customer_user'] ) ? absint( $_POST['customer_user'] ) : 0;
|
||||||
|
if ( $customer_id !== $subscription->get_customer_id() ) {
|
||||||
|
wcs_set_objects_property( $subscription, '_customer_user', $customer_id );
|
||||||
|
}
|
||||||
|
|
||||||
// Handle the billing fields.
|
// Handle the billing fields.
|
||||||
foreach ( self::$billing_fields as $key => $field ) {
|
foreach ( self::$billing_fields as $key => $field ) {
|
||||||
@@ -350,6 +358,11 @@ class WCS_Meta_Box_Subscription_Data extends WC_Meta_Box_Order_Data {
|
|||||||
wcs_add_admin_notice( sprintf( __( 'Error updating some information: %s', 'woocommerce-subscriptions' ), $e->getMessage() ), 'error' );
|
wcs_add_admin_notice( sprintf( __( 'Error updating some information: %s', 'woocommerce-subscriptions' ), $e->getMessage() ), 'error' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Grant download permissions on initial save.
|
||||||
|
if ( isset( $_POST['original_post_status'] ) && 'auto-draft' === $_POST['original_post_status'] ) {
|
||||||
|
wc_downloadable_product_permissions( $post_id );
|
||||||
|
}
|
||||||
|
|
||||||
do_action( 'woocommerce_process_shop_subscription_meta', $post_id, $post );
|
do_action( 'woocommerce_process_shop_subscription_meta', $post_id, $post );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -95,6 +95,10 @@ class WC_REST_Subscriptions_Controller extends WC_REST_Orders_V1_Controller {
|
|||||||
|
|
||||||
$response->data[ $date_type . '_date' ] = ( ! empty( $date ) ) ? wc_rest_prepare_date_response( $date ) : '';
|
$response->data[ $date_type . '_date' ] = ( ! empty( $date ) ) ? wc_rest_prepare_date_response( $date ) : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// v1 API includes some date types in site time, include those dates in UTC as well.
|
||||||
|
$response->data['date_completed_gmt'] = wc_rest_prepare_date_response( $subscription->get_date_completed() );
|
||||||
|
$response->data['date_paid_gmt'] = wc_rest_prepare_date_response( $subscription->get_date_paid() );
|
||||||
}
|
}
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
@@ -464,6 +468,18 @@ class WC_REST_Subscriptions_Controller extends WC_REST_Orders_V1_Controller {
|
|||||||
'context' => array( 'view' ),
|
'context' => array( 'view' ),
|
||||||
'readonly' => true,
|
'readonly' => true,
|
||||||
),
|
),
|
||||||
|
'date_completed_gmt' => array(
|
||||||
|
'description' => __( "The date the subscription's latest order was completed, in GMT.", 'woocommerce-subscriptions' ),
|
||||||
|
'type' => 'date-time',
|
||||||
|
'context' => array( 'view' ),
|
||||||
|
'readonly' => true,
|
||||||
|
),
|
||||||
|
'date_paid_gmt' => array(
|
||||||
|
'description' => __( "The date the subscription's latest order was paid, in GMT.", 'woocommerce-subscriptions' ),
|
||||||
|
'type' => 'date-time',
|
||||||
|
'context' => array( 'view' ),
|
||||||
|
'readonly' => true,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
$schema['properties'] += $subscriptions_schema;
|
$schema['properties'] += $subscriptions_schema;
|
||||||
|
@@ -165,7 +165,7 @@ class WC_Product_Subscription_Variation extends WC_Product_Variation {
|
|||||||
|
|
||||||
$sign_up_fee_including_tax = parent::get_price_including_tax( $qty );
|
$sign_up_fee_including_tax = parent::get_price_including_tax( $qty );
|
||||||
|
|
||||||
remove_filter( 'woocommerce_get_price', array( &$this, 'get_sign_up_fee' ), 100, 0 );
|
remove_filter( 'woocommerce_get_price', array( &$this, 'get_sign_up_fee' ), 100 );
|
||||||
|
|
||||||
return $sign_up_fee_including_tax;
|
return $sign_up_fee_including_tax;
|
||||||
}
|
}
|
||||||
@@ -183,7 +183,7 @@ class WC_Product_Subscription_Variation extends WC_Product_Variation {
|
|||||||
|
|
||||||
$sign_up_fee_excluding_tax = parent::get_price_excluding_tax( $qty );
|
$sign_up_fee_excluding_tax = parent::get_price_excluding_tax( $qty );
|
||||||
|
|
||||||
remove_filter( 'woocommerce_get_price', array( &$this, 'get_sign_up_fee' ), 100, 0 );
|
remove_filter( 'woocommerce_get_price', array( &$this, 'get_sign_up_fee' ), 100 );
|
||||||
|
|
||||||
return $sign_up_fee_excluding_tax;
|
return $sign_up_fee_excluding_tax;
|
||||||
}
|
}
|
||||||
|
@@ -1762,11 +1762,11 @@ class WC_Subscription extends WC_Order {
|
|||||||
* Get the related orders for a subscription, including renewal orders and the initial order (if any)
|
* Get the related orders for a subscription, including renewal orders and the initial order (if any)
|
||||||
*
|
*
|
||||||
* @param string $return_fields The columns to return, either 'all' or 'ids'
|
* @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' ).
|
* @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 2.0
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function get_related_orders( $return_fields = 'ids', $order_types = array( 'parent', 'renewal' ) ) {
|
public function get_related_orders( $return_fields = 'ids', $order_types = array( 'parent', 'renewal', 'switch' ) ) {
|
||||||
|
|
||||||
$return_fields = ( 'ids' == $return_fields ) ? $return_fields : 'all';
|
$return_fields = ( 'ids' == $return_fields ) ? $return_fields : 'all';
|
||||||
|
|
||||||
@@ -2176,7 +2176,7 @@ class WC_Subscription extends WC_Order {
|
|||||||
$files = array();
|
$files = array();
|
||||||
|
|
||||||
// WC Emails are sent before the subscription status is updated to active etc. so we need a way to ensure download links are added to the emails before being sent
|
// WC Emails are sent before the subscription status is updated to active etc. so we need a way to ensure download links are added to the emails before being sent
|
||||||
$sending_email = ( did_action( 'woocommerce_email_before_order_table' ) > did_action( 'woocommerce_email_after_order_table' ) ) ? true : false;
|
$sending_email = did_action( 'woocommerce_email_before_order_table' ) > did_action( 'woocommerce_email_after_order_table' );
|
||||||
|
|
||||||
if ( $this->has_status( apply_filters( 'woocommerce_subscription_item_download_statuses', array( 'active', 'pending-cancel' ) ) ) || $sending_email ) {
|
if ( $this->has_status( apply_filters( 'woocommerce_subscription_item_download_statuses', array( 'active', 'pending-cancel' ) ) ) || $sending_email ) {
|
||||||
$files = parent::get_item_downloads( $item );
|
$files = parent::get_item_downloads( $item );
|
||||||
|
@@ -339,7 +339,11 @@ class WC_Subscriptions_Cart {
|
|||||||
// We need to reset the packages and totals stored in WC()->shipping too
|
// We need to reset the packages and totals stored in WC()->shipping too
|
||||||
WC()->shipping->reset_shipping();
|
WC()->shipping->reset_shipping();
|
||||||
self::maybe_restore_shipping_methods();
|
self::maybe_restore_shipping_methods();
|
||||||
|
|
||||||
|
// Only calculate the initial order cart shipping if we need to show shipping.
|
||||||
|
if ( WC()->cart->show_shipping() ) {
|
||||||
WC()->cart->calculate_shipping();
|
WC()->cart->calculate_shipping();
|
||||||
|
}
|
||||||
|
|
||||||
// We no longer need our backup of shipping methods
|
// We no longer need our backup of shipping methods
|
||||||
unset( WC()->session->wcs_shipping_methods );
|
unset( WC()->session->wcs_shipping_methods );
|
||||||
@@ -703,14 +707,14 @@ class WC_Subscriptions_Cart {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Avoid infinite loop
|
// Avoid infinite loop
|
||||||
remove_filter( 'woocommerce_cart_product_subtotal', __CLASS__ . '::get_formatted_product_subtotal', 11, 4 );
|
remove_filter( 'woocommerce_cart_product_subtotal', __CLASS__ . '::get_formatted_product_subtotal', 11 );
|
||||||
|
|
||||||
add_filter( $product_price_filter, 'WC_Subscriptions_Product::get_sign_up_fee_filter', 100, 2 );
|
add_filter( $product_price_filter, 'WC_Subscriptions_Product::get_sign_up_fee_filter', 100, 2 );
|
||||||
|
|
||||||
// And get the appropriate sign up fee string
|
// And get the appropriate sign up fee string
|
||||||
$sign_up_fee_string = $cart->get_product_subtotal( $product, $quantity );
|
$sign_up_fee_string = $cart->get_product_subtotal( $product, $quantity );
|
||||||
|
|
||||||
remove_filter( $product_price_filter, 'WC_Subscriptions_Product::get_sign_up_fee_filter', 100, 2 );
|
remove_filter( $product_price_filter, 'WC_Subscriptions_Product::get_sign_up_fee_filter', 100 );
|
||||||
|
|
||||||
add_filter( 'woocommerce_cart_product_subtotal', __CLASS__ . '::get_formatted_product_subtotal', 11, 4 );
|
add_filter( 'woocommerce_cart_product_subtotal', __CLASS__ . '::get_formatted_product_subtotal', 11, 4 );
|
||||||
|
|
||||||
@@ -1985,7 +1989,7 @@ class WC_Subscriptions_Cart {
|
|||||||
'trial_period' => self::get_cart_subscription_trial_period(),
|
'trial_period' => self::get_cart_subscription_trial_period(),
|
||||||
);
|
);
|
||||||
|
|
||||||
$is_one_payment = ( self::get_cart_subscription_length() > 0 && self::get_cart_subscription_length() == self::get_cart_subscription_interval() ) ? true : false;
|
$is_one_payment = self::get_cart_subscription_length() > 0 && self::get_cart_subscription_length() == self::get_cart_subscription_interval();
|
||||||
|
|
||||||
// Override defaults when subscription is for one billing period
|
// Override defaults when subscription is for one billing period
|
||||||
if ( $is_one_payment ) {
|
if ( $is_one_payment ) {
|
||||||
|
@@ -32,7 +32,7 @@ class WC_Subscriptions_Change_Payment_Gateway {
|
|||||||
add_action( 'woocommerce_loaded', __CLASS__ . '::attach_dependant_hooks' );
|
add_action( 'woocommerce_loaded', __CLASS__ . '::attach_dependant_hooks' );
|
||||||
|
|
||||||
// Keep a record of any messages or errors that should be displayed
|
// Keep a record of any messages or errors that should be displayed
|
||||||
add_action( 'before_woocommerce_pay', __CLASS__ . '::store_pay_shortcode_mesages', 100 );
|
add_action( 'before_woocommerce_pay', __CLASS__ . '::store_pay_shortcode_messages', 100 );
|
||||||
|
|
||||||
// Hijack the default pay shortcode
|
// Hijack the default pay shortcode
|
||||||
add_action( 'after_woocommerce_pay', __CLASS__ . '::maybe_replace_pay_shortcode', 100 );
|
add_action( 'after_woocommerce_pay', __CLASS__ . '::maybe_replace_pay_shortcode', 100 );
|
||||||
@@ -99,13 +99,13 @@ class WC_Subscriptions_Change_Payment_Gateway {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store any messages or errors added by other plugins, particularly important for those occasions when the new payment
|
* Store any messages or errors added by other plugins.
|
||||||
* method caused and error or failure.
|
|
||||||
*
|
*
|
||||||
* @since 1.4
|
* This is particularly important for those occasions when the new payment method caused and error or failure.
|
||||||
|
*
|
||||||
|
* @since 2.3.6
|
||||||
*/
|
*/
|
||||||
public static function store_pay_shortcode_mesages() {
|
public static function store_pay_shortcode_messages() {
|
||||||
|
|
||||||
if ( wc_notice_count( 'notice' ) > 0 ) {
|
if ( wc_notice_count( 'notice' ) > 0 ) {
|
||||||
self::$woocommerce_messages = wc_get_notices( 'success' );
|
self::$woocommerce_messages = wc_get_notices( 'success' );
|
||||||
self::$woocommerce_messages += wc_get_notices( 'notice' );
|
self::$woocommerce_messages += wc_get_notices( 'notice' );
|
||||||
@@ -116,6 +116,18 @@ 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
|
||||||
|
*/
|
||||||
|
public static function store_pay_shortcode_mesages() {
|
||||||
|
wcs_deprecated_function( __METHOD__, '2.3.6', __CLASS__ . '::store_pay_shortcode_messages' );
|
||||||
|
self::store_pay_shortcode_messages();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If requesting a payment method change, replace the woocommerce_pay_shortcode() with a change payment form.
|
* If requesting a payment method change, replace the woocommerce_pay_shortcode() with a change payment form.
|
||||||
*
|
*
|
||||||
@@ -427,7 +439,8 @@ class WC_Subscriptions_Change_Payment_Gateway {
|
|||||||
*/
|
*/
|
||||||
public static function get_available_payment_gateways( $available_gateways ) {
|
public static function get_available_payment_gateways( $available_gateways ) {
|
||||||
|
|
||||||
if ( isset( $_GET['change_payment_method'] ) || wcs_cart_contains_failed_renewal_order_payment() ) {
|
// The customer change payment method flow uses the order pay endpoint and so we only need to check for order pay endpoints along side cart related conditions.
|
||||||
|
if ( isset( $_GET['change_payment_method'] ) || ( ! is_wc_endpoint_url( 'order-pay' ) && wcs_cart_contains_failed_renewal_order_payment() ) ) {
|
||||||
foreach ( $available_gateways as $gateway_id => $gateway ) {
|
foreach ( $available_gateways as $gateway_id => $gateway ) {
|
||||||
if ( true !== $gateway->supports( 'subscription_payment_method_change_customer' ) ) {
|
if ( true !== $gateway->supports( 'subscription_payment_method_change_customer' ) ) {
|
||||||
unset( $available_gateways[ $gateway_id ] );
|
unset( $available_gateways[ $gateway_id ] );
|
||||||
|
@@ -217,8 +217,8 @@ class WC_Subscriptions_Coupon {
|
|||||||
|
|
||||||
// Check if we're applying any recurring discounts to recurring total calculations
|
// Check if we're applying any recurring discounts to recurring total calculations
|
||||||
if ( 'recurring_total' == $calculation_type ) {
|
if ( 'recurring_total' == $calculation_type ) {
|
||||||
$apply_recurring_coupon = ( 'recurring_fee' == $coupon_type ) ? true : false;
|
$apply_recurring_coupon = 'recurring_fee' == $coupon_type;
|
||||||
$apply_recurring_percent_coupon = ( 'recurring_percent' == $coupon_type ) ? true : false;
|
$apply_recurring_percent_coupon = 'recurring_percent' == $coupon_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we're applying any initial discounts
|
// Check if we're applying any initial discounts
|
||||||
@@ -873,8 +873,8 @@ class WC_Subscriptions_Coupon {
|
|||||||
* @return array The filtered payment gateways.
|
* @return array The filtered payment gateways.
|
||||||
*/
|
*/
|
||||||
public static function gateways_subscription_amount_changes( $gateways ) {
|
public static function gateways_subscription_amount_changes( $gateways ) {
|
||||||
// If there are already no gateways, bail early.
|
// If there are already no gateways or we're on the order-pay screen, bail early.
|
||||||
if ( empty( $gateways ) ) {
|
if ( empty( $gateways ) || is_wc_endpoint_url( 'order-pay' ) ) {
|
||||||
return $gateways;
|
return $gateways;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1103,8 +1103,8 @@ class WC_Subscriptions_Coupon {
|
|||||||
|
|
||||||
// Apply recurring fee discounts to recurring total calculations
|
// Apply recurring fee discounts to recurring total calculations
|
||||||
if ( 'recurring_total' == $calculation_type ) {
|
if ( 'recurring_total' == $calculation_type ) {
|
||||||
$apply_recurring_coupon = ( 'recurring_fee' == $coupon_type ) ? true : false;
|
$apply_recurring_coupon = 'recurring_fee' == $coupon_type;
|
||||||
$apply_recurring_percent_coupon = ( 'recurring_percent' == $coupon_type ) ? true : false;
|
$apply_recurring_percent_coupon = 'recurring_percent' == $coupon_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( 'none' == $calculation_type ) {
|
if ( 'none' == $calculation_type ) {
|
||||||
|
@@ -1921,7 +1921,7 @@ class WC_Subscriptions_Manager {
|
|||||||
|
|
||||||
// We've already processed the renewal
|
// We've already processed the renewal
|
||||||
remove_action( 'woocommerce_scheduled_subscription_payment', __CLASS__ . '::prepare_renewal' );
|
remove_action( 'woocommerce_scheduled_subscription_payment', __CLASS__ . '::prepare_renewal' );
|
||||||
remove_action( 'woocommerce_scheduled_subscription_payment', 'WC_Subscriptions_Payment_Gateways::gateway_scheduled_subscription_payment', 10, 1 );
|
remove_action( 'woocommerce_scheduled_subscription_payment', 'WC_Subscriptions_Payment_Gateways::gateway_scheduled_subscription_payment', 10 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1426,7 +1426,7 @@ class WC_Subscriptions_Order {
|
|||||||
public static function get_recurring_discount_total( $order, $product_id = '' ) {
|
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' );
|
_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' );
|
||||||
|
|
||||||
$ex_tax = ( 'excl' === get_option( 'woocommerce_tax_display_cart' ) && wcs_get_objects_property( $order, 'display_totals_ex_tax' ) ) ? true : false;
|
$ex_tax = ( 'excl' === get_option( 'woocommerce_tax_display_cart' ) && wcs_get_objects_property( $order, 'display_totals_ex_tax' ) );
|
||||||
|
|
||||||
$recurring_discount_cart = (double) self::get_recurring_discount_cart( $order );
|
$recurring_discount_cart = (double) self::get_recurring_discount_cart( $order );
|
||||||
$recurring_discount_cart_tax = (double) self::get_recurring_discount_cart_tax( $order );
|
$recurring_discount_cart_tax = (double) self::get_recurring_discount_cart_tax( $order );
|
||||||
|
@@ -149,7 +149,7 @@ class WC_Subscriptions_Product {
|
|||||||
$tax_display_mode = get_option( 'woocommerce_tax_display_shop' );
|
$tax_display_mode = get_option( 'woocommerce_tax_display_shop' );
|
||||||
$child_price = 'incl' == $tax_display_mode ? wcs_get_price_including_tax( $child_product, array( 'price' => $child_product->get_price() ) ) : wcs_get_price_excluding_tax( $child_product, array( 'price' => $child_product->get_price() ) );
|
$child_price = 'incl' == $tax_display_mode ? wcs_get_price_including_tax( $child_product, array( 'price' => $child_product->get_price() ) ) : wcs_get_price_excluding_tax( $child_product, array( 'price' => $child_product->get_price() ) );
|
||||||
$sign_up_fee = 'incl' == $tax_display_mode ? wcs_get_price_including_tax( $child_product, array( 'price' => self::get_sign_up_fee( $child_product ) ) ) : wcs_get_price_excluding_tax( $child_product, array( 'price' => self::get_sign_up_fee( $child_product ) ) );
|
$sign_up_fee = 'incl' == $tax_display_mode ? wcs_get_price_including_tax( $child_product, array( 'price' => self::get_sign_up_fee( $child_product ) ) ) : wcs_get_price_excluding_tax( $child_product, array( 'price' => self::get_sign_up_fee( $child_product ) ) );
|
||||||
$has_trial = ( self::get_trial_length( $child_product ) > 0 ) ? true : false;
|
$has_trial = self::get_trial_length( $child_product ) > 0;
|
||||||
|
|
||||||
// Make sure we have the *real* price (i.e. total initial payment)
|
// Make sure we have the *real* price (i.e. total initial payment)
|
||||||
if ( $has_trial && $sign_up_fee > 0 ) {
|
if ( $has_trial && $sign_up_fee > 0 ) {
|
||||||
|
@@ -115,7 +115,7 @@ class WC_Subscriptions_Renewal_Order {
|
|||||||
if ( $order_completed && ! $subscription->has_status( wcs_get_subscription_ended_statuses() ) && ! $subscription->has_status( 'active' ) ) {
|
if ( $order_completed && ! $subscription->has_status( wcs_get_subscription_ended_statuses() ) && ! $subscription->has_status( 'active' ) ) {
|
||||||
|
|
||||||
// Included here because calling payment_complete sets the retry status to 'cancelled'
|
// Included here because calling payment_complete sets the retry status to 'cancelled'
|
||||||
$is_failed_renewal_order = ( 'failed' === $orders_old_status ) ? true : false;
|
$is_failed_renewal_order = 'failed' === $orders_old_status;
|
||||||
$is_failed_renewal_order = apply_filters( 'woocommerce_subscriptions_is_failed_renewal_order', $is_failed_renewal_order, $order_id, $orders_old_status );
|
$is_failed_renewal_order = apply_filters( 'woocommerce_subscriptions_is_failed_renewal_order', $is_failed_renewal_order, $order_id, $orders_old_status );
|
||||||
|
|
||||||
if ( $order_needed_payment ) {
|
if ( $order_needed_payment ) {
|
||||||
|
@@ -1375,8 +1375,15 @@ class WC_Subscriptions_Switcher {
|
|||||||
// Find the price per day for the new subscription's recurring total based on billing schedule
|
// Find the price per day for the new subscription's recurring total based on billing schedule
|
||||||
$days_in_new_cycle = wcs_get_days_in_cycle( WC_Subscriptions_Product::get_period( $item_data ), WC_Subscriptions_Product::get_interval( $item_data ) );
|
$days_in_new_cycle = wcs_get_days_in_cycle( WC_Subscriptions_Product::get_period( $item_data ), WC_Subscriptions_Product::get_interval( $item_data ) );
|
||||||
|
|
||||||
// Set days in new cycle to days in old if it only differs because of rounding
|
// Whether the days in new cycle match the days in old,ignoring any rounding.
|
||||||
if ( ceil( $days_in_new_cycle ) == $days_in_old_cycle || floor( $days_in_new_cycle ) == $days_in_old_cycle ) {
|
$days_in_new_and_old_cycle_match = ceil( $days_in_new_cycle ) == $days_in_old_cycle || floor( $days_in_new_cycle ) == $days_in_old_cycle;
|
||||||
|
|
||||||
|
// Whether the new item uses the same billing interval & cycle as the old subscription,
|
||||||
|
$matching_billing_cycle = WC_Subscriptions_Product::get_period( $item_data ) == $subscription->get_billing_period() && WC_Subscriptions_Product::get_interval( $item_data ) == $subscription->get_billing_interval();
|
||||||
|
$switch_during_trial = $subscription->get_time( 'trial_end' ) > gmdate( 'U' );
|
||||||
|
|
||||||
|
// Set the days in each cycle to match if they are equal (ignoring any rounding discrepancy) or if the subscription is switched during a trial and has a matching billing cycle.
|
||||||
|
if ( $days_in_new_and_old_cycle_match || ( $matching_billing_cycle && $switch_during_trial ) ) {
|
||||||
$days_in_new_cycle = $days_in_old_cycle;
|
$days_in_new_cycle = $days_in_old_cycle;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1570,7 +1577,7 @@ class WC_Subscriptions_Switcher {
|
|||||||
public static function get_recurring_cart_key( $cart_key, $cart_item ) {
|
public static function get_recurring_cart_key( $cart_key, $cart_item ) {
|
||||||
|
|
||||||
if ( isset( $cart_item['subscription_switch']['first_payment_timestamp'] ) ) {
|
if ( isset( $cart_item['subscription_switch']['first_payment_timestamp'] ) ) {
|
||||||
remove_filter( 'woocommerce_subscriptions_recurring_cart_key', __METHOD__, 10, 2 );
|
remove_filter( 'woocommerce_subscriptions_recurring_cart_key', __METHOD__, 10 );
|
||||||
$cart_key = WC_Subscriptions_Cart::get_recurring_cart_key( $cart_item, $cart_item['subscription_switch']['first_payment_timestamp'] );
|
$cart_key = WC_Subscriptions_Cart::get_recurring_cart_key( $cart_item, $cart_item['subscription_switch']['first_payment_timestamp'] );
|
||||||
add_filter( 'woocommerce_subscriptions_recurring_cart_key', __METHOD__, 10, 2 );
|
add_filter( 'woocommerce_subscriptions_recurring_cart_key', __METHOD__, 10, 2 );
|
||||||
}
|
}
|
||||||
@@ -1719,10 +1726,7 @@ class WC_Subscriptions_Switcher {
|
|||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
protected static function is_item_switched( $item ) {
|
protected static function is_item_switched( $item ) {
|
||||||
|
return isset( $item['switched'] );
|
||||||
$is_item_switched = isset( $item['switched'] ) ? true : false;
|
|
||||||
|
|
||||||
return $is_item_switched;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -472,7 +472,7 @@ class WC_Subscriptions_Synchroniser {
|
|||||||
|
|
||||||
$payment_date = self::get_products_payment_day( $product );
|
$payment_date = self::get_products_payment_day( $product );
|
||||||
|
|
||||||
return ( ( ! is_array( $payment_date ) && $payment_date > 0 ) || ( isset( $payment_date['day'] ) && $payment_date['day'] > 0 ) ) ? true : false;
|
return ( ! is_array( $payment_date ) && $payment_date > 0 ) || ( isset( $payment_date['day'] ) && $payment_date['day'] > 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -959,7 +959,7 @@ class WC_Subscriptions_Synchroniser {
|
|||||||
// Convert timestamp to site's time
|
// Convert timestamp to site's time
|
||||||
$timestamp += get_option( 'gmt_offset' ) * HOUR_IN_SECONDS;
|
$timestamp += get_option( 'gmt_offset' ) * HOUR_IN_SECONDS;
|
||||||
|
|
||||||
return ( gmdate( 'Y-m-d', current_time( 'timestamp' ) ) == gmdate( 'Y-m-d', $timestamp ) ) ? true : false;
|
return gmdate( 'Y-m-d', current_time( 'timestamp' ) ) == gmdate( 'Y-m-d', $timestamp );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1152,7 +1152,7 @@ class WC_Subscriptions_Synchroniser {
|
|||||||
$subscription_id = $subscription_id->get_id();
|
$subscription_id = $subscription_id->get_id();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ( 'true' == get_post_meta( $subscription_id, '_contains_synced_subscription', true ) ) ? true : false;
|
return 'true' == get_post_meta( $subscription_id, '_contains_synced_subscription', true );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1404,7 +1404,7 @@ class WC_Subscriptions_Synchroniser {
|
|||||||
$order_id = wcs_get_objects_property( $order_id, 'id' );
|
$order_id = wcs_get_objects_property( $order_id, 'id' );
|
||||||
}
|
}
|
||||||
|
|
||||||
return ( 'true' == get_post_meta( $order_id, '_order_contains_synced_subscription', true ) ) ? true : false;
|
return 'true' == get_post_meta( $order_id, '_order_contains_synced_subscription', true );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -533,7 +533,7 @@ class WCS_Cart_Renewal {
|
|||||||
if ( $this->cart_contains() && did_action( 'woocommerce_checkout_init' ) > 0 ) {
|
if ( $this->cart_contains() && did_action( 'woocommerce_checkout_init' ) > 0 ) {
|
||||||
|
|
||||||
// Guard against the fake WC_Checkout singleton, see https://github.com/woocommerce/woocommerce-subscriptions/issues/427#issuecomment-260763250
|
// Guard against the fake WC_Checkout singleton, see https://github.com/woocommerce/woocommerce-subscriptions/issues/427#issuecomment-260763250
|
||||||
remove_filter( 'woocommerce_checkout_get_value', array( &$this, 'checkout_get_value' ), 10, 2 );
|
remove_filter( 'woocommerce_checkout_get_value', array( &$this, 'checkout_get_value' ), 10 );
|
||||||
|
|
||||||
if ( is_callable( array( WC()->checkout(), 'get_checkout_fields' ) ) ) { // WC 3.0+
|
if ( is_callable( array( WC()->checkout(), 'get_checkout_fields' ) ) ) { // WC 3.0+
|
||||||
$address_fields = array_merge( WC()->checkout()->get_checkout_fields( 'billing' ), WC()->checkout()->get_checkout_fields( 'shipping' ) );
|
$address_fields = array_merge( WC()->checkout()->get_checkout_fields( 'billing' ), WC()->checkout()->get_checkout_fields( 'shipping' ) );
|
||||||
|
@@ -236,7 +236,7 @@ class WCS_Cart_Resubscribe extends WCS_Cart_Renewal {
|
|||||||
public function get_recurring_cart_key( $cart_key, $cart_item ) {
|
public function get_recurring_cart_key( $cart_key, $cart_item ) {
|
||||||
$subscription = $this->get_order( $cart_item );
|
$subscription = $this->get_order( $cart_item );
|
||||||
if ( false !== $subscription && $subscription->has_status( 'pending-cancel' ) ) {
|
if ( false !== $subscription && $subscription->has_status( 'pending-cancel' ) ) {
|
||||||
remove_filter( 'woocommerce_subscriptions_recurring_cart_key', array( &$this, 'get_recurring_cart_key' ), 10, 2 );
|
remove_filter( 'woocommerce_subscriptions_recurring_cart_key', array( &$this, 'get_recurring_cart_key' ), 10 );
|
||||||
$cart_key = WC_Subscriptions_Cart::get_recurring_cart_key( $cart_item, $subscription->get_time( 'end' ) );
|
$cart_key = WC_Subscriptions_Cart::get_recurring_cart_key( $cart_item, $subscription->get_time( 'end' ) );
|
||||||
add_filter( 'woocommerce_subscriptions_recurring_cart_key', array( &$this, 'get_recurring_cart_key' ), 10, 2 );
|
add_filter( 'woocommerce_subscriptions_recurring_cart_key', array( &$this, 'get_recurring_cart_key' ), 10, 2 );
|
||||||
}
|
}
|
||||||
|
@@ -62,7 +62,6 @@ class WCS_Limiter {
|
|||||||
* @since 2.1
|
* @since 2.1
|
||||||
* @param bool $purchasable Whether the product is purchasable as determined by parent class
|
* @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.
|
* @param mixed $product The product in question to be checked if it is purchasable.
|
||||||
* @param string $product_class Determines the subscription type of the product. Controls switch logic.
|
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
|
@@ -59,9 +59,9 @@ class WCS_Remove_Item {
|
|||||||
|
|
||||||
if ( isset( $_GET['subscription_id'] ) && ( isset( $_GET['remove_item'] ) || isset( $_GET['undo_remove_item'] ) ) && isset( $_GET['_wpnonce'] ) ) {
|
if ( isset( $_GET['subscription_id'] ) && ( isset( $_GET['remove_item'] ) || isset( $_GET['undo_remove_item'] ) ) && isset( $_GET['_wpnonce'] ) ) {
|
||||||
|
|
||||||
$subscription = ( wcs_is_subscription( $_GET['subscription_id'] ) ) ? wcs_get_subscription( $_GET['subscription_id'] ) : false;
|
$subscription = wcs_is_subscription( $_GET['subscription_id'] ) ? wcs_get_subscription( $_GET['subscription_id'] ) : false;
|
||||||
$undo_request = ( isset( $_GET['undo_remove_item'] ) ) ? true : false;
|
$undo_request = isset( $_GET['undo_remove_item'] );
|
||||||
$item_id = ( $undo_request ) ? $_GET['undo_remove_item'] : $_GET['remove_item'];
|
$item_id = $undo_request ? $_GET['undo_remove_item'] : $_GET['remove_item'];
|
||||||
|
|
||||||
if ( false === $subscription ) {
|
if ( false === $subscription ) {
|
||||||
|
|
||||||
|
@@ -86,7 +86,7 @@ class WCS_Retry_Manager {
|
|||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
public static function is_retry_enabled() {
|
public static function is_retry_enabled() {
|
||||||
return apply_filters( 'wcs_is_retry_enabled', ( 'yes' == get_option( self::$setting_id, 'no' ) ) ? true : false );
|
return (bool) apply_filters( 'wcs_is_retry_enabled', 'yes' == get_option( self::$setting_id, 'no' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -272,7 +272,7 @@ class WCS_Retry_Manager {
|
|||||||
$last_retry->update_status( 'processing' );
|
$last_retry->update_status( 'processing' );
|
||||||
|
|
||||||
$expected_order_status = $last_retry->get_rule()->get_status_to_apply( 'order' );
|
$expected_order_status = $last_retry->get_rule()->get_status_to_apply( 'order' );
|
||||||
$valid_order_status = ( '' == $expected_order_status || $last_order->has_status( $expected_order_status ) ) ? true : false;
|
$valid_order_status = ( '' == $expected_order_status || $last_order->has_status( $expected_order_status ) );
|
||||||
|
|
||||||
$expected_subscription_status = $last_retry->get_rule()->get_status_to_apply( 'subscription' );
|
$expected_subscription_status = $last_retry->get_rule()->get_status_to_apply( 'subscription' );
|
||||||
|
|
||||||
|
@@ -31,7 +31,12 @@ class WCS_Staging {
|
|||||||
$renewal_order = wc_get_order( $renewal_order_id );
|
$renewal_order = wc_get_order( $renewal_order_id );
|
||||||
|
|
||||||
if ( $renewal_order ) {
|
if ( $renewal_order ) {
|
||||||
$renewal_order->add_order_note( __( 'Payment processing skipped - renewal order created under staging site lock.', 'woocommerce-subscriptions' ) );
|
$wp_site_url = WC_Subscriptions::get_site_url_from_source( 'current_wp_site' );
|
||||||
|
$wcs_site_url = WC_Subscriptions::get_site_url_from_source( 'subscriptions_install' );
|
||||||
|
|
||||||
|
$message = sprintf( __( 'Payment processing skipped - renewal order created on %sstaging site%s under staging site lock. Live site is at %s', 'woocommerce-subscriptions' ), '<a href="' . $wp_site_url . '">', '</a>', '<a href="' . $wcs_site_url . '">'. $wcs_site_url . '</a>' );
|
||||||
|
|
||||||
|
$renewal_order->add_order_note( $message );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -70,9 +70,16 @@ class WC_Subscriptions_Payment_Gateways {
|
|||||||
*/
|
*/
|
||||||
public static function get_available_payment_gateways( $available_gateways ) {
|
public static function get_available_payment_gateways( $available_gateways ) {
|
||||||
|
|
||||||
if ( WC_Subscriptions_Cart::cart_contains_subscription() || ( isset( $_GET['order_id'] ) && wcs_order_contains_subscription( $_GET['order_id'] ) ) ) {
|
// We don't want to filter the available payment methods while the customer is paying for a standard order via the order-pay screen.
|
||||||
|
if ( is_wc_endpoint_url( 'order-pay' ) ) {
|
||||||
|
return $available_gateways;
|
||||||
|
}
|
||||||
|
|
||||||
$accept_manual_renewals = ( 'no' !== get_option( WC_Subscriptions_Admin::$option_prefix . '_accept_manual_renewals', 'no' ) ) ? true : false;
|
if ( ! WC_Subscriptions_Cart::cart_contains_subscription() && ( ! isset( $_GET['order_id'] ) || ! wcs_order_contains_subscription( $_GET['order_id'] ) ) ) {
|
||||||
|
return $available_gateways;
|
||||||
|
}
|
||||||
|
|
||||||
|
$accept_manual_renewals = ( 'no' !== get_option( WC_Subscriptions_Admin::$option_prefix . '_accept_manual_renewals', 'no' ) );
|
||||||
$subscriptions_in_cart = is_array( WC()->cart->recurring_carts ) ? count( WC()->cart->recurring_carts ) : 0;
|
$subscriptions_in_cart = is_array( WC()->cart->recurring_carts ) ? count( WC()->cart->recurring_carts ) : 0;
|
||||||
|
|
||||||
foreach ( $available_gateways as $gateway_id => $gateway ) {
|
foreach ( $available_gateways as $gateway_id => $gateway ) {
|
||||||
@@ -88,7 +95,6 @@ class WC_Subscriptions_Payment_Gateways {
|
|||||||
unset( $available_gateways[ $gateway_id ] );
|
unset( $available_gateways[ $gateway_id ] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return $available_gateways;
|
return $available_gateways;
|
||||||
}
|
}
|
||||||
|
@@ -463,7 +463,7 @@ class WCS_PayPal {
|
|||||||
*/
|
*/
|
||||||
protected static function get_ipn_handler( $ipn_type = 'standard' ) {
|
protected static function get_ipn_handler( $ipn_type = 'standard' ) {
|
||||||
|
|
||||||
$use_sandbox = ( 'yes' === self::get_option( 'testmode' ) ) ? true : false;
|
$use_sandbox = ( 'yes' === self::get_option( 'testmode' ) );
|
||||||
|
|
||||||
if ( 'reference' === $ipn_type ) {
|
if ( 'reference' === $ipn_type ) {
|
||||||
|
|
||||||
|
@@ -239,7 +239,7 @@ class WCS_PayPal_Standard_IPN_Handler extends WC_Gateway_Paypal_IPN_Handler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$is_first_payment = ( $subscription->get_completed_payment_count() < 1 ) ? true : false;
|
$is_first_payment = $subscription->get_completed_payment_count() < 1;
|
||||||
|
|
||||||
if ( $subscription->has_status( 'switched' ) ) {
|
if ( $subscription->has_status( 'switched' ) ) {
|
||||||
WC_Gateway_Paypal::log( 'IPN ignored, subscription has been switched.' );
|
WC_Gateway_Paypal::log( 'IPN ignored, subscription has been switched.' );
|
||||||
|
@@ -38,9 +38,9 @@ class WCS_PayPal_Standard_Request {
|
|||||||
|
|
||||||
// We need the subscription's total
|
// We need the subscription's total
|
||||||
if ( WC_Subscriptions::is_woocommerce_pre( '3.0' ) ) {
|
if ( WC_Subscriptions::is_woocommerce_pre( '3.0' ) ) {
|
||||||
remove_filter( 'woocommerce_order_amount_total', 'WC_Subscriptions_Change_Payment_Gateway::maybe_zero_total', 11, 2 );
|
remove_filter( 'woocommerce_order_amount_total', 'WC_Subscriptions_Change_Payment_Gateway::maybe_zero_total', 11 );
|
||||||
} else {
|
} else {
|
||||||
remove_filter( 'woocommerce_subscription_get_total', 'WC_Subscriptions_Change_Payment_Gateway::maybe_zero_total', 11, 2 );
|
remove_filter( 'woocommerce_subscription_get_total', 'WC_Subscriptions_Change_Payment_Gateway::maybe_zero_total', 11 );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
@@ -219,7 +219,7 @@ class WCS_PayPal_Standard_Switcher {
|
|||||||
*/
|
*/
|
||||||
public static function get_available_payment_gateways( $available_gateways ) {
|
public static function get_available_payment_gateways( $available_gateways ) {
|
||||||
|
|
||||||
if ( WC_Subscriptions_Switcher::cart_contains_switches() || ( isset( $_GET['order_id'] ) && wcs_order_contains_switch( $_GET['order_id'] ) ) ) {
|
if ( ! is_wc_endpoint_url( 'order-pay' ) && ( WC_Subscriptions_Switcher::cart_contains_switches() || ( isset( $_GET['order_id'] ) && wcs_order_contains_switch( $_GET['order_id'] ) ) ) ) {
|
||||||
foreach ( $available_gateways as $gateway_id => $gateway ) {
|
foreach ( $available_gateways as $gateway_id => $gateway ) {
|
||||||
if ( 'paypal' == $gateway_id && false == WCS_PayPal::are_reference_transactions_enabled() ) {
|
if ( 'paypal' == $gateway_id && false == WCS_PayPal::are_reference_transactions_enabled() ) {
|
||||||
unset( $available_gateways[ $gateway_id ] );
|
unset( $available_gateways[ $gateway_id ] );
|
||||||
|
@@ -44,7 +44,7 @@ class WCS_Retry_Rule {
|
|||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
public function has_email_template( $recipient = 'customer' ) {
|
public function has_email_template( $recipient = 'customer' ) {
|
||||||
return ( isset( $this->rule_data[ 'email_template_' . $recipient ] ) && ! empty( $this->rule_data[ 'email_template_' . $recipient ] ) ) ? true : false;
|
return isset( $this->rule_data[ 'email_template_' . $recipient ] ) && ! empty( $this->rule_data[ 'email_template_' . $recipient ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -74,7 +74,7 @@ class WCS_Retry_Rules {
|
|||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
public function has_rule( $retry_number, $order_id ) {
|
public function has_rule( $retry_number, $order_id ) {
|
||||||
return ( null !== $this->get_rule( $retry_number, $order_id ) ) ? true : false;
|
return null !== $this->get_rule( $retry_number, $order_id );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -59,7 +59,7 @@ class WCS_Upgrade_1_2 {
|
|||||||
$trial_lengths = WC_Subscriptions_Order::get_meta( $order, '_order_subscription_trial_lengths', array() );
|
$trial_lengths = WC_Subscriptions_Order::get_meta( $order, '_order_subscription_trial_lengths', array() );
|
||||||
$trial_length = array_pop( $trial_lengths );
|
$trial_length = array_pop( $trial_lengths );
|
||||||
|
|
||||||
$has_trial = ( ! empty( $trial_length ) && $trial_length > 0 ) ? true : false ;
|
$has_trial = ! empty( $trial_length ) && $trial_length > 0;
|
||||||
|
|
||||||
$sign_up_fee_total = WC_Subscriptions_Order::get_meta( $order, '_sign_up_fee_total', 0 );
|
$sign_up_fee_total = WC_Subscriptions_Order::get_meta( $order, '_sign_up_fee_total', 0 );
|
||||||
|
|
||||||
|
@@ -174,7 +174,7 @@ class WCS_Upgrade_1_4 {
|
|||||||
self::$last_upgraded_user_id = get_option( 'wcs_1_4_last_upgraded_user_id', 0 );
|
self::$last_upgraded_user_id = get_option( 'wcs_1_4_last_upgraded_user_id', 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
return ( $user_id > self::$last_upgraded_user_id ) ? true : false;
|
return $user_id > self::$last_upgraded_user_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WCS_Upgrade_1_4::init();
|
WCS_Upgrade_1_4::init();
|
||||||
|
@@ -34,7 +34,7 @@ function wcs_cart_totals_shipping_html() {
|
|||||||
|
|
||||||
$initial_packages = WC()->shipping->get_packages();
|
$initial_packages = WC()->shipping->get_packages();
|
||||||
|
|
||||||
$show_package_details = count( WC()->cart->recurring_carts ) > 1 ? true : false;
|
$show_package_details = count( WC()->cart->recurring_carts ) > 1;
|
||||||
$show_package_name = true;
|
$show_package_name = true;
|
||||||
|
|
||||||
// Create new subscriptions for each subscription product in the cart (that is not a renewal)
|
// Create new subscriptions for each subscription product in the cart (that is not a renewal)
|
||||||
|
@@ -253,7 +253,7 @@ function wcs_set_objects_property( &$object, $key, $value, $save = 'save', $meta
|
|||||||
|
|
||||||
// Prices include tax is stored as a boolean in props but saved in the database as a string yes/no, so we need to normalise it here to make sure if we have a string (which can be passed to it by things like wcs_copy_order_meta()) that it's converted to a boolean before being set
|
// Prices include tax is stored as a boolean in props but saved in the database as a string yes/no, so we need to normalise it here to make sure if we have a string (which can be passed to it by things like wcs_copy_order_meta()) that it's converted to a boolean before being set
|
||||||
if ( '_prices_include_tax' === $prefixed_key && ! is_bool( $value ) ) {
|
if ( '_prices_include_tax' === $prefixed_key && ! is_bool( $value ) ) {
|
||||||
$value = 'yes' === $value ? true : false;
|
$value = 'yes' === $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
$object->{ "set$prefixed_key" }( $value );
|
$object->{ "set$prefixed_key" }( $value );
|
||||||
@@ -458,7 +458,7 @@ function wcs_get_coupon_property( $coupon, $property ) {
|
|||||||
|
|
||||||
switch ( true ) {
|
switch ( true ) {
|
||||||
case 'exists' == $property:
|
case 'exists' == $property:
|
||||||
$value = ( $coupon->get_id() > 0 ) ? true : false;
|
$value = $coupon->get_id() > 0;
|
||||||
break;
|
break;
|
||||||
case isset( $property_to_getter_map[ $property ] ) && is_callable( array( $coupon, $property_to_getter_map[ $property ] ) ):
|
case isset( $property_to_getter_map[ $property ] ) && is_callable( array( $coupon, $property_to_getter_map[ $property ] ) ):
|
||||||
$function = $property_to_getter_map[ $property ];
|
$function = $property_to_getter_map[ $property ];
|
||||||
@@ -503,7 +503,7 @@ function wcs_set_coupon_property( &$coupon, $property, $value ) {
|
|||||||
case 'individual_use' == $property:
|
case 'individual_use' == $property:
|
||||||
// set_individual_use expects a boolean, the individual_use property use to be either 'yes' or 'no' so we need to accept both types
|
// set_individual_use expects a boolean, the individual_use property use to be either 'yes' or 'no' so we need to accept both types
|
||||||
if ( ! is_bool( $value ) ) {
|
if ( ! is_bool( $value ) ) {
|
||||||
$value = ( 'yes' === $value ) ? true : false;
|
$value = 'yes' === $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
$coupon->set_individual_use( $value );
|
$coupon->set_individual_use( $value );
|
||||||
|
@@ -52,7 +52,7 @@ function wcs_get_subscriptions_for_order( $order, $args = array() ) {
|
|||||||
$args['order_type'] = array( $args['order_type'] );
|
$args['order_type'] = array( $args['order_type'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
$get_all = ( in_array( 'any', $args['order_type'] ) ) ? true : false;
|
$get_all = in_array( 'any', $args['order_type'] );
|
||||||
|
|
||||||
if ( $get_all || in_array( 'parent', $args['order_type'] ) ) {
|
if ( $get_all || in_array( 'parent', $args['order_type'] ) ) {
|
||||||
|
|
||||||
@@ -186,7 +186,7 @@ function wcs_copy_order_meta( $from_order, $to_order, $type = 'subscription' ) {
|
|||||||
wcs_get_objects_property( $from_order, 'id' )
|
wcs_get_objects_property( $from_order, 'id' )
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( 'renewal_order' == $type ) {
|
if ( in_array( $type, array( 'renewal_order', 'parent' ) ) ) {
|
||||||
$meta_query .= " AND `meta_key` NOT LIKE '_download_permissions_granted' ";
|
$meta_query .= " AND `meta_key` NOT LIKE '_download_permissions_granted' ";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -435,7 +435,7 @@ function wcs_order_contains_subscription( $order, $order_type = array( 'parent',
|
|||||||
}
|
}
|
||||||
|
|
||||||
$contains_subscription = false;
|
$contains_subscription = false;
|
||||||
$get_all = ( in_array( 'any', $order_type ) ) ? true : false;
|
$get_all = in_array( 'any', $order_type );
|
||||||
|
|
||||||
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 ) || $get_all ) && count( wcs_get_subscriptions_for_order( wcs_get_objects_property( $order, 'id' ), array( 'order_type' => 'parent' ) ) ) > 0 ) {
|
||||||
$contains_subscription = true;
|
$contains_subscription = true;
|
||||||
@@ -471,7 +471,7 @@ function wcs_get_subscription_orders( $return_fields = 'ids', $order_type = 'par
|
|||||||
$order_type = array( $order_type );
|
$order_type = array( $order_type );
|
||||||
}
|
}
|
||||||
|
|
||||||
$any_order_type = in_array( 'any', $order_type ) ? true : false;
|
$any_order_type = in_array( 'any', $order_type );
|
||||||
$return_fields = ( 'ids' == $return_fields ) ? $return_fields : 'all';
|
$return_fields = ( 'ids' == $return_fields ) ? $return_fields : 'all';
|
||||||
|
|
||||||
$orders = array();
|
$orders = array();
|
||||||
|
@@ -181,12 +181,12 @@ function wcs_calculate_min_max_variations( $variations_data ) {
|
|||||||
$variations_data_trial_periods_list = array_unique( array_merge( $variations_data_trial_periods_list, array( $variation_data['subscription']['trial_period'] ) ) );
|
$variations_data_trial_periods_list = array_unique( array_merge( $variations_data_trial_periods_list, array( $variation_data['subscription']['trial_period'] ) ) );
|
||||||
$variations_data_lengths_list = array_unique( array_merge( $variations_data_lengths_list, array( $variation_data['subscription']['length'] ) ) );
|
$variations_data_lengths_list = array_unique( array_merge( $variations_data_lengths_list, array( $variation_data['subscription']['length'] ) ) );
|
||||||
|
|
||||||
$has_free_trial = ( '' !== $variation_data['subscription']['trial_length'] && $variation_data['subscription']['trial_length'] > 0 ) ? true : false;
|
$has_free_trial = '' !== $variation_data['subscription']['trial_length'] && $variation_data['subscription']['trial_length'] > 0;
|
||||||
|
|
||||||
// Determine some recurring price flags
|
// Determine some recurring price flags
|
||||||
$is_lowest_price = ( $variation_data['price'] < $lowest_price || '' === $lowest_price ) ? true : false;
|
$is_lowest_price = $variation_data['price'] < $lowest_price || '' === $lowest_price;
|
||||||
$is_longest_period = ( WC_Subscriptions::get_longest_period( $variable_subscription_period, $variation_data['subscription']['period'] ) === $variation_data['subscription']['period'] ) ? true : false;
|
$is_longest_period = WC_Subscriptions::get_longest_period( $variable_subscription_period, $variation_data['subscription']['period'] ) === $variation_data['subscription']['period'];
|
||||||
$is_longest_interval = ( $variation_data['subscription']['interval'] >= $variable_subscription_period_interval || '' === $variable_subscription_period_interval ) ? true : false;
|
$is_longest_interval = $variation_data['subscription']['interval'] >= $variable_subscription_period_interval || '' === $variable_subscription_period_interval;
|
||||||
|
|
||||||
// Find the amount the subscriber will have to pay up-front
|
// Find the amount the subscriber will have to pay up-front
|
||||||
if ( $has_free_trial ) {
|
if ( $has_free_trial ) {
|
||||||
@@ -233,7 +233,7 @@ function wcs_calculate_min_max_variations( $variations_data ) {
|
|||||||
// Otherwise the cheapest variation is the one with the longer trial
|
// Otherwise the cheapest variation is the one with the longer trial
|
||||||
} elseif ( $variable_subscription_trial_period === $variation_data['subscription']['trial_period'] ) {
|
} elseif ( $variable_subscription_trial_period === $variation_data['subscription']['trial_period'] ) {
|
||||||
|
|
||||||
$is_min = ( $variation_data['subscription']['trial_length'] > $variable_subscription_trial_length ) ? true : false;
|
$is_min = $variation_data['subscription']['trial_length'] > $variable_subscription_trial_length;
|
||||||
|
|
||||||
// Otherwise just a longer trial period (that isn't equal to the longest period)
|
// Otherwise just a longer trial period (that isn't equal to the longest period)
|
||||||
} elseif ( WC_Subscriptions::get_longest_period( $longest_trial_period, $variation_data['subscription']['trial_period'] ) === $variation_data['subscription']['trial_period'] ) {
|
} elseif ( WC_Subscriptions::get_longest_period( $longest_trial_period, $variation_data['subscription']['trial_period'] ) === $variation_data['subscription']['trial_period'] ) {
|
||||||
@@ -257,7 +257,7 @@ function wcs_calculate_min_max_variations( $variations_data ) {
|
|||||||
// Need to check trial length
|
// Need to check trial length
|
||||||
} elseif ( $shortest_trial_period === $variation_data['subscription']['trial_period'] ) {
|
} elseif ( $shortest_trial_period === $variation_data['subscription']['trial_period'] ) {
|
||||||
|
|
||||||
$is_max = ( $variation_data['subscription']['trial_length'] < $shortest_trial_length ) ? true : false;
|
$is_max = $variation_data['subscription']['trial_length'] < $shortest_trial_length;
|
||||||
|
|
||||||
// Need to find shortest period
|
// Need to find shortest period
|
||||||
} elseif ( WC_Subscriptions::get_shortest_period( $shortest_trial_period, $variation_data['subscription']['trial_period'] ) === $variation_data['subscription']['trial_period'] ) {
|
} elseif ( WC_Subscriptions::get_shortest_period( $shortest_trial_period, $variation_data['subscription']['trial_period'] ) === $variation_data['subscription']['trial_period'] ) {
|
||||||
@@ -276,13 +276,13 @@ function wcs_calculate_min_max_variations( $variations_data ) {
|
|||||||
$longest_initial_period = WC_Subscriptions::get_longest_period( $longest_initial_period, $initial_period );
|
$longest_initial_period = WC_Subscriptions::get_longest_period( $longest_initial_period, $initial_period );
|
||||||
$shortest_initial_period = WC_Subscriptions::get_shortest_period( $shortest_initial_period, $initial_period );
|
$shortest_initial_period = WC_Subscriptions::get_shortest_period( $shortest_initial_period, $initial_period );
|
||||||
|
|
||||||
$is_lowest_initial_amount = ( $initial_amount < $lowest_initial_amount || '' === $lowest_initial_amount ) ? true : false;
|
$is_lowest_initial_amount = $initial_amount < $lowest_initial_amount || '' === $lowest_initial_amount;
|
||||||
$is_longest_initial_period = ( $initial_period === $longest_initial_period ) ? true : false;
|
$is_longest_initial_period = $initial_period === $longest_initial_period;
|
||||||
$is_longest_initial_interval = ( $initial_interval >= $longest_initial_interval || '' === $longest_initial_interval ) ? true : false;
|
$is_longest_initial_interval = $initial_interval >= $longest_initial_interval || '' === $longest_initial_interval;
|
||||||
|
|
||||||
$is_highest_initial = ( $initial_amount > $highest_initial_amount || '' === $highest_initial_amount ) ? true : false;
|
$is_highest_initial = $initial_amount > $highest_initial_amount || '' === $highest_initial_amount;
|
||||||
$is_shortest_period = ( $initial_period === $shortest_initial_period || '' === $shortest_initial_period ) ? true : false;
|
$is_shortest_period = $initial_period === $shortest_initial_period || '' === $shortest_initial_period;
|
||||||
$is_shortest_interval = ( $initial_interval < $shortest_initial_interval || '' === $shortest_initial_interval ) ? true : false;
|
$is_shortest_interval = $initial_interval < $shortest_initial_interval || '' === $shortest_initial_interval;
|
||||||
|
|
||||||
// If we're not dealing with the lowest initial access amount, then ignore this variation
|
// If we're not dealing with the lowest initial access amount, then ignore this variation
|
||||||
if ( ! $is_lowest_initial_amount && $initial_amount !== $lowest_initial_amount ) {
|
if ( ! $is_lowest_initial_amount && $initial_amount !== $lowest_initial_amount ) {
|
||||||
|
@@ -608,7 +608,7 @@ function wcs_is_datetime_mysql_format( $time ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( function_exists( 'strptime' ) ) {
|
if ( function_exists( 'strptime' ) ) {
|
||||||
$valid_time = $match = ( false !== strptime( $time, '%Y-%m-%d %H:%M:%S' ) ) ? true : false;
|
$valid_time = $match = ( false !== strptime( $time, '%Y-%m-%d %H:%M:%S' ) );
|
||||||
} else {
|
} else {
|
||||||
// parses for the pattern of YYYY-MM-DD HH:MM:SS, but won't check whether it's a valid timedate
|
// 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 );
|
$match = preg_match( '/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/', $time );
|
||||||
@@ -618,7 +618,7 @@ function wcs_is_datetime_mysql_format( $time ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// magic number -2209078800 is strtotime( '1900-01-00 00:00:00' ). Needed to achieve parity with strptime
|
// 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 ) ? true : false;
|
return $match && false !== $valid_time && -2209078800 <= $valid_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -319,7 +319,7 @@ function wcs_get_all_user_actions_for_subscription( $subscription, $user_id ) {
|
|||||||
|
|
||||||
if ( user_can( $user_id, 'edit_shop_subscription_status', $subscription->get_id() ) ) {
|
if ( user_can( $user_id, 'edit_shop_subscription_status', $subscription->get_id() ) ) {
|
||||||
|
|
||||||
$admin_with_suspension_disallowed = ( current_user_can( 'manage_woocommerce' ) && '0' === get_option( WC_Subscriptions_Admin::$option_prefix . '_max_customer_suspensions', '0' ) ) ? true : false;
|
$admin_with_suspension_disallowed = current_user_can( 'manage_woocommerce' ) && '0' === get_option( WC_Subscriptions_Admin::$option_prefix . '_max_customer_suspensions', '0' );
|
||||||
$current_status = $subscription->get_status();
|
$current_status = $subscription->get_status();
|
||||||
|
|
||||||
if ( $subscription->can_be_updated_to( 'on-hold' ) && wcs_can_user_put_subscription_on_hold( $subscription, $user_id ) && ! $admin_with_suspension_disallowed ) {
|
if ( $subscription->can_be_updated_to( 'on-hold' ) && wcs_can_user_put_subscription_on_hold( $subscription, $user_id ) && ! $admin_with_suspension_disallowed ) {
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -31,14 +31,14 @@ do_action( 'woocommerce_before_add_to_cart_form' ); ?>
|
|||||||
<p class="limited-subscription-notice notice"><?php esc_html_e( 'You have an active subscription to this product already.', 'woocommerce-subscriptions' ); ?></p>
|
<p class="limited-subscription-notice notice"><?php esc_html_e( 'You have an active subscription to this product already.', 'woocommerce-subscriptions' ); ?></p>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php else : ?>
|
<?php else : ?>
|
||||||
<?php if ( ! empty( wp_list_filter( $available_variations, array( 'is_purchasable' => false ) ) ) ) : ?>
|
<?php if ( wp_list_filter( $available_variations, array( 'is_purchasable' => false ) ) ) : ?>
|
||||||
<p class="limited-subscription-notice notice"><?php esc_html_e( 'You have added a variation of this product to the cart already.', 'woocommerce-subscriptions' ); ?></p>
|
<p class="limited-subscription-notice notice"><?php esc_html_e( 'You have added a variation of this product to the cart already.', 'woocommerce-subscriptions' ); ?></p>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<table class="variations" cellspacing="0">
|
<table class="variations" cellspacing="0">
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php foreach ( $attributes as $attribute_name => $options ) : ?>
|
<?php foreach ( $attributes as $attribute_name => $options ) : ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="label"><label for="<?php echo esc_attr( sanitize_title( $attribute_name ) ); ?>"><?php echo esc_html( wc_attribute_label( $attribute_name ) ); ?></label></td>
|
<td class="label"><label for="<?php echo esc_attr( sanitize_title( $attribute_name ) ); ?>"><?php echo wc_attribute_label( $attribute_name ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></label></td>
|
||||||
<td class="value">
|
<td class="value">
|
||||||
<?php
|
<?php
|
||||||
$selected = isset( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) ? wc_clean( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) : $product->get_variation_default_attribute( $attribute_name );
|
$selected = isset( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) ? wc_clean( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) : $product->get_variation_default_attribute( $attribute_name );
|
||||||
|
@@ -66,7 +66,7 @@ function wcs_do_subscriptions_exist() {
|
|||||||
// query is the fastest, every other built in method uses this. Plus, the return value is the number of rows found
|
// 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 );
|
$num_rows_found = $wpdb->query( $sql );
|
||||||
|
|
||||||
return ( 0 !== $num_rows_found ) ? true: false;
|
return 0 !== $num_rows_found;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -674,7 +674,7 @@ function wcs_get_subscription_ended_statuses() {
|
|||||||
function wcs_is_view_subscription_page() {
|
function wcs_is_view_subscription_page() {
|
||||||
global $wp;
|
global $wp;
|
||||||
|
|
||||||
return ( is_page( wc_get_page_id( 'myaccount' ) ) && isset( $wp->query_vars['view-subscription'] ) ) ? true : false;
|
return is_page( wc_get_page_id( 'myaccount' ) ) && isset( $wp->query_vars['view-subscription'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
* Description: Sell products and services with recurring payments in your WooCommerce Store.
|
* Description: Sell products and services with recurring payments in your WooCommerce Store.
|
||||||
* Author: Prospress Inc.
|
* Author: Prospress Inc.
|
||||||
* Author URI: http://prospress.com/
|
* Author URI: http://prospress.com/
|
||||||
* Version: 2.3.5
|
* Version: 2.3.7
|
||||||
*
|
*
|
||||||
* WC requires at least: 2.6
|
* WC requires at least: 2.6
|
||||||
* WC tested up to: 3.4
|
* WC tested up to: 3.4
|
||||||
@@ -48,7 +48,7 @@ woothemes_queue_update( plugin_basename( __FILE__ ), '6115e6d7e297b623a169fdcf57
|
|||||||
*
|
*
|
||||||
* @since 1.0
|
* @since 1.0
|
||||||
*/
|
*/
|
||||||
if ( ! is_woocommerce_active() || version_compare( get_option( 'woocommerce_db_version' ), '2.6', '<' ) ) {
|
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' );
|
add_action( 'admin_notices', 'WC_Subscriptions::woocommerce_inactive_notice' );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -170,7 +170,9 @@ class WC_Subscriptions {
|
|||||||
|
|
||||||
public static $plugin_file = __FILE__;
|
public static $plugin_file = __FILE__;
|
||||||
|
|
||||||
public static $version = '2.3.5';
|
public static $version = '2.3.7';
|
||||||
|
|
||||||
|
public static $wc_minimum_supported_version = '2.6';
|
||||||
|
|
||||||
private static $total_subscription_count = null;
|
private static $total_subscription_count = null;
|
||||||
|
|
||||||
@@ -502,8 +504,8 @@ class WC_Subscriptions {
|
|||||||
$is_subscription = WC_Subscriptions_Product::is_subscription( $product_id );
|
$is_subscription = WC_Subscriptions_Product::is_subscription( $product_id );
|
||||||
$cart_contains_subscription = WC_Subscriptions_Cart::cart_contains_subscription();
|
$cart_contains_subscription = WC_Subscriptions_Cart::cart_contains_subscription();
|
||||||
$multiple_subscriptions_possible = WC_Subscriptions_Payment_Gateways::one_gateway_supports( 'multiple_subscriptions' );
|
$multiple_subscriptions_possible = WC_Subscriptions_Payment_Gateways::one_gateway_supports( 'multiple_subscriptions' );
|
||||||
$manual_renewals_enabled = ( 'yes' == get_option( WC_Subscriptions_Admin::$option_prefix . '_accept_manual_renewals', 'no' ) ) ? true : false;
|
$manual_renewals_enabled = ( 'yes' == get_option( WC_Subscriptions_Admin::$option_prefix . '_accept_manual_renewals', 'no' ) );
|
||||||
$canonical_product_id = ( ! empty( $variation_id ) ) ? $variation_id : $product_id;
|
$canonical_product_id = ! empty( $variation_id ) ? $variation_id : $product_id;
|
||||||
|
|
||||||
if ( $is_subscription && 'yes' != get_option( WC_Subscriptions_Admin::$option_prefix . '_multiple_purchase', 'no' ) ) {
|
if ( $is_subscription && 'yes' != get_option( WC_Subscriptions_Admin::$option_prefix . '_multiple_purchase', 'no' ) ) {
|
||||||
|
|
||||||
@@ -710,25 +712,26 @@ class WC_Subscriptions {
|
|||||||
* @since 1.2
|
* @since 1.2
|
||||||
*/
|
*/
|
||||||
public static function woocommerce_inactive_notice() {
|
public static function woocommerce_inactive_notice() {
|
||||||
if ( current_user_can( 'activate_plugins' ) ) :
|
if ( current_user_can( 'activate_plugins' ) ) {
|
||||||
if ( ! is_woocommerce_active() ) : ?>
|
$admin_notice_content = '';
|
||||||
<div id="message" class="error">
|
|
||||||
<p><?php
|
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' );
|
$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 <strong> 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
|
// translators: 1$-2$: opening and closing <strong> 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
|
||||||
printf( 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' ), '<strong>', '</strong>', '<a href="http://wordpress.org/extend/plugins/woocommerce/">', '</a>', '<a href="' . esc_url( $install_url ) . '">', '</a>' ); ?>
|
$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' ), '<strong>', '</strong>', '<a href="http://wordpress.org/extend/plugins/woocommerce/">', '</a>', '<a href="' . esc_url( $install_url ) . '">', '</a>' );
|
||||||
</p>
|
} elseif ( version_compare( get_option( 'woocommerce_db_version' ), self::$wc_minimum_supported_version, '<' ) ) {
|
||||||
</div>
|
// translators: 1$-2$: opening and closing <strong> tags, 3$: minimum supported WooCommerce version, 4$-5$: opening and closing link tags, leads to plugin admin
|
||||||
<?php elseif ( version_compare( get_option( 'woocommerce_db_version' ), '2.4', '<' ) ) : ?>
|
$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' ), '<strong>', '</strong>', self::$wc_minimum_supported_version,'<a href="' . esc_url( admin_url( 'plugins.php' ) ) . '">', '</a>' );
|
||||||
<div id="message" class="error">
|
}
|
||||||
<p><?php
|
|
||||||
// translators: 1$-2$: opening and closing <strong> tags, 3$-4$: opening and closing link tags, leads to plugin admin
|
if ( $admin_notice_content ) {
|
||||||
printf( esc_html__( '%1$sWooCommerce Subscriptions is inactive.%2$s This version of Subscriptions requires WooCommerce 2.4 or newer. Please %3$supdate WooCommerce to version 2.4 or newer »%4$s', 'woocommerce-subscriptions' ), '<strong>', '</strong>', '<a href="' . esc_url( admin_url( 'plugins.php' ) ) . '">', '</a>' ); ?>
|
require_once( 'includes/admin/class-wcs-admin-notice.php' );
|
||||||
</p>
|
$notice = new WCS_Admin_Notice( 'error' );
|
||||||
</div>
|
$notice->set_simple_content( $admin_notice_content );
|
||||||
<?php endif; ?>
|
$notice->display();
|
||||||
<?php endif;
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1099,6 +1102,26 @@ class WC_Subscriptions {
|
|||||||
return $shortest_period;
|
return $shortest_period;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns WordPress/Subscriptions record of the site URL for this site
|
||||||
|
*
|
||||||
|
* @param string $source Takes values 'current_wp_site' or 'subscriptions_install'
|
||||||
|
* @since 2.3.6
|
||||||
|
*/
|
||||||
|
public static function get_site_url_from_source( $source = 'current_wp_site' ) {
|
||||||
|
// Let the default source be WP
|
||||||
|
if ( 'subscriptions_install' === $source ) {
|
||||||
|
$site_url = self::get_site_url();
|
||||||
|
} elseif ( defined( 'WP_SITEURL' ) ) {
|
||||||
|
$site_url = WP_SITEURL;
|
||||||
|
} else {
|
||||||
|
$site_url = get_site_url();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $site_url;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns Subscriptions record of the site URL for this site
|
* Returns Subscriptions record of the site URL for this site
|
||||||
*
|
*
|
||||||
@@ -1133,14 +1156,8 @@ class WC_Subscriptions {
|
|||||||
*/
|
*/
|
||||||
public static function is_duplicate_site() {
|
public static function is_duplicate_site() {
|
||||||
|
|
||||||
if ( defined( 'WP_SITEURL' ) ) {
|
$wp_site_url_parts = wp_parse_url( self::get_site_url_from_source( 'current_wp_site' ) );
|
||||||
$site_url = WP_SITEURL;
|
$wcs_site_url_parts = wp_parse_url( self::get_site_url_from_source( 'subscriptions_install' ) );
|
||||||
} else {
|
|
||||||
$site_url = get_site_url();
|
|
||||||
}
|
|
||||||
|
|
||||||
$wp_site_url_parts = wp_parse_url( $site_url );
|
|
||||||
$wcs_site_url_parts = wp_parse_url( self::get_site_url() );
|
|
||||||
|
|
||||||
if ( ! isset( $wp_site_url_parts['path'] ) && ! isset( $wcs_site_url_parts['path'] ) ) {
|
if ( ! isset( $wp_site_url_parts['path'] ) && ! isset( $wcs_site_url_parts['path'] ) ) {
|
||||||
$paths_match = true;
|
$paths_match = true;
|
||||||
@@ -1197,11 +1214,7 @@ class WC_Subscriptions {
|
|||||||
*/
|
*/
|
||||||
public static function get_current_sites_duplicate_lock() {
|
public static function get_current_sites_duplicate_lock() {
|
||||||
|
|
||||||
if ( defined( 'WP_SITEURL' ) ) {
|
$site_url = self::get_site_url_from_source( 'current_wp_site' );
|
||||||
$site_url = WP_SITEURL;
|
|
||||||
} else {
|
|
||||||
$site_url = get_site_url();
|
|
||||||
}
|
|
||||||
|
|
||||||
return substr_replace( $site_url, '_[wc_subscriptions_siteurl]_', strlen( $site_url ) / 2, 0 );
|
return substr_replace( $site_url, '_[wc_subscriptions_siteurl]_', strlen( $site_url ) / 2, 0 );
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user