This commit is contained in:
Prospress Inc
2019-08-12 13:50:11 +02:00
committed by Remco Tolsma
parent 1a334c1ead
commit 42ae80fc42
16 changed files with 1588 additions and 37 deletions

30
.github/ISSUE_TEMPLATE/Bug_report.md vendored Executable file
View File

@@ -0,0 +1,30 @@
---
name: "Bug report"
about: Report a bug if something isn't working as expected in Subscriptions
---
### Describe the bug
<!-- A clear and concise description of what the bug is. Please be as descriptive as possible; issues lacking detail, or for any other reason than to report a bug, may be closed without action.-->
### To reproduce
<!-- Describe the steps to reproduce the behavior -->
1.
1.
1.
**Screenshots**
<!-- If applicable, add screenshots to help explain your problem.-->
### Expected behavior
<!-- A clear and concise description of what you expected to happen.-->
### Additional details
<!--Here you can include any additional details you think might be helpful.-->
<!--Ticket numbers/links, plugin versions, system statuses etc.-->
<details><summary>System status</summary>
```
<!--If applicable, paste the system status here. Please ensure you redact or remove any identifying information. -->
```
</details>

17
.github/ISSUE_TEMPLATE/Enhancement.md vendored Executable file
View File

@@ -0,0 +1,17 @@
---
name: "New Enhancement"
about: ""
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Proposed approach**
Describe the proposed approach for the enhancement.

3
.github/config.yml vendored Executable file
View File

@@ -0,0 +1,3 @@
# helPR bot config. https://probot.github.io/apps/helpr/
helpr:
opened: 'hasPR'

28
.github/pull_request_template.md vendored Executable file
View File

@@ -0,0 +1,28 @@
<!-- Reference the source of this Pull Request. -->
<!-- Remove any which are not applicable. -->
**Issue**: #
**Ticket**:
**Slack thread**:
---
### Description
<!-- Describe the changes made in this Pull Request and the reason for these changes. -->
### Steps to test:
<!-- Describe the steps to replicate the issue and confirm the fix -->
<!-- Try to include as many details as possible. -->
<!-- Please include screenshots. If you work with Prospress, sign-up for CloudApp via https://prospress.cl.ly -->
1.
1.
1.
### Documentation
<!-- Will this change require new documentation or changes to existing documentation? -->
<!-- A good way to answer it is to ask: will more than one customer ever need to know about this? -->
- [ ] This PR needs documentation (has the "status:needs-docs" label).
<!-- For an extra 💯 include further details about which change requires documentation -->
Closes # .

View File

@@ -1,5 +1,11 @@
*** WooCommerce Subscriptions Changelog *** *** WooCommerce Subscriptions Changelog ***
2019.07.04 - version 2.5.7
* Fix: Check for any free shipping which has its requirements met - not just the first one. PR#3329
* Fix: Fix un-purchasability issues with limited subscriptions in manual renewal carts. PR#3358
* Tweak: Update email address to create support admin user with. PR#3363
* Tweak: Update the plugin headers to include Automattic. PR#3365
2019.05.30 - version 2.5.6 2019.05.30 - version 2.5.6
* Fix: Exclude core order properties from the meta copied from the subscription to early renewal orders. #PR3331 * Fix: Exclude core order properties from the meta copied from the subscription to early renewal orders. #PR3331
* Tweak: Add the 'is-active' class to My Account > My Subscription menu item when user is on View Subscription page. PR#3328 * Tweak: Add the 'is-active' class to My Account > My Subscription menu item when user is on View Subscription page. PR#3328

16
composer.json Executable file
View File

@@ -0,0 +1,16 @@
{
"name": "prospress/woocommerce-subscriptions",
"description": "Sell products and services with recurring payments in your WooCommerce Store.",
"homepage": "http://www.woocommerce.com/products/woocommerce-subscriptions/",
"type": "wordpress-plugin",
"license": "GPL-2.0+",
"require": {
"composer/installers": "~1.2"
},
"config": {
"vendor-dir": "includes/libraries"
},
"require-dev": {
"phpunit/phpunit": "^4.5"
}
}

1252
composer.lock generated Executable file

File diff suppressed because it is too large Load Diff

View File

