From ce24e61a4cb8c8adb532c3da638e29f94d23e87e Mon Sep 17 00:00:00 2001 From: Prospress Inc Date: Fri, 28 Sep 2018 16:11:56 +0200 Subject: [PATCH] 2.3.7 --- assets/js/admin/admin.js | 23 + changelog.txt | 20 + .../admin/class-wc-subscriptions-admin.php | 70 ++- includes/admin/class-wcs-admin-meta-boxes.php | 2 +- includes/admin/class-wcs-admin-notice.php | 16 +- includes/admin/class-wcs-admin-post-types.php | 10 +- .../class-wcs-meta-box-subscription-data.php | 15 +- ...class-wc-rest-subscriptions-controller.php | 16 + ...lass-wc-product-subscription-variation.php | 4 +- includes/class-wc-subscription.php | 6 +- includes/class-wc-subscriptions-cart.php | 12 +- ...c-subscriptions-change-payment-gateway.php | 29 +- includes/class-wc-subscriptions-coupon.php | 12 +- includes/class-wc-subscriptions-manager.php | 2 +- includes/class-wc-subscriptions-order.php | 2 +- includes/class-wc-subscriptions-product.php | 2 +- .../class-wc-subscriptions-renewal-order.php | 2 +- includes/class-wc-subscriptions-switcher.php | 18 +- .../class-wc-subscriptions-synchroniser.php | 8 +- includes/class-wcs-cart-renewal.php | 2 +- includes/class-wcs-cart-resubscribe.php | 2 +- includes/class-wcs-limiter.php | 1 - includes/class-wcs-remove-item.php | 6 +- includes/class-wcs-retry-manager.php | 4 +- includes/class-wcs-staging.php | 7 +- ...lass-wc-subscriptions-payment-gateways.php | 30 +- includes/gateways/paypal/class-wcs-paypal.php | 2 +- .../class-wcs-paypal-standard-ipn-handler.php | 2 +- .../class-wcs-paypal-standard-request.php | 4 +- .../class-wcs-paypal-standard-switcher.php | 2 +- .../payment-retry/class-wcs-retry-rule.php | 2 +- .../payment-retry/class-wcs-retry-rules.php | 2 +- includes/upgrades/class-wcs-upgrade-1-2.php | 2 +- includes/upgrades/class-wcs-upgrade-1-4.php | 2 +- includes/wcs-cart-functions.php | 2 +- includes/wcs-compatibility-functions.php | 6 +- includes/wcs-order-functions.php | 8 +- includes/wcs-product-functions.php | 24 +- includes/wcs-time-functions.php | 4 +- includes/wcs-user-functions.php | 2 +- languages/woocommerce-subscriptions.pot | 405 +++++++++--------- .../add-to-cart/variable-subscription.php | 4 +- wcs-functions.php | 4 +- woocommerce-subscriptions.php | 85 ++-- 44 files changed, 526 insertions(+), 357 deletions(-) diff --git a/assets/js/admin/admin.js b/assets/js/admin/admin.js index 532de7b..7c0b49b 100755 --- a/assets/js/admin/admin.js +++ b/assets/js/admin/admin.js @@ -743,4 +743,27 @@ jQuery(document).ready(function($){ }; 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(); + }); diff --git a/changelog.txt b/changelog.txt index ada15b8..e7807c5 100755 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,25 @@ *** 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 * 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 diff --git a/includes/admin/class-wc-subscriptions-admin.php b/includes/admin/class-wc-subscriptions-admin.php index c939c37..9dfc987 100755 --- a/includes/admin/class-wc-subscriptions-admin.php +++ b/includes/admin/class-wc-subscriptions-admin.php @@ -713,8 +713,8 @@ class WC_Subscriptions_Admin { // Get admin screen id $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_activation_screen = ( get_transient( WC_Subscriptions::$activation_transient ) == true ) ? 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 = (bool) get_transient( WC_Subscriptions::$activation_transient ); 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' ), 'bulkDeleteOptionLabel' => __( 'Delete all variations without a subscription', 'woocommerce-subscriptions' ), '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 ) { $script_params = array( @@ -965,7 +967,31 @@ class WC_Subscriptions_Admin { 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 ); } /** @@ -1036,25 +1062,27 @@ class WC_Subscriptions_Admin { ), array( - 'name' => __( 'Add to Cart Button Text', 'woocommerce-subscriptions' ), - 'desc' => __( 'A product displays a button with the text "Add to Cart". By default, a subscription changes this to "Sign Up Now". You can customise the button text for subscriptions here.', 'woocommerce-subscriptions' ), - 'tip' => '', - 'id' => self::$option_prefix . '_add_to_cart_button_text', - 'css' => 'min-width:150px;', - 'default' => __( 'Sign Up Now', 'woocommerce-subscriptions' ), - 'type' => 'text', - 'desc_tip' => true, + 'name' => __( 'Add to Cart Button Text', 'woocommerce-subscriptions' ), + 'desc' => __( 'A product displays a button with the text "Add to Cart". By default, a subscription changes this to "Sign Up Now". You can customise the button text for subscriptions here.', 'woocommerce-subscriptions' ), + 'tip' => '', + 'id' => self::$option_prefix . '_add_to_cart_button_text', + 'css' => 'min-width:150px;', + 'default' => __( 'Sign Up Now', 'woocommerce-subscriptions' ), + 'type' => 'text', + 'desc_tip' => true, + 'placeholder' => __( 'Sign Up Now', 'woocommerce-subscriptions' ), ), array( - 'name' => __( 'Place Order Button Text', 'woocommerce-subscriptions' ), - 'desc' => __( 'Use this field to customise the text displayed on the checkout button when an order contains a subscription. Normally the checkout submission button displays "Place Order". When the cart contains a subscription, this is changed to "Sign Up Now".', 'woocommerce-subscriptions' ), - 'tip' => '', - 'id' => self::$option_prefix . '_order_button_text', - 'css' => 'min-width:150px;', - 'default' => __( 'Sign Up Now', 'woocommerce-subscriptions' ), - 'type' => 'text', - 'desc_tip' => true, + 'name' => __( 'Place Order Button Text', 'woocommerce-subscriptions' ), + 'desc' => __( 'Use this field to customise the text displayed on the checkout button when an order contains a subscription. Normally the checkout submission button displays "Place Order". When the cart contains a subscription, this is changed to "Sign Up Now".', 'woocommerce-subscriptions' ), + 'tip' => '', + 'id' => self::$option_prefix . '_order_button_text', + 'css' => 'min-width:150px;', + 'default' => __( 'Sign Up Now', 'woocommerce-subscriptions' ), + 'type' => 'text', + 'desc_tip' => true, + 'placeholder' => __( 'Sign Up Now', 'woocommerce-subscriptions' ), ), array( 'type' => 'sectionend', 'id' => self::$option_prefix . '_button_text' ), @@ -1502,7 +1530,7 @@ class WC_Subscriptions_Admin { $screen = get_current_screen(); 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(); 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 ); } } diff --git a/includes/admin/class-wcs-admin-meta-boxes.php b/includes/admin/class-wcs-admin-meta-boxes.php index 2067936..7a162df 100755 --- a/includes/admin/class-wcs-admin-meta-boxes.php +++ b/includes/admin/class-wcs-admin-meta-boxes.php @@ -81,7 +81,7 @@ class WCS_Admin_Meta_Boxes { public function remove_meta_box_save( $post_id, $post ) { 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 ); } } diff --git a/includes/admin/class-wcs-admin-notice.php b/includes/admin/class-wcs-admin-notice.php index 324aec3..80d468f 100755 --- a/includes/admin/class-wcs-admin-notice.php +++ b/includes/admin/class-wcs-admin-notice.php @@ -85,18 +85,20 @@ class WCS_Admin_Notice { * @since 2.3.0 */ public function display() { - if ( 'admin_notices' !== current_filter() ) { add_action( 'admin_notices', array( $this, __FUNCTION__ ) ); return; } - wc_get_template( - 'html-admin-notice.php', - array( 'notice' => $this ), - '', - plugin_dir_path( WC_Subscriptions::$plugin_file ) . 'templates/admin/' - ); + $template_name = 'html-admin-notice.php'; + $template_path = plugin_dir_path( WC_Subscriptions::$plugin_file ) . 'templates/admin/'; + + if ( function_exists( 'wc_get_template' ) ) { + wc_get_template( $template_name, array( 'notice' => $this ), '', $template_path ); + } else { + $notice = $this; + include( $template_path . $template_name ); + } } /** diff --git a/includes/admin/class-wcs-admin-post-types.php b/includes/admin/class-wcs-admin-post-types.php index 712dc84..6be191b 100755 --- a/includes/admin/class-wcs-admin-post-types.php +++ b/includes/admin/class-wcs-admin-post-types.php @@ -745,8 +745,8 @@ class WCS_Admin_Post_Types { if ( 'shop_subscription' === $typenow ) { // Filter the orders by the posted customer. - if ( isset( $_GET['_subscriber_id'] ) && $_GET['_subscriber_id'] > 0 ) { - $subscription_ids = WCS_Customer_Store::instance()->get_users_subscription_ids( absint( $_GET['_subscriber_id'] ) ); + if ( isset( $_GET['_customer_user'] ) && $_GET['_customer_user'] > 0 ) { + $subscription_ids = WCS_Customer_Store::instance()->get_users_subscription_ids( absint( $_GET['_customer_user'] ) ); $vars = self::set_post__in_query_var( $vars, $subscription_ids ); } @@ -1105,8 +1105,8 @@ class WCS_Admin_Post_Types { $user_string = ''; $user_id = ''; - if ( ! empty( $_GET['_subscriber_id'] ) ) { - $user_id = absint( $_GET['_subscriber_id'] ); + if ( ! empty( $_GET['_customer_user'] ) ) { + $user_id = absint( $_GET['_customer_user'] ); $user = get_user_by( 'id', $user_id ); $user_string = sprintf( @@ -1118,7 +1118,7 @@ class WCS_Admin_Post_Types { ); } ?> - %s', + esc_url( add_query_arg( 'user_id', $subscription->get_user_id(), admin_url( 'user-edit.php' ) ) ), + esc_html__( 'Profile', 'woocommerce-subscriptions' ) + ); } ?> get_customer_id() ) { + wcs_set_objects_property( $subscription, '_customer_user', $customer_id ); + } // Handle the billing fields. 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' ); } + // 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 ); } } diff --git a/includes/api/class-wc-rest-subscriptions-controller.php b/includes/api/class-wc-rest-subscriptions-controller.php index d55d495..80b29cc 100755 --- a/includes/api/class-wc-rest-subscriptions-controller.php +++ b/includes/api/class-wc-rest-subscriptions-controller.php @@ -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 ) : ''; } + + // 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; @@ -464,6 +468,18 @@ class WC_REST_Subscriptions_Controller extends WC_REST_Orders_V1_Controller { 'context' => array( 'view' ), '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; diff --git a/includes/class-wc-product-subscription-variation.php b/includes/class-wc-product-subscription-variation.php index 9b4f3d3..9b6f094 100755 --- a/includes/class-wc-product-subscription-variation.php +++ b/includes/class-wc-product-subscription-variation.php @@ -165,7 +165,7 @@ class WC_Product_Subscription_Variation extends WC_Product_Variation { $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; } @@ -183,7 +183,7 @@ class WC_Product_Subscription_Variation extends WC_Product_Variation { $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; } diff --git a/includes/class-wc-subscription.php b/includes/class-wc-subscription.php index dcd1fd5..364cc21 100755 --- a/includes/class-wc-subscription.php +++ b/includes/class-wc-subscription.php @@ -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) * * @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 * @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'; @@ -2176,7 +2176,7 @@ class WC_Subscription extends WC_Order { $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 - $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 ) { $files = parent::get_item_downloads( $item ); diff --git a/includes/class-wc-subscriptions-cart.php b/includes/class-wc-subscriptions-cart.php index e7f6313..e9d3729 100755 --- a/includes/class-wc-subscriptions-cart.php +++ b/includes/class-wc-subscriptions-cart.php @@ -339,7 +339,11 @@ class WC_Subscriptions_Cart { // We need to reset the packages and totals stored in WC()->shipping too WC()->shipping->reset_shipping(); self::maybe_restore_shipping_methods(); - WC()->cart->calculate_shipping(); + + // Only calculate the initial order cart shipping if we need to show shipping. + if ( WC()->cart->show_shipping() ) { + WC()->cart->calculate_shipping(); + } // We no longer need our backup of shipping methods unset( WC()->session->wcs_shipping_methods ); @@ -703,14 +707,14 @@ class WC_Subscriptions_Cart { } // 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 ); // And get the appropriate sign up fee string $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 ); @@ -1985,7 +1989,7 @@ class WC_Subscriptions_Cart { '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 if ( $is_one_payment ) { diff --git a/includes/class-wc-subscriptions-change-payment-gateway.php b/includes/class-wc-subscriptions-change-payment-gateway.php index 6786be6..facede0 100755 --- a/includes/class-wc-subscriptions-change-payment-gateway.php +++ b/includes/class-wc-subscriptions-change-payment-gateway.php @@ -32,7 +32,7 @@ class WC_Subscriptions_Change_Payment_Gateway { add_action( 'woocommerce_loaded', __CLASS__ . '::attach_dependant_hooks' ); // 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 add_action( 'after_woocommerce_pay', __CLASS__ . '::maybe_replace_pay_shortcode', 100 ); @@ -99,15 +99,15 @@ class WC_Subscriptions_Change_Payment_Gateway { } /** - * Store any messages or errors added by other plugins, particularly important for those occasions when the new payment - * method caused and error or failure. + * Store any messages or errors added by other plugins. * - * @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 ) { - self::$woocommerce_messages = wc_get_notices( 'success' ); + self::$woocommerce_messages = wc_get_notices( 'success' ); 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. * @@ -427,7 +439,8 @@ class WC_Subscriptions_Change_Payment_Gateway { */ 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 ) { if ( true !== $gateway->supports( 'subscription_payment_method_change_customer' ) ) { unset( $available_gateways[ $gateway_id ] ); diff --git a/includes/class-wc-subscriptions-coupon.php b/includes/class-wc-subscriptions-coupon.php index 353a6d8..5478aba 100755 --- a/includes/class-wc-subscriptions-coupon.php +++ b/includes/class-wc-subscriptions-coupon.php @@ -217,8 +217,8 @@ class WC_Subscriptions_Coupon { // Check if we're applying any recurring discounts to recurring total calculations if ( 'recurring_total' == $calculation_type ) { - $apply_recurring_coupon = ( 'recurring_fee' == $coupon_type ) ? true : false; - $apply_recurring_percent_coupon = ( 'recurring_percent' == $coupon_type ) ? true : false; + $apply_recurring_coupon = 'recurring_fee' == $coupon_type; + $apply_recurring_percent_coupon = 'recurring_percent' == $coupon_type; } // Check if we're applying any initial discounts @@ -873,8 +873,8 @@ class WC_Subscriptions_Coupon { * @return array The filtered payment gateways. */ public static function gateways_subscription_amount_changes( $gateways ) { - // If there are already no gateways, bail early. - if ( empty( $gateways ) ) { + // If there are already no gateways or we're on the order-pay screen, bail early. + if ( empty( $gateways ) || is_wc_endpoint_url( 'order-pay' ) ) { return $gateways; } @@ -1103,8 +1103,8 @@ class WC_Subscriptions_Coupon { // Apply recurring fee discounts to recurring total calculations if ( 'recurring_total' == $calculation_type ) { - $apply_recurring_coupon = ( 'recurring_fee' == $coupon_type ) ? true : false; - $apply_recurring_percent_coupon = ( 'recurring_percent' == $coupon_type ) ? true : false; + $apply_recurring_coupon = 'recurring_fee' == $coupon_type; + $apply_recurring_percent_coupon = 'recurring_percent' == $coupon_type; } if ( 'none' == $calculation_type ) { diff --git a/includes/class-wc-subscriptions-manager.php b/includes/class-wc-subscriptions-manager.php index f8cf75a..fc42da0 100755 --- a/includes/class-wc-subscriptions-manager.php +++ b/includes/class-wc-subscriptions-manager.php @@ -1921,7 +1921,7 @@ class WC_Subscriptions_Manager { // We've already processed the 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 ); } } diff --git a/includes/class-wc-subscriptions-order.php b/includes/class-wc-subscriptions-order.php index 7cbb5b3..6e2456b 100755 --- a/includes/class-wc-subscriptions-order.php +++ b/includes/class-wc-subscriptions-order.php @@ -1426,7 +1426,7 @@ class WC_Subscriptions_Order { 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' ); - $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_tax = (double) self::get_recurring_discount_cart_tax( $order ); diff --git a/includes/class-wc-subscriptions-product.php b/includes/class-wc-subscriptions-product.php index ea6905b..454d0d4 100755 --- a/includes/class-wc-subscriptions-product.php +++ b/includes/class-wc-subscriptions-product.php @@ -149,7 +149,7 @@ class WC_Subscriptions_Product { $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() ) ); $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) if ( $has_trial && $sign_up_fee > 0 ) { diff --git a/includes/class-wc-subscriptions-renewal-order.php b/includes/class-wc-subscriptions-renewal-order.php index ca48c3d..4af4008 100755 --- a/includes/class-wc-subscriptions-renewal-order.php +++ b/includes/class-wc-subscriptions-renewal-order.php @@ -115,7 +115,7 @@ class WC_Subscriptions_Renewal_Order { 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' - $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 ); if ( $order_needed_payment ) { diff --git a/includes/class-wc-subscriptions-switcher.php b/includes/class-wc-subscriptions-switcher.php index 436d1fc..e68b401 100755 --- a/includes/class-wc-subscriptions-switcher.php +++ b/includes/class-wc-subscriptions-switcher.php @@ -1375,8 +1375,15 @@ class WC_Subscriptions_Switcher { // 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 ) ); - // Set days in new cycle to days in old if it only differs because of rounding - if ( ceil( $days_in_new_cycle ) == $days_in_old_cycle || floor( $days_in_new_cycle ) == $days_in_old_cycle ) { + // Whether the days in new cycle match the days in old,ignoring any rounding. + $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; } @@ -1570,7 +1577,7 @@ class WC_Subscriptions_Switcher { public static function get_recurring_cart_key( $cart_key, $cart_item ) { 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'] ); add_filter( 'woocommerce_subscriptions_recurring_cart_key', __METHOD__, 10, 2 ); } @@ -1719,10 +1726,7 @@ class WC_Subscriptions_Switcher { * @since 2.0 */ protected static function is_item_switched( $item ) { - - $is_item_switched = isset( $item['switched'] ) ? true : false; - - return $is_item_switched; + return isset( $item['switched'] ); } /** diff --git a/includes/class-wc-subscriptions-synchroniser.php b/includes/class-wc-subscriptions-synchroniser.php index f7d2337..44bb735 100755 --- a/includes/class-wc-subscriptions-synchroniser.php +++ b/includes/class-wc-subscriptions-synchroniser.php @@ -472,7 +472,7 @@ class WC_Subscriptions_Synchroniser { $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 $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(); } - 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' ); } - 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 ); } /** diff --git a/includes/class-wcs-cart-renewal.php b/includes/class-wcs-cart-renewal.php index 883ad36..4f252ae 100755 --- a/includes/class-wcs-cart-renewal.php +++ b/includes/class-wcs-cart-renewal.php @@ -533,7 +533,7 @@ class WCS_Cart_Renewal { 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 - 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+ $address_fields = array_merge( WC()->checkout()->get_checkout_fields( 'billing' ), WC()->checkout()->get_checkout_fields( 'shipping' ) ); diff --git a/includes/class-wcs-cart-resubscribe.php b/includes/class-wcs-cart-resubscribe.php index 69fceef..03eb393 100755 --- a/includes/class-wcs-cart-resubscribe.php +++ b/includes/class-wcs-cart-resubscribe.php @@ -236,7 +236,7 @@ class WCS_Cart_Resubscribe extends WCS_Cart_Renewal { public function get_recurring_cart_key( $cart_key, $cart_item ) { $subscription = $this->get_order( $cart_item ); 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' ) ); add_filter( 'woocommerce_subscriptions_recurring_cart_key', array( &$this, 'get_recurring_cart_key' ), 10, 2 ); } diff --git a/includes/class-wcs-limiter.php b/includes/class-wcs-limiter.php index 1808b97..d721649 100755 --- a/includes/class-wcs-limiter.php +++ b/includes/class-wcs-limiter.php @@ -62,7 +62,6 @@ class WCS_Limiter { * @since 2.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. - * @param string $product_class Determines the subscription type of the product. Controls switch logic. * * @return bool */ diff --git a/includes/class-wcs-remove-item.php b/includes/class-wcs-remove-item.php index c79233d..7ce6eeb 100755 --- a/includes/class-wcs-remove-item.php +++ b/includes/class-wcs-remove-item.php @@ -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'] ) ) { - $subscription = ( wcs_is_subscription( $_GET['subscription_id'] ) ) ? wcs_get_subscription( $_GET['subscription_id'] ) : false; - $undo_request = ( isset( $_GET['undo_remove_item'] ) ) ? true : false; - $item_id = ( $undo_request ) ? $_GET['undo_remove_item'] : $_GET['remove_item']; + $subscription = wcs_is_subscription( $_GET['subscription_id'] ) ? wcs_get_subscription( $_GET['subscription_id'] ) : false; + $undo_request = isset( $_GET['undo_remove_item'] ); + $item_id = $undo_request ? $_GET['undo_remove_item'] : $_GET['remove_item']; if ( false === $subscription ) { diff --git a/includes/class-wcs-retry-manager.php b/includes/class-wcs-retry-manager.php index 859ef03..6d13907 100755 --- a/includes/class-wcs-retry-manager.php +++ b/includes/class-wcs-retry-manager.php @@ -86,7 +86,7 @@ class WCS_Retry_Manager { * @since 2.1 */ 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' ); $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' ); diff --git a/includes/class-wcs-staging.php b/includes/class-wcs-staging.php index 2eab372..da28dd9 100755 --- a/includes/class-wcs-staging.php +++ b/includes/class-wcs-staging.php @@ -31,7 +31,12 @@ class WCS_Staging { $renewal_order = wc_get_order( $renewal_order_id ); 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' ), '', '', ''. $wcs_site_url . '' ); + + $renewal_order->add_order_note( $message ); } } diff --git a/includes/gateways/class-wc-subscriptions-payment-gateways.php b/includes/gateways/class-wc-subscriptions-payment-gateways.php index f7135c2..55100f5 100755 --- a/includes/gateways/class-wc-subscriptions-payment-gateways.php +++ b/includes/gateways/class-wc-subscriptions-payment-gateways.php @@ -70,23 +70,29 @@ class WC_Subscriptions_Payment_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; - $subscriptions_in_cart = is_array( WC()->cart->recurring_carts ) ? count( WC()->cart->recurring_carts ) : 0; + if ( ! WC_Subscriptions_Cart::cart_contains_subscription() && ( ! isset( $_GET['order_id'] ) || ! wcs_order_contains_subscription( $_GET['order_id'] ) ) ) { + return $available_gateways; + } - foreach ( $available_gateways as $gateway_id => $gateway ) { + $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; - $supports_subscriptions = $gateway->supports( 'subscriptions' ); + foreach ( $available_gateways as $gateway_id => $gateway ) { - // Remove the payment gateway if there are multiple subscriptions in the cart and this gateway either doesn't support multiple subscriptions or isn't manual (all manual gateways support multiple subscriptions) - if ( $subscriptions_in_cart > 1 && $gateway->supports( 'multiple_subscriptions' ) !== true && ( $supports_subscriptions || ! $accept_manual_renewals ) ) { - unset( $available_gateways[ $gateway_id ] ); + $supports_subscriptions = $gateway->supports( 'subscriptions' ); - // If there is just the one subscription the cart, remove the payment gateway if manual renewals are disabled and this gateway doesn't support automatic payments - } elseif ( ! $supports_subscriptions && ! $accept_manual_renewals ) { - unset( $available_gateways[ $gateway_id ] ); - } + // Remove the payment gateway if there are multiple subscriptions in the cart and this gateway either doesn't support multiple subscriptions or isn't manual (all manual gateways support multiple subscriptions) + if ( $subscriptions_in_cart > 1 && $gateway->supports( 'multiple_subscriptions' ) !== true && ( $supports_subscriptions || ! $accept_manual_renewals ) ) { + unset( $available_gateways[ $gateway_id ] ); + + // If there is just the one subscription the cart, remove the payment gateway if manual renewals are disabled and this gateway doesn't support automatic payments + } elseif ( ! $supports_subscriptions && ! $accept_manual_renewals ) { + unset( $available_gateways[ $gateway_id ] ); } } diff --git a/includes/gateways/paypal/class-wcs-paypal.php b/includes/gateways/paypal/class-wcs-paypal.php index 05725ed..9400dc4 100755 --- a/includes/gateways/paypal/class-wcs-paypal.php +++ b/includes/gateways/paypal/class-wcs-paypal.php @@ -463,7 +463,7 @@ class WCS_PayPal { */ 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 ) { diff --git a/includes/gateways/paypal/includes/class-wcs-paypal-standard-ipn-handler.php b/includes/gateways/paypal/includes/class-wcs-paypal-standard-ipn-handler.php index 90cebef..96e9b3d 100755 --- a/includes/gateways/paypal/includes/class-wcs-paypal-standard-ipn-handler.php +++ b/includes/gateways/paypal/includes/class-wcs-paypal-standard-ipn-handler.php @@ -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' ) ) { WC_Gateway_Paypal::log( 'IPN ignored, subscription has been switched.' ); diff --git a/includes/gateways/paypal/includes/class-wcs-paypal-standard-request.php b/includes/gateways/paypal/includes/class-wcs-paypal-standard-request.php index 2cef5b3..fedb250 100755 --- a/includes/gateways/paypal/includes/class-wcs-paypal-standard-request.php +++ b/includes/gateways/paypal/includes/class-wcs-paypal-standard-request.php @@ -38,9 +38,9 @@ class WCS_PayPal_Standard_Request { // We need the subscription's total 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 { - 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 { diff --git a/includes/gateways/paypal/includes/class-wcs-paypal-standard-switcher.php b/includes/gateways/paypal/includes/class-wcs-paypal-standard-switcher.php index bdf956e..34b84dd 100755 --- a/includes/gateways/paypal/includes/class-wcs-paypal-standard-switcher.php +++ b/includes/gateways/paypal/includes/class-wcs-paypal-standard-switcher.php @@ -219,7 +219,7 @@ class WCS_PayPal_Standard_Switcher { */ 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 ) { if ( 'paypal' == $gateway_id && false == WCS_PayPal::are_reference_transactions_enabled() ) { unset( $available_gateways[ $gateway_id ] ); diff --git a/includes/payment-retry/class-wcs-retry-rule.php b/includes/payment-retry/class-wcs-retry-rule.php index bbcb095..7ba85e3 100755 --- a/includes/payment-retry/class-wcs-retry-rule.php +++ b/includes/payment-retry/class-wcs-retry-rule.php @@ -44,7 +44,7 @@ class WCS_Retry_Rule { * @since 2.1 */ 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 ] ); } /** diff --git a/includes/payment-retry/class-wcs-retry-rules.php b/includes/payment-retry/class-wcs-retry-rules.php index d0fab6d..03593f4 100755 --- a/includes/payment-retry/class-wcs-retry-rules.php +++ b/includes/payment-retry/class-wcs-retry-rules.php @@ -74,7 +74,7 @@ class WCS_Retry_Rules { * @since 2.1 */ 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 ); } /** diff --git a/includes/upgrades/class-wcs-upgrade-1-2.php b/includes/upgrades/class-wcs-upgrade-1-2.php index aaabb5e..84829fd 100755 --- a/includes/upgrades/class-wcs-upgrade-1-2.php +++ b/includes/upgrades/class-wcs-upgrade-1-2.php @@ -59,7 +59,7 @@ class WCS_Upgrade_1_2 { $trial_lengths = WC_Subscriptions_Order::get_meta( $order, '_order_subscription_trial_lengths', array() ); $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 ); diff --git a/includes/upgrades/class-wcs-upgrade-1-4.php b/includes/upgrades/class-wcs-upgrade-1-4.php index 98246f1..df0ee2f 100755 --- a/includes/upgrades/class-wcs-upgrade-1-4.php +++ b/includes/upgrades/class-wcs-upgrade-1-4.php @@ -174,7 +174,7 @@ class WCS_Upgrade_1_4 { 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(); diff --git a/includes/wcs-cart-functions.php b/includes/wcs-cart-functions.php index c7d4e85..279494b 100755 --- a/includes/wcs-cart-functions.php +++ b/includes/wcs-cart-functions.php @@ -34,7 +34,7 @@ function wcs_cart_totals_shipping_html() { $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; // Create new subscriptions for each subscription product in the cart (that is not a renewal) diff --git a/includes/wcs-compatibility-functions.php b/includes/wcs-compatibility-functions.php index 24dbb02..4ca95b8 100755 --- a/includes/wcs-compatibility-functions.php +++ b/includes/wcs-compatibility-functions.php @@ -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 if ( '_prices_include_tax' === $prefixed_key && ! is_bool( $value ) ) { - $value = 'yes' === $value ? true : false; + $value = 'yes' === $value; } $object->{ "set$prefixed_key" }( $value ); @@ -458,7 +458,7 @@ function wcs_get_coupon_property( $coupon, $property ) { switch ( true ) { case 'exists' == $property: - $value = ( $coupon->get_id() > 0 ) ? true : false; + $value = $coupon->get_id() > 0; break; case isset( $property_to_getter_map[ $property ] ) && is_callable( array( $coupon, $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: // 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 ) ) { - $value = ( 'yes' === $value ) ? true : false; + $value = 'yes' === $value; } $coupon->set_individual_use( $value ); diff --git a/includes/wcs-order-functions.php b/includes/wcs-order-functions.php index 9612ea1..105cfef 100755 --- a/includes/wcs-order-functions.php +++ b/includes/wcs-order-functions.php @@ -52,7 +52,7 @@ function wcs_get_subscriptions_for_order( $order, $args = array() ) { $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'] ) ) { @@ -186,7 +186,7 @@ function wcs_copy_order_meta( $from_order, $to_order, $type = 'subscription' ) { 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' "; } @@ -435,7 +435,7 @@ function wcs_order_contains_subscription( $order, $order_type = array( 'parent', } $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 ) { $contains_subscription = true; @@ -471,7 +471,7 @@ function wcs_get_subscription_orders( $return_fields = 'ids', $order_type = 'par $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'; $orders = array(); diff --git a/includes/wcs-product-functions.php b/includes/wcs-product-functions.php index d37dda4..7e12038 100755 --- a/includes/wcs-product-functions.php +++ b/includes/wcs-product-functions.php @@ -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_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 - $is_lowest_price = ( $variation_data['price'] < $lowest_price || '' === $lowest_price ) ? true : false; - $is_longest_period = ( WC_Subscriptions::get_longest_period( $variable_subscription_period, $variation_data['subscription']['period'] ) === $variation_data['subscription']['period'] ) ? true : false; - $is_longest_interval = ( $variation_data['subscription']['interval'] >= $variable_subscription_period_interval || '' === $variable_subscription_period_interval ) ? 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']; + $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 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 } 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) } 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 } 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 } 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 ); $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_longest_initial_period = ( $initial_period === $longest_initial_period ) ? true : false; - $is_longest_initial_interval = ( $initial_interval >= $longest_initial_interval || '' === $longest_initial_interval ) ? true : false; + $is_lowest_initial_amount = $initial_amount < $lowest_initial_amount || '' === $lowest_initial_amount; + $is_longest_initial_period = $initial_period === $longest_initial_period; + $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_shortest_period = ( $initial_period === $shortest_initial_period || '' === $shortest_initial_period ) ? true : false; - $is_shortest_interval = ( $initial_interval < $shortest_initial_interval || '' === $shortest_initial_interval ) ? true : false; + $is_highest_initial = $initial_amount > $highest_initial_amount || '' === $highest_initial_amount; + $is_shortest_period = $initial_period === $shortest_initial_period || '' === $shortest_initial_period; + $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 ( ! $is_lowest_initial_amount && $initial_amount !== $lowest_initial_amount ) { diff --git a/includes/wcs-time-functions.php b/includes/wcs-time-functions.php index 1b54c3e..883d45f 100755 --- a/includes/wcs-time-functions.php +++ b/includes/wcs-time-functions.php @@ -608,7 +608,7 @@ function wcs_is_datetime_mysql_format( $time ) { } 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 { // 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 ); @@ -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 - return ( $match && false !== $valid_time && -2209078800 <= $valid_time ) ? true : false; + return $match && false !== $valid_time && -2209078800 <= $valid_time; } /** diff --git a/includes/wcs-user-functions.php b/includes/wcs-user-functions.php index 334e114..2cd8892 100755 --- a/includes/wcs-user-functions.php +++ b/includes/wcs-user-functions.php @@ -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() ) ) { - $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(); if ( $subscription->can_be_updated_to( 'on-hold' ) && wcs_can_user_put_subscription_on_hold( $subscription, $user_id ) && ! $admin_with_suspension_disallowed ) { diff --git a/languages/woocommerce-subscriptions.pot b/languages/woocommerce-subscriptions.pot index 163ad98..0f25b84 100755 --- a/languages/woocommerce-subscriptions.pot +++ b/languages/woocommerce-subscriptions.pot @@ -2,10 +2,10 @@ # This file is distributed under the same license as the WooCommerce Subscriptions package. msgid "" msgstr "" -"Project-Id-Version: WooCommerce Subscriptions 2.3.5\n" +"Project-Id-Version: WooCommerce Subscriptions 2.3.7\n" "Report-Msgid-Bugs-To: " "https://github.com/Prospress/woocommerce-subscriptions/issues\n" -"POT-Creation-Date: 2018-08-27 07:15:08+00:00\n" +"POT-Creation-Date: 2018-09-25 00:57:34+00:00\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -144,7 +144,13 @@ msgstr "" msgid "Delete all variations without a subscription" msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:745 +#: includes/admin/class-wc-subscriptions-admin.php:743 +msgid "" +"Product type can not be changed because this product is associated with " +"active subscriptions" +msgstr "" + +#: includes/admin/class-wc-subscriptions-admin.php:747 msgid "" "You are about to trash one or more orders which contain a subscription.\n" "\n" @@ -152,7 +158,7 @@ msgid "" "orders." msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:758 +#: includes/admin/class-wc-subscriptions-admin.php:760 msgid "" "WARNING: Bad things are about to happen!\n" "\n" @@ -164,13 +170,13 @@ msgid "" "gateway." msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:759 +#: includes/admin/class-wc-subscriptions-admin.php:761 msgid "" "You are deleting a subscription item. You will also need to manually cancel " "and trash the subscription on the Manage Subscriptions screen." msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:766 +#: includes/admin/class-wc-subscriptions-admin.php:768 msgid "" "Warning: Deleting a user will also delete the user's subscriptions. The " "user's orders will remain but be reassigned to the 'Guest' user.\n" @@ -179,61 +185,63 @@ msgid "" "subscriptions?" msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:829 +#: includes/admin/class-wc-subscriptions-admin.php:831 msgid "Active subscriber?" msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:872 +#: includes/admin/class-wc-subscriptions-admin.php:874 msgid "Manage Subscriptions" msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:876 -#: woocommerce-subscriptions.php:312 +#: includes/admin/class-wc-subscriptions-admin.php:878 +#: woocommerce-subscriptions.php:314 msgid "Search Subscriptions" msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:896 -#: includes/admin/class-wc-subscriptions-admin.php:992 +#: includes/admin/class-wc-subscriptions-admin.php:898 +#: includes/admin/class-wc-subscriptions-admin.php:1018 #: includes/admin/class-wcs-admin-reports.php:51 #: includes/admin/class-wcs-admin-system-status.php:55 #: includes/admin/reports/class-wcs-report-subscription-events-by-date.php:687 #: includes/class-wcs-query.php:108 includes/class-wcs-query.php:129 #: includes/class-wcs-query.php:248 #: includes/privacy/class-wcs-privacy-exporters.php:51 -#: woocommerce-subscriptions.php:303 woocommerce-subscriptions.php:316 +#: woocommerce-subscriptions.php:305 woocommerce-subscriptions.php:318 msgid "Subscriptions" msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1032 +#: includes/admin/class-wc-subscriptions-admin.php:1058 msgid "Button Text" msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1039 +#: includes/admin/class-wc-subscriptions-admin.php:1065 msgid "Add to Cart Button Text" msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1040 +#: includes/admin/class-wc-subscriptions-admin.php:1066 msgid "" "A product displays a button with the text \"Add to Cart\". By default, a " "subscription changes this to \"Sign Up Now\". You can customise the button " "text for subscriptions here." msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1044 -#: includes/admin/class-wc-subscriptions-admin.php:1055 +#: includes/admin/class-wc-subscriptions-admin.php:1070 +#: includes/admin/class-wc-subscriptions-admin.php:1073 +#: includes/admin/class-wc-subscriptions-admin.php:1082 +#: includes/admin/class-wc-subscriptions-admin.php:1085 #: includes/class-wc-product-subscription-variation.php:98 #: includes/class-wc-product-subscription.php:72 #: includes/class-wc-product-variable-subscription.php:73 #: includes/class-wc-subscriptions-product.php:99 -#: woocommerce-subscriptions.php:608 +#: woocommerce-subscriptions.php:610 msgid "Sign Up Now" msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1050 +#: includes/admin/class-wc-subscriptions-admin.php:1077 msgid "Place Order Button Text" msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1051 +#: includes/admin/class-wc-subscriptions-admin.php:1078 msgid "" "Use this field to customise the text displayed on the checkout button when " "an order contains a subscription. Normally the checkout submission button " @@ -241,11 +249,11 @@ msgid "" "changed to \"Sign Up Now\"." msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1063 +#: includes/admin/class-wc-subscriptions-admin.php:1091 msgid "Roles" msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1066 +#: includes/admin/class-wc-subscriptions-admin.php:1094 #. translators: placeholders are tags msgid "" "Choose the default roles to assign to active and inactive subscribers. For " @@ -254,46 +262,46 @@ msgid "" "allocated these roles to prevent locking out administrators." msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1071 +#: includes/admin/class-wc-subscriptions-admin.php:1099 msgid "Subscriber Default Role" msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1072 +#: includes/admin/class-wc-subscriptions-admin.php:1100 msgid "" "When a subscription is activated, either manually or after a successful " "purchase, new users will be assigned this role." msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1083 +#: includes/admin/class-wc-subscriptions-admin.php:1111 msgid "Inactive Subscriber Role" msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1084 +#: includes/admin/class-wc-subscriptions-admin.php:1112 msgid "" "If a subscriber's subscription is manually cancelled or expires, she will " "be assigned this role." msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1104 +#: includes/admin/class-wc-subscriptions-admin.php:1132 msgid "Manual Renewal Payments" msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1105 +#: includes/admin/class-wc-subscriptions-admin.php:1133 msgid "Accept Manual Renewals" msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1110 +#: includes/admin/class-wc-subscriptions-admin.php:1138 #. translators: placeholders are opening and closing link tags msgid "" "With manual renewals, a customer's subscription is put on-hold until they " "login and pay to renew it. %sLearn more%s." msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1116 +#: includes/admin/class-wc-subscriptions-admin.php:1144 msgid "Turn off Automatic Payments" msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1121 +#: includes/admin/class-wc-subscriptions-admin.php:1149 #. translators: placeholders are opening and closing link tags msgid "" "If you don't want new subscription purchases to automatically charge " @@ -302,11 +310,11 @@ msgid "" "more%s." msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1136 +#: includes/admin/class-wc-subscriptions-admin.php:1164 msgid "Customer Suspensions" msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1143 +#: includes/admin/class-wc-subscriptions-admin.php:1171 msgid "" "Set a maximum number of times a customer can suspend their account for each " "billing period. For example, for a value of 3 and a subscription billed " @@ -316,30 +324,30 @@ msgid "" "this to 0 to turn off the customer suspension feature completely." msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1147 +#: includes/admin/class-wc-subscriptions-admin.php:1175 msgid "Mixed Checkout" msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1148 +#: includes/admin/class-wc-subscriptions-admin.php:1176 msgid "Allow multiple subscriptions and products to be purchased simultaneously." msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1152 +#: includes/admin/class-wc-subscriptions-admin.php:1180 msgid "" "Allow a subscription product to be purchased with other products and " "subscriptions in the same transaction." msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1156 +#: includes/admin/class-wc-subscriptions-admin.php:1184 #: includes/upgrades/templates/wcs-about-2-0.php:108 msgid "Drip Downloadable Content" msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1157 +#: includes/admin/class-wc-subscriptions-admin.php:1185 msgid "Enable dripping for downloadable content on subscription products." msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1161 +#: includes/admin/class-wc-subscriptions-admin.php:1189 msgid "" "Enabling this grants access to new downloadable files added to a product " "only after the next renewal is processed.%sBy default, access to new " @@ -347,7 +355,7 @@ msgid "" "customer that has an active subscription with that product." msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1197 +#: includes/admin/class-wc-subscriptions-admin.php:1225 #. translators: $1-$2: opening and closing tags, $3-$4: opening and #. closing tags msgid "" @@ -355,73 +363,73 @@ msgid "" "start selling subscriptions!%4$s" msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1202 +#: includes/admin/class-wc-subscriptions-admin.php:1230 msgid "Add a Subscription Product" msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1203 +#: includes/admin/class-wc-subscriptions-admin.php:1231 #: includes/upgrades/templates/wcs-about-2-0.php:35 #: includes/upgrades/templates/wcs-about.php:34 -#: woocommerce-subscriptions.php:1179 +#: woocommerce-subscriptions.php:1196 msgid "Settings" msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1289 +#: includes/admin/class-wc-subscriptions-admin.php:1317 #. translators: placeholder is a number msgid "We can't find a subscription with ID #%d. Perhaps it was deleted?" msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1322 -#: includes/admin/class-wc-subscriptions-admin.php:1327 +#: includes/admin/class-wc-subscriptions-admin.php:1350 +#: includes/admin/class-wc-subscriptions-admin.php:1355 #. translators: placeholders are opening link tag, ID of sub, and closing link #. tag msgid "Showing orders for %sSubscription %s%s" msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1351 +#: includes/admin/class-wc-subscriptions-admin.php:1379 #. translators: number of 1$: days, 2$: weeks, 3$: months, 4$: years msgid "The trial period can not exceed: %1s, %2s, %3s or %4s." msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1356 +#: includes/admin/class-wc-subscriptions-admin.php:1384 #. translators: placeholder is a time period (e.g. "4 weeks") msgid "The trial period can not exceed %s." msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1419 -#: includes/admin/class-wc-subscriptions-admin.php:1472 +#: includes/admin/class-wc-subscriptions-admin.php:1447 +#: includes/admin/class-wc-subscriptions-admin.php:1500 #: includes/admin/class-wcs-admin-system-status.php:94 #: includes/admin/reports/class-wcs-report-cache-manager.php:341 msgid "Yes" msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1419 +#: includes/admin/class-wc-subscriptions-admin.php:1447 #: includes/admin/class-wcs-admin-system-status.php:94 #: includes/admin/reports/class-wcs-report-cache-manager.php:341 msgid "No" msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1455 +#: includes/admin/class-wc-subscriptions-admin.php:1483 msgid "Automatic Recurring Payments" msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1472 +#: includes/admin/class-wc-subscriptions-admin.php:1500 msgid "" "Supports automatic renewal payments with the WooCommerce Subscriptions " "extension." msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1552 +#: includes/admin/class-wc-subscriptions-admin.php:1580 msgid "Subscription items can no longer be edited." msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1556 +#: includes/admin/class-wc-subscriptions-admin.php:1584 msgid "" "This subscription is no longer editable because the payment gateway does " "not allow modification of recurring amounts." msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1575 +#: includes/admin/class-wc-subscriptions-admin.php:1603 #. translators: $1-2: opening and closing tags of a link that takes to Woo #. marketplace / Stripe product page msgid "" @@ -430,18 +438,18 @@ msgid "" "the %1$sfree Stripe extension%2$s." msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1580 +#: includes/admin/class-wc-subscriptions-admin.php:1608 msgid "Recurring Payments" msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1588 +#: includes/admin/class-wc-subscriptions-admin.php:1616 #. translators: placeholders are opening and closing link tags msgid "" "Payment gateways which don't support automatic recurring payments can be " "used to process %smanual subscription renewal payments%s." msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1595 +#: includes/admin/class-wc-subscriptions-admin.php:1623 #. translators: $1-$2: opening and closing tags. Link to documents->payment #. gateways, 3$-4$: opening and closing tags. Link to WooCommerce extensions #. shop page @@ -450,7 +458,7 @@ msgid "" "the official %3$sWooCommerce Marketplace%4$s." msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1697 +#: includes/admin/class-wc-subscriptions-admin.php:1725 msgid "Note that purchasing a subscription still requires an account." msgstr "" @@ -568,7 +576,7 @@ msgstr "" #: templates/emails/subscription-info.php:18 #: templates/myaccount/my-subscriptions.php:25 #: templates/myaccount/related-subscriptions.php:20 -#: woocommerce-subscriptions.php:304 +#: woocommerce-subscriptions.php:306 msgid "Subscription" msgstr "" @@ -724,7 +732,7 @@ msgid "%1$s (#%2$s – %3$s)" msgstr "" #: includes/admin/class-wcs-admin-post-types.php:1121 -#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:79 +#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:84 msgid "Search for a customer…" msgstr "" @@ -802,83 +810,87 @@ msgstr "" msgid "View other subscriptions" msgstr "" -#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:87 +#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:68 +msgid "Profile" +msgstr "" + +#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:92 msgid "Subscription status:" msgstr "" -#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:104 +#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:109 msgid "Parent order: " msgstr "" -#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:106 +#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:111 msgid "#%1$s" msgstr "" -#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:112 +#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:117 msgid "Parent order:" msgstr "" -#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:118 +#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:123 msgid "Select an order…" msgstr "" -#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:128 +#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:133 msgid "Billing Details" msgstr "" -#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:129 -#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:201 +#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:134 +#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:206 #: includes/payment-retry/class-wcs-retry-post-store.php:38 msgid "Edit" msgstr "" -#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:130 +#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:135 msgid "Load billing address" msgstr "" -#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:137 -#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:139 -#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:210 -#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:212 +#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:142 +#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:144 +#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:215 +#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:217 msgid "Address" msgstr "" -#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:139 +#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:144 msgid "No billing address set." msgstr "" -#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:159 +#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:164 #: includes/class-wcs-change-payment-method-admin.php:38 #: includes/class-wcs-change-payment-method-admin.php:51 msgid "Payment Method" msgstr "" -#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:200 +#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:205 msgid "Shipping Details" msgstr "" -#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:202 +#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:207 msgid "Copy from billing" msgstr "" -#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:203 +#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:208 msgid "Load shipping address" msgstr "" -#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:212 +#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:217 msgid "No shipping address set." msgstr "" -#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:234 -#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:264 +#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:239 +#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:269 msgid "Customer Provided Note" msgstr "" -#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:265 +#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:270 msgid "Customer's notes about the order" msgstr "" -#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:350 +#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:358 #. translators: placeholder is error message from the payment gateway or #. subscriptions when updating the status msgid "Error updating some information: %s" @@ -1410,16 +1422,16 @@ msgstr "" msgid "Renewals amount" msgstr "" -#: includes/api/class-wc-rest-subscriptions-controller.php:114 +#: includes/api/class-wc-rest-subscriptions-controller.php:118 msgid "Customer ID is invalid." msgstr "" -#: includes/api/class-wc-rest-subscriptions-controller.php:219 +#: includes/api/class-wc-rest-subscriptions-controller.php:223 #: includes/api/legacy/class-wc-rest-subscriptions-controller.php:171 msgid "Invalid subscription id." msgstr "" -#: includes/api/class-wc-rest-subscriptions-controller.php:290 +#: includes/api/class-wc-rest-subscriptions-controller.php:294 #: includes/api/legacy/class-wc-api-subscriptions.php:307 #: includes/api/legacy/class-wc-rest-subscriptions-controller.php:303 msgid "" @@ -1427,7 +1439,7 @@ msgid "" "Subscription." msgstr "" -#: includes/api/class-wc-rest-subscriptions-controller.php:321 +#: includes/api/class-wc-rest-subscriptions-controller.php:325 #: includes/api/legacy/class-wc-rest-subscriptions-controller.php:333 #. translators: 1$: gateway id, 2$: error message msgid "" @@ -1435,62 +1447,70 @@ msgid "" "%2$s" msgstr "" -#: includes/api/class-wc-rest-subscriptions-controller.php:388 -#: includes/api/class-wc-rest-subscriptions-controller.php:542 +#: includes/api/class-wc-rest-subscriptions-controller.php:392 +#: includes/api/class-wc-rest-subscriptions-controller.php:558 #: includes/api/legacy/class-wc-rest-subscriptions-controller.php:284 msgid "Updating subscription dates errored with message: %s" msgstr "" -#: includes/api/class-wc-rest-subscriptions-controller.php:413 +#: includes/api/class-wc-rest-subscriptions-controller.php:417 #: includes/api/legacy/class-wc-rest-subscriptions-controller.php:347 msgid "The number of billing periods between subscription renewals." msgstr "" -#: includes/api/class-wc-rest-subscriptions-controller.php:418 +#: includes/api/class-wc-rest-subscriptions-controller.php:422 #: includes/api/legacy/class-wc-rest-subscriptions-controller.php:352 msgid "Billing period for the subscription." msgstr "" -#: includes/api/class-wc-rest-subscriptions-controller.php:424 +#: includes/api/class-wc-rest-subscriptions-controller.php:428 #: includes/api/legacy/class-wc-rest-subscriptions-controller.php:358 msgid "Subscription payment details." msgstr "" -#: includes/api/class-wc-rest-subscriptions-controller.php:429 +#: includes/api/class-wc-rest-subscriptions-controller.php:433 #: includes/api/legacy/class-wc-rest-subscriptions-controller.php:363 msgid "Payment gateway ID." msgstr "" -#: includes/api/class-wc-rest-subscriptions-controller.php:436 +#: includes/api/class-wc-rest-subscriptions-controller.php:440 #: includes/api/legacy/class-wc-rest-subscriptions-controller.php:370 msgid "The subscription's start date." msgstr "" -#: includes/api/class-wc-rest-subscriptions-controller.php:441 +#: includes/api/class-wc-rest-subscriptions-controller.php:445 #: includes/api/legacy/class-wc-rest-subscriptions-controller.php:375 msgid "The subscription's trial date" msgstr "" -#: includes/api/class-wc-rest-subscriptions-controller.php:446 +#: includes/api/class-wc-rest-subscriptions-controller.php:450 #: includes/api/legacy/class-wc-rest-subscriptions-controller.php:380 msgid "The subscription's next payment date." msgstr "" -#: includes/api/class-wc-rest-subscriptions-controller.php:451 +#: includes/api/class-wc-rest-subscriptions-controller.php:455 #: includes/api/legacy/class-wc-rest-subscriptions-controller.php:385 msgid "The subscription's end date." msgstr "" -#: includes/api/class-wc-rest-subscriptions-controller.php:456 +#: includes/api/class-wc-rest-subscriptions-controller.php:460 msgid "" "The subscription's original subscription ID if this is a resubscribed " "subscription." msgstr "" -#: includes/api/class-wc-rest-subscriptions-controller.php:462 +#: includes/api/class-wc-rest-subscriptions-controller.php:466 msgid "The subscription's resubscribed subscription ID." msgstr "" +#: includes/api/class-wc-rest-subscriptions-controller.php:472 +msgid "The date the subscription's latest order was completed, in GMT." +msgstr "" + +#: includes/api/class-wc-rest-subscriptions-controller.php:478 +msgid "The date the subscription's latest order was paid, in GMT." +msgstr "" + #: includes/api/legacy/class-wc-api-subscriptions.php:102 wcs-functions.php:172 msgid "Invalid subscription status given." msgstr "" @@ -1667,64 +1687,64 @@ msgstr "" msgid "Update the %1$s used for %2$sall%3$s of my active subscriptions" msgstr "" -#: includes/class-wc-subscriptions-cart.php:898 +#: includes/class-wc-subscriptions-cart.php:902 msgid "Please enter a valid postcode/ZIP." msgstr "" -#: includes/class-wc-subscriptions-cart.php:1069 +#: includes/class-wc-subscriptions-cart.php:1073 msgid "" "That subscription product can not be added to your cart as it already " "contains a subscription renewal." msgstr "" -#: includes/class-wc-subscriptions-cart.php:1157 +#: includes/class-wc-subscriptions-cart.php:1161 msgid "Invalid recurring shipping method." msgstr "" -#: includes/class-wc-subscriptions-cart.php:1980 +#: includes/class-wc-subscriptions-cart.php:1984 msgid "now" msgstr "" -#: includes/class-wc-subscriptions-change-payment-gateway.php:148 +#: includes/class-wc-subscriptions-change-payment-gateway.php:160 #: templates/emails/plain/email-order-details.php:19 #. translators: placeholder is the subscription order number wrapped in #. tags msgid "Subscription Number: %s" msgstr "" -#: includes/class-wc-subscriptions-change-payment-gateway.php:154 +#: includes/class-wc-subscriptions-change-payment-gateway.php:166 #. translators: placeholder is the subscription's next payment date (either #. human readable or normal date) wrapped in tags msgid "Next Payment Date: %s" msgstr "" -#: includes/class-wc-subscriptions-change-payment-gateway.php:160 +#: includes/class-wc-subscriptions-change-payment-gateway.php:172 #. translators: placeholder is the formatted total to be paid for the #. subscription wrapped in tags msgid "Total: %s" msgstr "" -#: includes/class-wc-subscriptions-change-payment-gateway.php:167 +#: includes/class-wc-subscriptions-change-payment-gateway.php:179 #. translators: placeholder is the display name of the payment method msgid "Payment Method: %s" msgstr "" -#: includes/class-wc-subscriptions-change-payment-gateway.php:179 +#: includes/class-wc-subscriptions-change-payment-gateway.php:191 msgid "" "Sorry, this subscription change payment method request is invalid and " "cannot be processed." msgstr "" -#: includes/class-wc-subscriptions-change-payment-gateway.php:211 +#: includes/class-wc-subscriptions-change-payment-gateway.php:223 msgid "There was an error with your request. Please try again." msgstr "" -#: includes/class-wc-subscriptions-change-payment-gateway.php:215 +#: includes/class-wc-subscriptions-change-payment-gateway.php:227 #: templates/myaccount/view-subscription.php:20 msgid "Invalid Subscription." msgstr "" -#: includes/class-wc-subscriptions-change-payment-gateway.php:219 +#: includes/class-wc-subscriptions-change-payment-gateway.php:231 #: includes/class-wcs-cart-resubscribe.php:78 #: includes/class-wcs-cart-resubscribe.php:129 #: includes/class-wcs-user-change-status-handler.php:103 @@ -1732,25 +1752,25 @@ msgstr "" msgid "That doesn't appear to be one of your subscriptions." msgstr "" -#: includes/class-wc-subscriptions-change-payment-gateway.php:223 +#: includes/class-wc-subscriptions-change-payment-gateway.php:235 msgid "The payment method can not be changed for that subscription." msgstr "" -#: includes/class-wc-subscriptions-change-payment-gateway.php:229 +#: includes/class-wc-subscriptions-change-payment-gateway.php:241 #. translators: placeholder is next payment's date msgid " Next payment is due %s." msgstr "" -#: includes/class-wc-subscriptions-change-payment-gateway.php:235 +#: includes/class-wc-subscriptions-change-payment-gateway.php:247 #. translators: placeholder is either empty or "Next payment is due..." msgid "Choose a new payment method.%s" msgstr "" -#: includes/class-wc-subscriptions-change-payment-gateway.php:264 +#: includes/class-wc-subscriptions-change-payment-gateway.php:276 msgid "Invalid order." msgstr "" -#: includes/class-wc-subscriptions-change-payment-gateway.php:366 +#: includes/class-wc-subscriptions-change-payment-gateway.php:378 msgid "Payment method updated." msgstr "" @@ -1882,7 +1902,7 @@ msgid "Error: Unable to create renewal order with note \"%s\"" msgstr "" #: includes/class-wc-subscriptions-manager.php:168 -#: includes/gateways/class-wc-subscriptions-payment-gateways.php:204 +#: includes/gateways/class-wc-subscriptions-payment-gateways.php:210 msgid "Subscription doesn't exist in scheduled action: %d" msgstr "" @@ -2222,7 +2242,7 @@ msgstr "" #: includes/class-wc-subscriptions-switcher.php:421 #: includes/class-wc-subscriptions-switcher.php:447 -#: includes/class-wc-subscriptions-switcher.php:2442 +#: includes/class-wc-subscriptions-switcher.php:2446 msgid "Upgrade or Downgrade" msgstr "" @@ -2260,16 +2280,16 @@ msgstr "" msgid "There was an error locating the switch details." msgstr "" -#: includes/class-wc-subscriptions-switcher.php:1892 -#: includes/class-wc-subscriptions-switcher.php:2236 +#: includes/class-wc-subscriptions-switcher.php:1896 +#: includes/class-wc-subscriptions-switcher.php:2240 msgid "The original subscription item being switched cannot be found." msgstr "" -#: includes/class-wc-subscriptions-switcher.php:1894 +#: includes/class-wc-subscriptions-switcher.php:1898 msgid "The item on the switch order cannot be found." msgstr "" -#: includes/class-wc-subscriptions-switcher.php:2273 +#: includes/class-wc-subscriptions-switcher.php:2277 msgid "Failed to update the subscription shipping method." msgstr "" @@ -2596,11 +2616,13 @@ msgid "" "not support removing an item." msgstr "" -#: includes/class-wcs-staging.php:34 -msgid "Payment processing skipped - renewal order created under staging site lock." +#: includes/class-wcs-staging.php:37 +msgid "" +"Payment processing skipped - renewal order created on %sstaging site%s " +"under staging site lock. Live site is at %s" msgstr "" -#: includes/class-wcs-staging.php:47 +#: includes/class-wcs-staging.php:52 msgid "staging" msgstr "" @@ -2981,7 +3003,7 @@ msgid "" "to run {retry_time}" msgstr "" -#: includes/gateways/class-wc-subscriptions-payment-gateways.php:126 +#: includes/gateways/class-wc-subscriptions-payment-gateways.php:132 msgid "" "Sorry, it seems there are no available payment methods which support " "subscriptions. Please contact us if you require assistance or wish to make " @@ -4644,71 +4666,71 @@ msgstr "" msgid "Date type can not be an empty string." msgstr "" -#: woocommerce-subscriptions.php:318 +#: woocommerce-subscriptions.php:320 msgid "This is where subscriptions are stored." msgstr "" -#: woocommerce-subscriptions.php:363 +#: woocommerce-subscriptions.php:365 msgid "No Subscriptions found" msgstr "" -#: woocommerce-subscriptions.php:365 +#: woocommerce-subscriptions.php:367 msgid "" "Subscriptions will appear here for you to view and manage once purchased by " "a customer." msgstr "" -#: woocommerce-subscriptions.php:367 +#: woocommerce-subscriptions.php:369 #. translators: placeholders are opening and closing link tags msgid "%sLearn more about managing subscriptions »%s" msgstr "" -#: woocommerce-subscriptions.php:369 +#: woocommerce-subscriptions.php:371 #. translators: placeholders are opening and closing link tags msgid "%sAdd a subscription product »%s" msgstr "" -#: woocommerce-subscriptions.php:523 +#: woocommerce-subscriptions.php:525 msgid "" "A subscription renewal has been removed from your cart. Multiple " "subscriptions can not be purchased at the same time." msgstr "" -#: woocommerce-subscriptions.php:529 +#: woocommerce-subscriptions.php:531 msgid "" "A subscription has been removed from your cart. Due to payment gateway " "restrictions, different subscription products can not be purchased at the " "same time." msgstr "" -#: woocommerce-subscriptions.php:535 +#: woocommerce-subscriptions.php:537 msgid "" "A subscription has been removed from your cart. Products and subscriptions " "can not be purchased at the same time." msgstr "" -#: woocommerce-subscriptions.php:677 woocommerce-subscriptions.php:694 +#: woocommerce-subscriptions.php:679 woocommerce-subscriptions.php:696 #. translators: placeholder is a number, this is for the teens #. translators: placeholder is a number, numbers ending in 4-9, 0 msgid "%sth" msgstr "" -#: woocommerce-subscriptions.php:682 +#: woocommerce-subscriptions.php:684 #. translators: placeholder is a number, numbers ending in 1 msgid "%sst" msgstr "" -#: woocommerce-subscriptions.php:686 +#: woocommerce-subscriptions.php:688 #. translators: placeholder is a number, numbers ending in 2 msgid "%snd" msgstr "" -#: woocommerce-subscriptions.php:690 +#: woocommerce-subscriptions.php:692 #. translators: placeholder is a number, numbers ending in 3 msgid "%srd" msgstr "" -#: woocommerce-subscriptions.php:720 +#: woocommerce-subscriptions.php:722 #. 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 @@ -4718,20 +4740,21 @@ msgid "" "%5$sinstall & activate WooCommerce »%6$s" msgstr "" -#: woocommerce-subscriptions.php:727 -#. translators: 1$-2$: opening and closing tags, 3$-4$: opening and -#. closing link tags, leads to plugin admin +#: woocommerce-subscriptions.php:725 +#. translators: 1$-2$: opening and closing tags, 3$: minimum supported +#. WooCommerce version, 4$-5$: opening and closing link tags, leads to plugin +#. admin msgid "" "%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" +"Subscriptions requires WooCommerce %3$s or newer. Please %4$supdate " +"WooCommerce to version %3$s or newer »%5$s" msgstr "" -#: woocommerce-subscriptions.php:753 +#: woocommerce-subscriptions.php:756 msgid "Variable Subscription" msgstr "" -#: woocommerce-subscriptions.php:896 +#: woocommerce-subscriptions.php:899 msgid "" "%1$sWarning!%2$s We can see the %1$sWooCommerce Subscriptions Early " "Renewal%2$s plugin is active. Version %3$s of %1$sWooCommerce " @@ -4740,11 +4763,11 @@ msgid "" "avoid any conflicts." msgstr "" -#: woocommerce-subscriptions.php:899 +#: woocommerce-subscriptions.php:902 msgid "Installed Plugins" msgstr "" -#: woocommerce-subscriptions.php:972 +#: woocommerce-subscriptions.php:975 #. translators: 1$-2$: opening and closing tags, 3$-4$: opening and #. closing link tags. Leads to duplicate site article on docs msgid "" @@ -4754,19 +4777,19 @@ msgid "" "environment. %3$sLearn more »%4$s." msgstr "" -#: woocommerce-subscriptions.php:974 +#: woocommerce-subscriptions.php:977 msgid "Quit nagging me (but don't enable automatic payments)" msgstr "" -#: woocommerce-subscriptions.php:975 +#: woocommerce-subscriptions.php:978 msgid "Enable automatic payments" msgstr "" -#: woocommerce-subscriptions.php:1181 +#: woocommerce-subscriptions.php:1198 msgid "Support" msgstr "" -#: woocommerce-subscriptions.php:1266 +#: woocommerce-subscriptions.php:1279 #. translators: placeholders are opening and closing tags. Leads to docs on #. version 2 msgid "" @@ -4777,14 +4800,14 @@ msgid "" "2.0 »%s" msgstr "" -#: woocommerce-subscriptions.php:1281 +#: woocommerce-subscriptions.php:1294 msgid "" "Warning! You are running version %s of WooCommerce Subscriptions plugin " "code but your database has been upgraded to Subscriptions version 2.0. This " "will cause major problems on your store." msgstr "" -#: woocommerce-subscriptions.php:1282 +#: woocommerce-subscriptions.php:1295 msgid "" "Please upgrade the WooCommerce Subscriptions plugin to version 2.0 or newer " "immediately. If you need assistance, after upgrading to Subscriptions v2.0, " @@ -4833,7 +4856,7 @@ msgctxt "example price" msgid "e.g. 9.90" msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:784 +#: includes/admin/class-wc-subscriptions-admin.php:786 #. translators: placeholders are for HTML tags. They are 1$: "

", 2$: #. "

", 3$: "

", 4$: "", 5$: "", 6$: "", 7$: "", 8$: #. "

" @@ -4844,7 +4867,7 @@ msgid "" "%6$sVariable subscription%7$s.%8$s" msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:786 +#: includes/admin/class-wc-subscriptions-admin.php:788 #. translators: placeholders are for HTML tags. They are 1$: "

", 2$: #. "

", 3$: "

", 4$: "

" msgctxt "used in admin pointer script params in javascript as price pointer content" @@ -4854,17 +4877,17 @@ msgid "" "sign-up fee and free trial.%4$s" msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1097 +#: includes/admin/class-wc-subscriptions-admin.php:1125 msgctxt "option section heading" msgid "Renewals" msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1129 +#: includes/admin/class-wc-subscriptions-admin.php:1157 msgctxt "options section heading" msgid "Miscellaneous" msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1137 +#: includes/admin/class-wc-subscriptions-admin.php:1165 msgctxt "there's a number immediately in front of this text" msgid "suspensions per billing period." msgstr "" @@ -4874,25 +4897,25 @@ msgctxt "there's a number immediately in front of this text" msgid "days prior to Renewal Day" msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1418 +#: includes/admin/class-wc-subscriptions-admin.php:1446 #: includes/admin/class-wcs-admin-system-status.php:92 msgctxt "label that indicates whether debugging is turned on for the plugin" msgid "WCS_DEBUG" msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1424 +#: includes/admin/class-wc-subscriptions-admin.php:1452 #: includes/admin/class-wcs-admin-system-status.php:104 msgctxt "Live or Staging, Label on WooCommerce -> System Status page" msgid "Subscriptions Mode" msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1425 +#: includes/admin/class-wc-subscriptions-admin.php:1453 #: includes/admin/class-wcs-admin-system-status.php:106 msgctxt "refers to staging site" msgid "Staging" msgstr "" -#: includes/admin/class-wc-subscriptions-admin.php:1425 +#: includes/admin/class-wc-subscriptions-admin.php:1453 #: includes/admin/class-wcs-admin-system-status.php:106 msgctxt "refers to live site" msgid "Live" @@ -5046,7 +5069,7 @@ msgctxt "edit subscription header" msgid "Subscription #%s details" msgstr "" -#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:163 +#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:168 #: includes/class-wcs-change-payment-method-admin.php:52 msgctxt "" "The gateway ID displayed on the Edit Subscriptions screen when editing " @@ -5054,7 +5077,7 @@ msgctxt "" msgid "Gateway ID: [%s]" msgstr "" -#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:336 +#: includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:344 msgctxt "subscription note after linking to a parent order" msgid "Subscription linked to parent order %s via admin." msgstr "" @@ -5180,19 +5203,19 @@ msgctxt "appears in an error message if date is wrong format" msgid "Invalid %s date. The date must be of the format: \"Y-m-d H:i:s\"." msgstr "" -#: includes/class-wc-subscriptions-change-payment-gateway.php:288 +#: includes/class-wc-subscriptions-change-payment-gateway.php:300 msgctxt "label on button, imperative" msgid "Change Payment" msgstr "" -#: includes/class-wc-subscriptions-change-payment-gateway.php:414 +#: includes/class-wc-subscriptions-change-payment-gateway.php:426 msgctxt "%1$s: old payment title, %2$s: new payment title" msgid "" "Payment method changed from \"%1$s\" to \"%2$s\" by the subscriber from " "their account page." msgstr "" -#: includes/class-wc-subscriptions-change-payment-gateway.php:539 +#: includes/class-wc-subscriptions-change-payment-gateway.php:552 msgctxt "the page title of the change payment method form" msgid "Change Payment Method" msgstr "" @@ -5245,7 +5268,7 @@ msgctxt "Subscription status" msgid "On-hold" msgstr "" -#: includes/class-wc-subscriptions-switcher.php:2583 wcs-functions.php:228 +#: includes/class-wc-subscriptions-switcher.php:2587 wcs-functions.php:228 msgctxt "Subscription status" msgid "Switched" msgstr "" @@ -5376,30 +5399,30 @@ msgctxt "when to prorate first payment / subscription length" msgid "Never (charge the full recurring amount at sign-up)" msgstr "" -#: includes/class-wc-subscriptions-switcher.php:1778 +#: includes/class-wc-subscriptions-switcher.php:1782 msgctxt "a switch order" msgid "Downgrade" msgstr "" -#: includes/class-wc-subscriptions-switcher.php:1781 +#: includes/class-wc-subscriptions-switcher.php:1785 msgctxt "a switch order" msgid "Upgrade" msgstr "" -#: includes/class-wc-subscriptions-switcher.php:1784 +#: includes/class-wc-subscriptions-switcher.php:1788 msgctxt "a switch order" msgid "Crossgrade" msgstr "" -#: includes/class-wc-subscriptions-switcher.php:1789 +#: includes/class-wc-subscriptions-switcher.php:1793 #. translators: %1: product subtotal, %2: HTML span tag, %3: direction #. (upgrade, downgrade, crossgrade), %4: closing HTML span tag msgctxt "product subtotal string" msgid "%1$s %2$s(%3$s)%4$s" msgstr "" -#: includes/class-wc-subscriptions-switcher.php:1905 -#: includes/class-wc-subscriptions-switcher.php:2247 +#: includes/class-wc-subscriptions-switcher.php:1909 +#: includes/class-wc-subscriptions-switcher.php:2251 #. translators: 1$: old item, 2$: new item when switching msgctxt "used in order notes" msgid "Customer switched from: %1$s to %2$s." @@ -5769,7 +5792,7 @@ msgid "2.3" msgstr "" #: includes/upgrades/templates/wcs-about-2-0.php:36 -#: woocommerce-subscriptions.php:1180 +#: woocommerce-subscriptions.php:1197 msgctxt "short for documents" msgid "Docs" msgstr "" @@ -6247,68 +6270,68 @@ msgctxt "The post title for the new subscription" msgid "Subscription – %s" msgstr "" -#: woocommerce-subscriptions.php:305 +#: woocommerce-subscriptions.php:307 msgctxt "custom post type setting" msgid "Add Subscription" msgstr "" -#: woocommerce-subscriptions.php:306 +#: woocommerce-subscriptions.php:308 msgctxt "custom post type setting" msgid "Add New Subscription" msgstr "" -#: woocommerce-subscriptions.php:307 +#: woocommerce-subscriptions.php:309 msgctxt "custom post type setting" msgid "Edit" msgstr "" -#: woocommerce-subscriptions.php:308 +#: woocommerce-subscriptions.php:310 msgctxt "custom post type setting" msgid "Edit Subscription" msgstr "" -#: woocommerce-subscriptions.php:309 +#: woocommerce-subscriptions.php:311 msgctxt "custom post type setting" msgid "New Subscription" msgstr "" -#: woocommerce-subscriptions.php:310 woocommerce-subscriptions.php:311 +#: woocommerce-subscriptions.php:312 woocommerce-subscriptions.php:313 msgctxt "custom post type setting" msgid "View Subscription" msgstr "" -#: woocommerce-subscriptions.php:314 +#: woocommerce-subscriptions.php:316 msgctxt "custom post type setting" msgid "No Subscriptions found in trash" msgstr "" -#: woocommerce-subscriptions.php:315 +#: woocommerce-subscriptions.php:317 msgctxt "custom post type setting" msgid "Parent Subscriptions" msgstr "" -#: woocommerce-subscriptions.php:383 +#: woocommerce-subscriptions.php:385 msgctxt "post status label including post count" msgid "Active (%s)" msgid_plural "Active (%s)" msgstr[0] "" msgstr[1] "" -#: woocommerce-subscriptions.php:384 +#: woocommerce-subscriptions.php:386 msgctxt "post status label including post count" msgid "Switched (%s)" msgid_plural "Switched (%s)" msgstr[0] "" msgstr[1] "" -#: woocommerce-subscriptions.php:385 +#: woocommerce-subscriptions.php:387 msgctxt "post status label including post count" msgid "Expired (%s)" msgid_plural "Expired (%s)" msgstr[0] "" msgstr[1] "" -#: woocommerce-subscriptions.php:386 +#: woocommerce-subscriptions.php:388 msgctxt "post status label including post count" msgid "Pending Cancellation (%s)" msgid_plural "Pending Cancellation (%s)" diff --git a/templates/single-product/add-to-cart/variable-subscription.php b/templates/single-product/add-to-cart/variable-subscription.php index ecb55cd..d0e8df0 100755 --- a/templates/single-product/add-to-cart/variable-subscription.php +++ b/templates/single-product/add-to-cart/variable-subscription.php @@ -31,14 +31,14 @@ do_action( 'woocommerce_before_add_to_cart_form' ); ?>

- false ) ) ) ) : ?> + false ) ) ) : ?>

