Skip to content

Commit

Permalink
Updates to 6.6.2
Browse files Browse the repository at this point in the history
  • Loading branch information
WooCommerce committed Sep 13, 2024
1 parent 072c76a commit ccb5fe3
Show file tree
Hide file tree
Showing 30 changed files with 291 additions and 234 deletions.
11 changes: 11 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
*** WooCommerce Subscriptions Changelog ***

2024-09-13 - version 6.7.0
* Fix: Resolved two issues preventing the correct display of the "Subscription items can no longer be edited." message on the Edit Subscription page.
* Fix: Checks for the existence of `wc_get_page_screen_id` before calling it on `wcs_get_page_screen_id`, and for the admin context before calling `list_table_primary_column` to prevent fatal errors.
* Fix: Blocks the reactivation of a subscription when the end date is in the past.
* Fix: Ensure a subscription's modified date is updated when its related order cache is updated on non-HPOS sites.
* Fix: Ensure trial period form data is set before use to prevent fatal errors when the data is missing.
* Fix: Resolved an error with coupon discount calculations for manual or early renewal orders on stores with tax-inclusive pricing.
* Fix: Add the theme-compatible button class to the switch button on the My Account > Subscription page.
* Dev: Removing the unused method `maybe_remove_formatted_order_total_filter` hooked to `woocommerce_get_formatted_order_total` which was deprecated.
* Dev: Update subscriptions-core to 7.5.0