@@ -111,14 +111,26 @@ class WC_Subscriptions_Cart {
// Validate chosen recurring shipping methods // Validate chosen recurring shipping methods
add_action( 'woocommerce_after_checkout_validation', __CLASS__ . '::validate_recurring_shipping_methods' ); add_action( 'woocommerce_after_checkout_validation', __CLASS__ . '::validate_recurring_shipping_methods' );
// WooCommerce determines if free shipping is available using the WC->cart total and coupons, we need to recalculate its availability when obtaining shipping methods for a recurring cart
add_filter( 'woocommerce_shipping_free_shipping_is_available', __CLASS__ . '::maybe_recalculate_shipping_method_availability', 10, 2 );
add_filter( 'woocommerce_add_to_cart_handler', __CLASS__ . '::add_to_cart_handler', 10, 2 ); add_filter( 'woocommerce_add_to_cart_handler', __CLASS__ . '::add_to_cart_handler', 10, 2 );
add_action( 'woocommerce_cart_calculate_fees', __CLASS__ . '::apply_recurring_fees', 1000, 1 ); add_action( 'woocommerce_cart_calculate_fees', __CLASS__ . '::apply_recurring_fees', 1000, 1 );
add_action( 'woocommerce_checkout_update_order_review', __CLASS__ . '::update_chosen_shipping_methods' ); add_action( 'woocommerce_checkout_update_order_review', __CLASS__ . '::update_chosen_shipping_methods' );
add_action( 'plugins_loaded', array( __CLASS__, 'attach_dependant_hooks' ) );
}
/**
* Attach dependant callbacks.
*
* @since 2.5.6
*/
public static function attach_dependant_hooks() {
// WooCommerce determines if free shipping is available using the WC->cart total and coupons, we need to recalculate its availability when obtaining shipping methods for a recurring cart
if ( WC_Subscriptions::is_woocommerce_pre( '3.2' ) ) {
add_filter( 'woocommerce_shipping_free_shipping_is_available', array( __CLASS__, 'maybe_recalculate_shipping_method_availability' ), 10, 2 );
} else {
add_filter( 'woocommerce_shipping_free_shipping_is_available', array( __CLASS__, 'recalculate_shipping_method_availability' ), 10, 3 );
}
} }
/** /**
@@ -1275,23 +1287,64 @@ class WC_Subscriptions_Cart {
*/ */
public static function maybe_recalculate_shipping_method_availability( $is_available, $package ) { public static function maybe_recalculate_shipping_method_availability( $is_available, $package ) {
if ( isset( $package['recurring_cart_key'] ) && isset( self::$cached_recurring_cart ) && $package['recurring_cart_key'] == self::$cached_recurring_cart->recurring_cart_key ) { if ( ! isset( $package['recurring_cart_key'], self::$cached_recurring_cart ) || $package['recurring_cart_key'] !== self::$cached_recurring_cart->recurring_cart_key ) {
return $is_available;
}
if ( ! WC_Subscriptions::is_woocommerce_pre( '3.2' ) ) {
wcs_doing_it_wrong( __METHOD__, 'This method should no longer be used on WC 3.2.0 and newer. Use WC_Subscriptions_Cart::recalculate_shipping_method_availability() and pass the specific shipping method as the third parameter instead.', '2.5.6' );
}
// Take a copy of the WC global cart object so we can temporarily set it to base shipping method availability on the cached recurring cart
$global_cart = WC()->cart;
WC()->cart = self::$cached_recurring_cart;
$shipping_methods = WC()->shipping->get_shipping_methods();
$is_available = false;
remove_filter( 'woocommerce_shipping_free_shipping_is_available', __METHOD__ );
foreach ( $shipping_methods as $shipping_method ) {
if ( 'free_shipping' === $shipping_method->id && $shipping_method->get_instance_id() && $shipping_method->is_available( $package ) ) {
$is_available = true;
break;
}
}
add_filter( 'woocommerce_shipping_free_shipping_is_available', __METHOD__, 10, 2 );
WC()->cart = $global_cart;
return $is_available;
}
/**
* Calculates whether a shipping method is available for the recurring cart.
*
* By default WooCommerce core checks the initial cart for shipping method availability. For recurring carts,
* shipping method availability is based whether the recurring total and coupons meet the requirements.
*
* @since 2.5.6
*
* @param bool $is_available Whether the shipping method is available or not.
* @param array $package a shipping package.
* @param WC_Shipping_Method $shipping_method An instance of a shipping method.
* @return bool Whether the shipping method is available for the recurring cart or not.
*/
public static function recalculate_shipping_method_availability( $is_available, $package, $shipping_method ) {
if ( ! isset( $package['recurring_cart_key'], self::$cached_recurring_cart ) || $package['recurring_cart_key'] !== self::$cached_recurring_cart->recurring_cart_key ) {
return $is_available;
}
// Take a copy of the WC global cart object so we can temporarily set it to base shipping method availability on the cached recurring cart // Take a copy of the WC global cart object so we can temporarily set it to base shipping method availability on the cached recurring cart
$global_cart = WC()->cart; $global_cart = WC()->cart;
WC()->cart = self::$cached_recurring_cart; WC()->cart = self::$cached_recurring_cart;
foreach ( WC()->shipping->get_shipping_methods() as $shipping_method ) {
if ( $shipping_method->id == 'free_shipping' ) {
remove_filter( 'woocommerce_shipping_free_shipping_is_available', __METHOD__ ); remove_filter( 'woocommerce_shipping_free_shipping_is_available', __METHOD__ );
$is_available = $shipping_method->is_available( $package ); $is_available = $shipping_method->is_available( $package );
add_filter( 'woocommerce_shipping_free_shipping_is_available', __METHOD__, 10, 2 ); add_filter( 'woocommerce_shipping_free_shipping_is_available', __METHOD__, 10, 3 );
break;
}
}
// Restore the global cart object.
WC()->cart = $global_cart; WC()->cart = $global_cart;
}
return $is_available; return $is_available;
} }