$options ) : ?> - +
get_variation_default_attribute( $attribute_name ); diff --git a/wcs-functions.php b/wcs-functions.php index 94fc125..f3b745c 100755 --- a/wcs-functions.php +++ b/wcs-functions.php @@ -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 $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() { 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'] ); } /** diff --git a/woocommerce-subscriptions.php b/woocommerce-subscriptions.php index d6415ac..5deb59f 100755 --- a/woocommerce-subscriptions.php +++ b/woocommerce-subscriptions.php @@ -5,7 +5,7 @@ * Description: Sell products and services with recurring payments in your WooCommerce Store. * Author: Prospress Inc. * Author URI: http://prospress.com/ - * Version: 2.3.5 + * Version: 2.3.7 * * WC requires at least: 2.6 * WC tested up to: 3.4 @@ -48,7 +48,7 @@ woothemes_queue_update( plugin_basename( __FILE__ ), '6115e6d7e297b623a169fdcf57 * * @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' ); return; } @@ -170,7 +170,9 @@ class WC_Subscriptions { 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; @@ -502,8 +504,8 @@ class WC_Subscriptions { $is_subscription = WC_Subscriptions_Product::is_subscription( $product_id ); $cart_contains_subscription = WC_Subscriptions_Cart::cart_contains_subscription(); $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; - $canonical_product_id = ( ! empty( $variation_id ) ) ? $variation_id : $product_id; + $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; if ( $is_subscription && 'yes' != get_option( WC_Subscriptions_Admin::$option_prefix . '_multiple_purchase', 'no' ) ) { @@ -710,25 +712,26 @@ class WC_Subscriptions { * @since 1.2 */ public static function woocommerce_inactive_notice() { - if ( current_user_can( 'activate_plugins' ) ) : - if ( ! is_woocommerce_active() ) : ?> -
-

'install-plugin', 'plugin' => 'woocommerce' ), admin_url( 'update.php' ) ), 'install-plugin_woocommerce' ); + if ( current_user_can( 'activate_plugins' ) ) { + $admin_notice_content = ''; - // 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 - 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' ), '', '', '', '', '', '' ); ?> -

-
- -
-

tags, 3$-4$: opening and closing link tags, leads to plugin admin - 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' ), '', '', '', '' ); ?> -

-
- - '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 ) { + require_once( 'includes/admin/class-wcs-admin-notice.php' ); + $notice = new WCS_Admin_Notice( 'error' ); + $notice->set_simple_content( $admin_notice_content ); + $notice->display(); + } + } } /** @@ -1099,6 +1102,26 @@ class WC_Subscriptions { 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 * @@ -1133,14 +1156,8 @@ class WC_Subscriptions { */ public static function is_duplicate_site() { - if ( defined( 'WP_SITEURL' ) ) { - $site_url = WP_SITEURL; - } 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() ); + $wp_site_url_parts = wp_parse_url( self::get_site_url_from_source( 'current_wp_site' ) ); + $wcs_site_url_parts = wp_parse_url( self::get_site_url_from_source( 'subscriptions_install' ) ); if ( ! isset( $wp_site_url_parts['path'] ) && ! isset( $wcs_site_url_parts['path'] ) ) { $paths_match = true; @@ -1197,11 +1214,7 @@ class WC_Subscriptions { */ public static function get_current_sites_duplicate_lock() { - if ( defined( 'WP_SITEURL' ) ) { - $site_url = WP_SITEURL; - } else { - $site_url = get_site_url(); - } + $site_url = self::get_site_url_from_source( 'current_wp_site' ); return substr_replace( $site_url, '_[wc_subscriptions_siteurl]_', strlen( $site_url ) / 2, 0 ); }