2024-09-05 - version 6.6.2
* Fix: Prevent errors during checkout when a customer is switching their subscription product and does not require payment.
* Dev: Update subscriptions-core to 7.4.3.
Expand Down
2 changes: 1 addition & 1 deletion includes/switching/class-wc-subscriptions-switcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ public static function print_switch_link( $item_id, $item, $subscription ) {

$switch_url = esc_url( self::get_switch_url( $item_id, $item, $subscription ) );
$switch_text = apply_filters( 'woocommerce_subscriptions_switch_link_text', get_option( WC_Subscriptions_Admin::$option_prefix . '_switch_button_text', __( 'Upgrade or Downgrade', 'woocommerce-subscriptions' ) ), $item_id, $item, $subscription );
$switch_classes = apply_filters( 'woocommerce_subscriptions_switch_link_classes', array( 'wcs-switch-link', 'button' ), $item_id, $item, $subscription );
$switch_classes = apply_filters( 'woocommerce_subscriptions_switch_link_classes', array( 'wcs-switch-link', 'button', wc_wp_theme_get_element_class_name( 'button' ) ), $item_id, $item, $subscription );

$switch_link = sprintf( '<a href="%s" class="%s">%s</a>', $switch_url, implode( ' ', (array) $switch_classes ), $switch_text );

Expand Down
248 changes: 122 additions & 126 deletions languages/woocommerce-subscriptions.pot

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInit7e691db14332db79e94ffb5244979d5e::getLoader();
return ComposerAutoloaderInit0a0744246f082255078926698437a7a5::getLoader();
8 changes: 4 additions & 4 deletions vendor/composer/autoload_real.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// autoload_real.php @generated by Composer

class ComposerAutoloaderInit7e691db14332db79e94ffb5244979d5e
class ComposerAutoloaderInit0a0744246f082255078926698437a7a5
{
private static $loader;

Expand All @@ -24,12 +24,12 @@ public static function getLoader()

require __DIR__ . '/platform_check.php';

spl_autoload_register(array('ComposerAutoloaderInit7e691db14332db79e94ffb5244979d5e', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit0a0744246f082255078926698437a7a5', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit7e691db14332db79e94ffb5244979d5e', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit0a0744246f082255078926698437a7a5', 'loadClassLoader'));

require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit7e691db14332db79e94ffb5244979d5e::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit0a0744246f082255078926698437a7a5::getInitializer($loader));

$loader->register(true);

Expand Down
8 changes: 4 additions & 4 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Composer\Autoload;

class ComposerStaticInit7e691db14332db79e94ffb5244979d5e
class ComposerStaticInit0a0744246f082255078926698437a7a5
{
public static $prefixLengthsPsr4 = array (
'C' =>
Expand Down Expand Up @@ -129,9 +129,9 @@ class ComposerStaticInit7e691db14332db79e94ffb5244979d5e
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit7e691db14332db79e94ffb5244979d5e::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit7e691db14332db79e94ffb5244979d5e::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit7e691db14332db79e94ffb5244979d5e::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit0a0744246f082255078926698437a7a5::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit0a0744246f082255078926698437a7a5::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit0a0744246f082255078926698437a7a5::$classMap;

}, null, ClassLoader::class);
}
Expand Down
14 changes: 7 additions & 7 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,17 +156,17 @@
},
{
"name": "woocommerce/subscriptions-core",
"version": "7.4.3",
"version_normalized": "7.4.3.0",
"version": "7.5.0",
"version_normalized": "7.5.0.0",
"source": {
"type": "git",
"url": "https://github.com/Automattic/woocommerce-subscriptions-core.git",
"reference": "eba9c58a2fd2a65e55c533f24cd20af2084a8265"
"reference": "32bcb16e1a0d87e55214aaff1fa80b45bd1b43df"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Automattic/woocommerce-subscriptions-core/zipball/eba9c58a2fd2a65e55c533f24cd20af2084a8265",
"reference": "eba9c58a2fd2a65e55c533f24cd20af2084a8265",
"url": "https://api.github.com/repos/Automattic/woocommerce-subscriptions-core/zipball/32bcb16e1a0d87e55214aaff1fa80b45bd1b43df",
"reference": "32bcb16e1a0d87e55214aaff1fa80b45bd1b43df",
"shasum": ""
},
"require": {
Expand All @@ -179,7 +179,7 @@
"woocommerce/woocommerce-sniffs": "0.1.0",
"yoast/phpunit-polyfills": "1.1.0"
},
"time": "2024-09-05T02:55:11+00:00",
"time": "2024-09-12T23:46:14+00:00",
"type": "wordpress-plugin",
"extra": {
"phpcodesniffer-search-depth": 2
Expand Down Expand Up @@ -209,7 +209,7 @@
"description": "Sell products and services with recurring payments in your WooCommerce Store.",
"homepage": "https://github.com/Automattic/woocommerce-subscriptions-core",
"support": {
"source": "https://github.com/Automattic/woocommerce-subscriptions-core/tree/7.4.3",
"source": "https://github.com/Automattic/woocommerce-subscriptions-core/tree/7.5.0",
"issues": "https://github.com/Automattic/woocommerce-subscriptions-core/issues"
},
"install-path": "../woocommerce/subscriptions-core"
Expand Down
18 changes: 9 additions & 9 deletions vendor/composer/installed.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php return array(
'root' => array(
'name' => 'woocommerce/woocommerce-subscriptions',
'pretty_version' => 'dev-release/6.6.2',
'version' => 'dev-release/6.6.2',
'reference' => 'dfdcf5705059ca03ecc9c5b2c21910f8c932b082',
'pretty_version' => 'dev-release/6.7.0',
'version' => 'dev-release/6.7.0',
'reference' => '094d1fce371e91c7c3ac11ce7f11eda8f2002eeb',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand Down Expand Up @@ -32,18 +32,18 @@
),
),
'woocommerce/subscriptions-core' => array(
'pretty_version' => '7.4.3',
'version' => '7.4.3.0',
'reference' => 'eba9c58a2fd2a65e55c533f24cd20af2084a8265',
'pretty_version' => '7.5.0',
'version' => '7.5.0.0',
'reference' => '32bcb16e1a0d87e55214aaff1fa80b45bd1b43df',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../woocommerce/subscriptions-core',
'aliases' => array(),
'dev_requirement' => false,
),
'woocommerce/woocommerce-subscriptions' => array(
'pretty_version' => 'dev-release/6.6.2',
'version' => 'dev-release/6.6.2',
'reference' => 'dfdcf5705059ca03ecc9c5b2c21910f8c932b082',
'pretty_version' => 'dev-release/6.7.0',
'version' => 'dev-release/6.7.0',
'reference' => '094d1fce371e91c7c3ac11ce7f11eda8f2002eeb',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand Down
9 changes: 9 additions & 0 deletions vendor/woocommerce/subscriptions-core/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
*** WooCommerce Subscriptions Core Changelog ***

= 7.5.0 - 2024-09-12 =
* Dev - Removing the unused method `maybe_remove_formatted_order_total_filter` hooked to `woocommerce_get_formatted_order_total` which was deprecated.
* Fix - Resolved two issues preventing the correct display of the "Subscription items can no longer be edited." message on the Edit Subscription page.
* Fix - Checks for the existence of `wc_get_page_screen_id` before calling it on `wcs_get_page_screen_id`, and for the admin context before calling `list_table_primary_column` to prevent fatal errors.
* Fix - Blocks the reactivation of a subscription when the end date is in the past.
* Fix - Ensure a subscription's modified date is updated when its related order cache is updated on non-HPOS sites.
* Fix - Ensure trial period form data is set before use to prevent fatal errors when the data is missing.
* Fix - Resolved an error with coupon discount calculations for manual or early renewal orders on stores with tax-inclusive pricing.

= 7.4.3 - 2024-09-05 =
* Fix - Prevent errors during checkout when a customer is switching their subscription product and does not require payment.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,6 @@ public static function init() {

add_action( 'woocommerce_payment_gateways_setting_column_renewals', array( __CLASS__, 'payment_gateways_renewal_support' ) );

// Do not display formatted order total on the Edit Order administration screen
add_filter( 'woocommerce_get_formatted_order_total', __CLASS__ . '::maybe_remove_formatted_order_total_filter', 0, 2 );

add_action( 'woocommerce_payment_gateways_settings', __CLASS__ . '::add_recurring_payment_gateway_information', 10, 1 );

// Change text for when order items cannot be edited
Expand Down Expand Up @@ -536,9 +533,9 @@ public static function save_subscription_meta( $post_id ) {
// Make sure trial period is within allowable range
$subscription_ranges = wcs_get_subscription_ranges();

$max_trial_length = count( $subscription_ranges[ $_POST['_subscription_trial_period'] ] ) - 1;
$max_trial_length = ! empty( $_POST['_subscription_trial_period'] ) ? count( $subscription_ranges[ $_POST['_subscription_trial_period'] ] ) - 1 : 0;

$_POST['_subscription_trial_length'] = absint( $_POST['_subscription_trial_length'] );
$_POST['_subscription_trial_length'] = ! empty( $_POST['_subscription_trial_length'] ) ? absint( $_POST['_subscription_trial_length'] ) : 0;

if ( $_POST['_subscription_trial_length'] > $max_trial_length ) {
$_POST['_subscription_trial_length'] = $max_trial_length;
Expand Down Expand Up @@ -754,9 +751,9 @@ public static function save_product_variation( $variation_id, $index ) {

// Make sure trial period is within allowable range
$subscription_ranges = wcs_get_subscription_ranges();
$max_trial_length = count( $subscription_ranges[ $_POST['variable_subscription_trial_period'][ $index ] ] ) - 1;
$max_trial_length = ! empty( $_POST['variable_subscription_trial_period'][ $index ] ) ? count( $subscription_ranges[ $_POST['variable_subscription_trial_period'][ $index ] ] ) - 1 : 0;

$_POST['variable_subscription_trial_length'][ $index ] = absint( $_POST['variable_subscription_trial_length'][ $index ] );
$_POST['variable_subscription_trial_length'][ $index ] = ! empty( $_POST['variable_subscription_trial_length'][ $index ] ) ? absint( $_POST['variable_subscription_trial_length'][ $index ] ) : 0;

if ( $_POST['variable_subscription_trial_length'][ $index ] > $max_trial_length ) {
$_POST['variable_subscription_trial_length'][ $index ] = $max_trial_length;
Expand Down Expand Up @@ -1829,18 +1826,10 @@ public static function payment_gateways_rewewal_support( $gateway ) {
* Do not display formatted order total on the Edit Order administration screen
*
* @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.5.17
* @deprecated 7.5.0
*/
public static function maybe_remove_formatted_order_total_filter( $formatted_total, $order ) {

// Check if we're on the Edit Order screen - get_current_screen() only exists on admin pages so order of operations matters here
if ( is_admin() && function_exists( 'get_current_screen' ) ) {

$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 );
}
}
wcs_deprecated_function( __METHOD__, '7.5.0' );

return $formatted_total;
}
Expand All @@ -1852,12 +1841,8 @@ public static function maybe_remove_formatted_order_total_filter( $formatted_tot
*/
public static function maybe_attach_gettext_callback() {

if ( is_admin() && function_exists( 'get_current_screen' ) ) {
$screen = get_current_screen();

if ( is_object( $screen ) && 'shop_subscription' === $screen->id ) {
add_filter( 'gettext', array( __CLASS__, 'change_order_item_editable_text' ), 10, 3 );
}
if ( self::is_edit_subscription_page() ) {
add_filter( 'gettext', array( __CLASS__, 'change_order_item_editable_text' ), 10, 3 );
}
}

Expand All @@ -1868,16 +1853,11 @@ public static function maybe_attach_gettext_callback() {
*/
public static function maybe_unattach_gettext_callback() {

if ( is_admin() && function_exists( 'get_current_screen' ) ) {
$screen = get_current_screen();

if ( is_object( $screen ) && 'shop_subscription' === $screen->id ) {
remove_filter( 'gettext', array( __CLASS__, 'change_order_item_editable_text' ), 10 );
}
if ( self::is_edit_subscription_page() ) {
remove_filter( 'gettext', array( __CLASS__, 'change_order_item_editable_text' ), 10 );
}
}


/**
* When subscription items not editable (such as due to the payment gateway not supporting modifications),
* change the text to explain why
Expand All @@ -1892,6 +1872,7 @@ public static function change_order_item_editable_text( $translated_text, $text,
break;

case 'To edit this order change the status back to "Pending"':
case 'To edit this order change the status back to "Pending payment"':
$translated_text = __( 'This subscription is no longer editable because the payment gateway does not allow modification of recurring amounts.', 'woocommerce-subscriptions' );
break;
}
Expand Down Expand Up @@ -1926,7 +1907,7 @@ public static function add_recurring_payment_gateway_information( $settings ) {

array(
// translators: placeholders are opening and closing link tags
'desc' => sprintf( __( 'Payment gateways which don\'t support automatic recurring payments can be used to process %1$smanual subscription renewal payments%2$s.', 'woocommerce-subscriptions' ), '<a href="http://docs.woocommerce.com/document/subscriptions/renewal-process/">', '</a>' ),
'desc' => sprintf( __( 'Payment gateways which don\'t support automatic recurring payments can be used to process %1$smanual subscription renewal payments%2$s.', 'woocommerce-subscriptions' ), '<a href="https://woocommerce.com/document/subscriptions/renewal-process/">', '</a>' ),
'id' => self::$option_prefix . '_payment_gateways_additional',
'type' => 'informational',
),
Expand Down Expand Up @@ -2250,4 +2231,24 @@ public static function maybe_keep_variations( $delete_variations, $product, $fro

return $delete_variations;
}

/**
* Check if the current page is the Edit Subscription page
*
* @return bool True if the current page is the Edit Subscription page
*
* @since 7.5.0
*/
private static function is_edit_subscription_page() {
if ( ! is_admin() || ! function_exists( 'get_current_screen' ) ) {
return false;
}

$screen = get_current_screen();
if ( ! is_object( $screen ) ) {
return false;
}

return wcs_get_page_screen_id( 'shop_subscription' ) === $screen->id;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1186,7 +1186,7 @@ public static function restrict_by_payment_method( $order_type = '' ) {
*/
public function list_table_primary_column( $default, $screen_id ) {

if ( in_array( $screen_id, [ wcs_get_page_screen_id( 'shop_subscription' ), 'edit-shop_subscription' ], true ) ) {
if ( is_admin() && in_array( $screen_id, [ wcs_get_page_screen_id( 'shop_subscription' ), 'edit-shop_subscription' ], true ) ) {
$default = 'order_title';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ private static function set_theme_overrides( &$debug_data ) {
$debug_data['wcs_theme_overrides'] += array(
'mark_icon' => 'warning',
// translators: placeholders are opening/closing tags linking to documentation on outdated templates.
'note' => sprintf( __( '%1$sLearn how to update%2$s', 'woocommerce-subscriptions' ), '<a href="https://docs.woocommerce.com/document/fix-outdated-templates-woocommerce/" target="_blank">', '</a>' ),
'note' => sprintf( __( '%1$sLearn how to update%2$s', 'woocommerce-subscriptions' ), '<a href="https://developer.woocommerce.com/docs/how-to-fix-outdated-woocommerce-templates/" target="_blank">', '</a>' ),
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@
echo sprintf( esc_html_x( '#%s', 'hash before order number', 'woocommerce-subscriptions' ), esc_html( $order_id ) );
?>
<div class="wcs-unknown-order-info-wrapper">
<a href="https://docs.woocommerce.com/document/subscriptions/orders/#section-8">
<?php
// Translators: The %1 placeholder is the translated order relationship ("Parent Order"), %2 placeholder is a <br> HTML tag.
echo wcs_help_tip( sprintf( __( 'This %1$s couldn\'t be loaded from the database. %1$s Click to learn more.', 'woocommerce-subscriptions' ), $relationship, '</br>' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
<a href="https://woocommerce.com/document/subscriptions/orders/#why-are-some-orders-in-the-related-orders-table-not-linking-to-the-order">
<?php // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo wcs_help_tip(
sprintf( // Translators: The %1 placeholder is the translated order relationship ("Parent Order"), %2 placeholder is a <br> HTML tag.
__( 'This %1$s couldn\'t be loaded from the database. %1$s Click to learn more.', 'woocommerce-subscriptions' ),
esc_html( $relationship ),
'</br>'
)
);
?>
</a>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,13 @@ public function can_be_updated_to( $new_status ) {
case 'completed': // core WC order status mapped internally to avoid exceptions
case 'active':
if ( $this->payment_method_supports( 'subscription_reactivation' ) && $this->has_status( 'on-hold' ) ) {
$can_be_updated = true;
// If the subscription's end date is in the past, it cannot be reactivated.
$end_time = $this->get_time( 'end' );
if ( 0 !== $end_time && $end_time < gmdate( 'U' ) ) {
$can_be_updated = false;
} else {
$can_be_updated = true;
}
} elseif ( $this->has_status( 'pending' ) ) {
$can_be_updated = true;
} elseif ( $this->has_status( 'pending-cancel' ) && $this->get_time( 'end' ) > gmdate( 'U' ) && ( $this->is_manual() || ( false === $this->payment_method_supports( 'gateway_scheduled_payments' ) && $this->payment_method_supports( 'subscription_date_changes' ) && $this->payment_method_supports( 'subscription_reactivation' ) ) ) ) {
Expand All @@ -364,7 +370,7 @@ public function can_be_updated_to( $new_status ) {
$can_be_updated = false;
}
break;
case 'pending-cancel' :
case 'pending-cancel':
// Only active subscriptions can be given the "pending cancellation" status, because it is used to account for a prepaid term
if ( $this->payment_method_supports( 'subscription_cancellation' ) ) {
if ( $this->has_status( 'active' ) ) {
Expand Down
Loading

0 comments on commit ccb5fe3

Please sign in to comment.