View File

@@ -20,7 +20,7 @@ class WCS_Limiter {
add_action( 'woocommerce_product_options_advanced', __CLASS__ . '::admin_edit_product_fields' ); add_action( 'woocommerce_product_options_advanced', __CLASS__ . '::admin_edit_product_fields' );
// Only attach limited subscription purchasability logic on the front end. // Only attach limited subscription purchasability logic on the front end.
if ( ! is_admin() ) { if ( wcs_is_frontend_request() ) {
add_filter( 'woocommerce_subscription_is_purchasable', __CLASS__ . '::is_purchasable_switch', 12, 2 ); add_filter( 'woocommerce_subscription_is_purchasable', __CLASS__ . '::is_purchasable_switch', 12, 2 );
add_filter( 'woocommerce_subscription_variation_is_purchasable', __CLASS__ . '::is_purchasable_switch', 12, 2 ); add_filter( 'woocommerce_subscription_variation_is_purchasable', __CLASS__ . '::is_purchasable_switch', 12, 2 );
add_filter( 'woocommerce_subscription_is_purchasable', __CLASS__ . '::is_purchasable_renewal', 12, 2 ); add_filter( 'woocommerce_subscription_is_purchasable', __CLASS__ . '::is_purchasable_renewal', 12, 2 );

View File

@@ -21,7 +21,7 @@ if ( ! defined( 'ABSPATH' ) ) {
<p><?php <p><?php
// translators: $1 and $2 are opening and closing link tags, respectively. // translators: $1 and $2 are opening and closing link tags, respectively.
printf( printf(
esc_html__( 'To resolve this as quickly as possible, please create a %1$stemporary administrator account%2$s with the user email support@prospress.com.', 'woocommerce-subscriptions' ), esc_html__( 'To resolve this as quickly as possible, please create a %1$stemporary administrator account%2$s with the user email woologin@woocommerce.com.', 'woocommerce-subscriptions' ),
'<a href="https://docs.woocommerce.com/document/create-new-admin-account-wordpress/" target="_blank">', '<a href="https://docs.woocommerce.com/document/create-new-admin-account-wordpress/" target="_blank">',
'</a>' '</a>'
);?> );?>

31
includes/libraries/readme.md Executable file
View File

@@ -0,0 +1,31 @@
# 3rd-Party Libraries
Code in this directory is pulled in from other sources. It is also used *instead of* a `vendor/` directory with Composer.
The libraries and files that should be tracked in Git are the following:
* `action-scheduler/` &ndash; Links to Prospress/action-scheduler
* `class-wc-datetime.php` &ndash; A copy of the `WC_DateTime`, for compatibility reasons.
## Action Scheduler
The Action scheduler library has been incorporated into WooCommerce Subscriptions as a Git Subtree.
### Setup
To set up Action Scheduler as a subtree in your local copy of Subscriptions, run the following command from the root of the Subscriptions directory:
```bash
git remote add subtree-action-scheduler https://github.com/Prospress/action-scheduler.git
```
### Updating
Whenever Action Scheduler is updated, the updated version will need to be pulled into Subscriptions. This can be done with the following two commands:
```bash
git fetch subtree-action-scheduler
git subtree pull --prefix includes/libraries/action-scheduler subtree-action-scheduler <BRANCH> --squash
```
In the command above, `<BRANCH>` should be replaced with either `master`, or a tag representing the latest release.

View File

@@ -485,3 +485,52 @@ function wcs_update_settings_option( $settings_api, $key, $value ) {
return update_option( $settings_api->get_option_key(), apply_filters( 'woocommerce_settings_api_sanitized_fields_' . $settings_api->id, $settings_api->settings ), 'yes' ); return update_option( $settings_api->get_option_key(), apply_filters( 'woocommerce_settings_api_sanitized_fields_' . $settings_api->id, $settings_api->settings ), 'yes' );
} }
} }
/**
* Determines if the request is a non-legacy REST API request.
*
* This function is a compatibility wrapper for WC()->is_rest_api_request() which was introduced in WC 3.6.
*
* @since 2.5.7
*
* @return bool True if it's a REST API request, false otherwise.
*/
function wcs_is_rest_api_request() {
if ( function_exists( 'WC' ) && is_callable( array( WC(), 'is_rest_api_request' ) ) ) {
return WC()->is_rest_api_request();
}
if ( empty( $_SERVER['REQUEST_URI'] ) ) {
return false;
}
$rest_prefix = trailingslashit( rest_get_url_prefix() );
$is_rest_api_request = ( false !== strpos( $_SERVER['REQUEST_URI'], $rest_prefix ) );
return apply_filters( 'woocommerce_is_rest_api_request', $is_rest_api_request );
}
/**
* Determines whether the current request is a WordPress cron request.
*
* This function is a compatibility wrapper for wp_doing_cron() which was introduced in WP 4.8.
*
* @since 2.5.7
*
* @return bool True if it's a WordPress cron request, false otherwise.
*/
function wcs_doing_cron() {
return function_exists( 'wp_doing_cron' ) ? wp_doing_cron() : defined( 'DOING_CRON' ) && DOING_CRON;
}
/**
* Determines whether the current request is a WordPress Ajax request.
*
* @since 2.5.7
*
* @return bool True if it's a WordPress Ajax request, false otherwise.
*/
function wcs_doing_ajax() {
return function_exists( 'wp_doing_ajax' ) ? wp_doing_ajax() : defined( 'DOING_AJAX' ) && DOING_AJAX;
}

View File

@@ -232,3 +232,16 @@ function wcs_get_minor_version_string( $version ) {
return $version_parts[0] . '.' . $version_parts[1]; return $version_parts[0] . '.' . $version_parts[1];
} }
/**
* Determines if the current request is for the frontend.
*
* The logic in this function is based off WooCommerce::is_request( 'frontend' ).
*
* @since 2.5.7
*
* @return bool True if it's a frontend request, false otherwise.
*/
function wcs_is_frontend_request() {
return ( ! is_admin() || wcs_doing_ajax() ) && ! wcs_doing_cron() && ! wcs_is_rest_api_request();
}

View File

@@ -1,11 +1,11 @@
# Copyright (C) 2019 Prospress Inc. # Copyright (C) 2019 Automattic
# This file is distributed under the same license as the WooCommerce Subscriptions package. # This file is distributed under the same license as the WooCommerce Subscriptions package.
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: WooCommerce Subscriptions 2.5.6\n" "Project-Id-Version: WooCommerce Subscriptions 2.5.7\n"
"Report-Msgid-Bugs-To: " "Report-Msgid-Bugs-To: "
"https://github.com/Prospress/woocommerce-subscriptions/issues\n" "https://github.com/Prospress/woocommerce-subscriptions/issues\n"
"POT-Creation-Date: 2019-05-30 20:02:46+00:00\n" "POT-Creation-Date: 2019-07-04 13:25:48+00:00\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n" "Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
@@ -1792,21 +1792,21 @@ msgstr ""
msgid "Update the %1$s used for %2$sall%3$s of my active subscriptions" msgid "Update the %1$s used for %2$sall%3$s of my active subscriptions"
msgstr "" msgstr ""
#: includes/class-wc-subscriptions-cart.php:932 #: includes/class-wc-subscriptions-cart.php:944
msgid "Please enter a valid postcode/ZIP." msgid "Please enter a valid postcode/ZIP."
msgstr "" msgstr ""
#: includes/class-wc-subscriptions-cart.php:1090 #: includes/class-wc-subscriptions-cart.php:1102
msgid "" msgid ""
"That subscription product can not be added to your cart as it already " "That subscription product can not be added to your cart as it already "
"contains a subscription renewal." "contains a subscription renewal."
msgstr "" msgstr ""
#: includes/class-wc-subscriptions-cart.php:1178 #: includes/class-wc-subscriptions-cart.php:1190
msgid "Invalid recurring shipping method." msgid "Invalid recurring shipping method."
msgstr "" msgstr ""
#: includes/class-wc-subscriptions-cart.php:2016 #: includes/class-wc-subscriptions-cart.php:2069
msgid "now" msgid "now"
msgstr "" msgstr ""
@@ -3359,7 +3359,7 @@ msgstr ""
#. translators: $1 and $2 are opening and closing link tags, respectively. #. translators: $1 and $2 are opening and closing link tags, respectively.
msgid "" msgid ""
"To resolve this as quickly as possible, please create a %1$stemporary " "To resolve this as quickly as possible, please create a %1$stemporary "
"administrator account%2$s with the user email support@prospress.com." "administrator account%2$s with the user email woologin@woocommerce.com."
msgstr "" msgstr ""
#: includes/gateways/paypal/includes/templates/html-ipn-failure-notice.php:29 #: includes/gateways/paypal/includes/templates/html-ipn-failure-notice.php:29
@@ -5087,11 +5087,11 @@ msgid ""
msgstr "" msgstr ""
#. Author of the plugin/theme #. Author of the plugin/theme
msgid "Prospress Inc." msgid "Automattic"
msgstr "" msgstr ""
#. Author URI of the plugin/theme #. Author URI of the plugin/theme
msgid "https://prospress.com/" msgid "https://woocommerce.com/"
msgstr "" msgstr ""
#: includes/admin/class-wc-subscriptions-admin.php:280 #: includes/admin/class-wc-subscriptions-admin.php:280

View File

@@ -3,15 +3,15 @@
* Plugin Name: WooCommerce Subscriptions * Plugin Name: WooCommerce Subscriptions
* Plugin URI: https://www.woocommerce.com/products/woocommerce-subscriptions/ * Plugin URI: https://www.woocommerce.com/products/woocommerce-subscriptions/
* Description: Sell products and services with recurring payments in your WooCommerce Store. * Description: Sell products and services with recurring payments in your WooCommerce Store.
* Author: Prospress Inc. * Author: Automattic
* Author URI: https://prospress.com/ * Author URI: https://woocommerce.com/
* Version: 2.5.6 * Version: 2.5.7
* *
* WC requires at least: 3.0 * WC requires at least: 3.0
* WC tested up to: 3.6 * WC tested up to: 3.6
* Woo: 27147:6115e6d7e297b623a169fdcf5728b224 * Woo: 27147:6115e6d7e297b623a169fdcf5728b224
* *
* Copyright 2017 Prospress, Inc. (email : freedoms@prospress.com) * Copyright 2019 WooCommerce
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -27,7 +27,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
* @package WooCommerce Subscriptions * @package WooCommerce Subscriptions
* @author Prospress Inc. * @author Automattic.
* @since 1.0 * @since 1.0
*/ */
@@ -113,7 +113,7 @@ class WC_Subscriptions {
public static $plugin_file = __FILE__; public static $plugin_file = __FILE__;
public static $version = '2.5.6'; public static $version = '2.5.7';
public static $wc_minimum_supported_version = '3.0'; public static $wc_minimum_supported_version = '3.0';

53
wpml-config.xml Executable file
View File

@@ -0,0 +1,53 @@
<wpml-config>
<admin-texts>
<key name="woocommerce_myaccount_subscriptions_endpoint" />
<key name="woocommerce_myaccount_view_subscription_endpoint" />
<key name="woocommerce_subscriptions_add_to_cart_button_text" />
<key name="woocommerce_subscriptions_order_button_text" />
<key name="woocommerce_subscriptions_switch_button_text" />
<key name="woocommerce_new_renewal_order_settings">
<key name="subject" />
<key name="heading" />
</key>
<key name="woocommerce_customer_completed_renewal_order_settings">
<key name="subject" />
<key name="heading" />
</key>
<key name="woocommerce_customer_completed_switch_order_settings">
<key name="subject" />
<key name="heading" />
</key>
<key name="woocommerce_customer_renewal_invoice_settings">
<key name="subject" />
<key name="heading" />
</key>
<key name="woocommerce_cancelled_subscription_settings">
<key name="subject" />
<key name="heading" />
</key>
<key name="woocommerce_expired_subscription_settings">
<key name="subject" />
<key name="heading" />
</key>
<key name="woocommerce_suspended_subscription_settings">
<key name="subject" />
<key name="heading" />
</key>
<key name="woocommerce_customer_payment_retry_settings">
<key name="subject" />
<key name="heading" />
</key>
<key name="woocommerce_payment_retry_settings">
<key name="subject" />
<key name="heading" />
</key>
<key name="woocommerce_new_renewal_order_settings">
<key name="subject" />
<key name="heading" />
</key>
<key name="woocommerce_new_renewal_order_settings">
<key name="subject" />
<key name="heading" />
</key>
</admin-texts>
</wpml-config>