Skip to content

Commit

Permalink
Updates to 7.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
WooCommerce committed Jan 10, 2025
1 parent 60a125d commit 15b2c61
Show file tree
Hide file tree
Showing 19 changed files with 373 additions and 112 deletions.
10 changes: 10 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
*** WooCommerce Subscriptions Changelog ***

2025-01-10 - version 7.1.0
* Add: Compatibility with WooCommerce's new preview email feature introduced in 9.6.
* Fix: Prevents PHP fatal error when wcs_can_user_renew_early() is called with a non-existent subscription ID.
* Fix: Prevent payment gateways that complete Change Payment requests asynchronously from blocking future attempts to update payment methods for all subscriptions.
* Fix: Resolved an issue that could lead to undefined variable when attempting to send a customer notification email with no order.
* Fix: Prevents the customer's postal code being used as their billing city in the current session, following a change to payment details.
* Dev: Use the subscription's customer ID during the `wcs_can_user_renew_early()` function call when sending customer notification emails.
* Dev: Fix PHP deprecated warnings caused by calling esc_url with null.
* Dev: Update subscriptions-core to 7.9

2024-12-16 - version 7.0.0
* Fix: Prevent failing non-recent renewal order from suspending the subscription and marking the most recent renewal order as failed.
* Fix: Use block theme-styled buttons for subscription and related-orders actions on My Account pages.
Expand Down
18 changes: 9 additions & 9 deletions includes/early-renewal/wcs-early-renewal-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ function wcs_can_user_renew_early( $subscription, $user_id = 0 ) {
! boolval( apply_filters( 'wcs_allow_synced_product_early_renewal', false, $subscription ) )
) {
$reason = 'subscription_contains_synced_product';
}

// Make sure all line items still exist.
foreach ( $subscription->get_items() as $line_item ) {
$product = wc_get_product( wcs_get_canonical_product_id( $line_item ) );

if ( false === $product ) {
$reason = 'line_item_no_longer_exists';
break;
} else {
// Make sure all line items still exist.
foreach ( $subscription->get_items() as $line_item ) {
$product = wc_get_product( wcs_get_canonical_product_id( $line_item ) );

if ( false === $product ) {
$reason = 'line_item_no_longer_exists';
break;
}
}
}

Expand Down
100 changes: 50 additions & 50 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 ComposerAutoloaderInit8696b4ce4243ef30c3ff87b4ec42d61a::getLoader();
return ComposerAutoloaderInit1a0806ecf77df05bfe8e09cca6dc9f00::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 ComposerAutoloaderInit8696b4ce4243ef30c3ff87b4ec42d61a
class ComposerAutoloaderInit1a0806ecf77df05bfe8e09cca6dc9f00
{
private static $loader;

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

require __DIR__ . '/platform_check.php';

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

require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit8696b4ce4243ef30c3ff87b4ec42d61a::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit1a0806ecf77df05bfe8e09cca6dc9f00::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 ComposerStaticInit8696b4ce4243ef30c3ff87b4ec42d61a
class ComposerStaticInit1a0806ecf77df05bfe8e09cca6dc9f00
{
public static $prefixLengthsPsr4 = array (
'C' =>
Expand Down Expand Up @@ -129,9 +129,9 @@ class ComposerStaticInit8696b4ce4243ef30c3ff87b4ec42d61a
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit8696b4ce4243ef30c3ff87b4ec42d61a::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit8696b4ce4243ef30c3ff87b4ec42d61a::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit8696b4ce4243ef30c3ff87b4ec42d61a::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit1a0806ecf77df05bfe8e09cca6dc9f00::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit1a0806ecf77df05bfe8e09cca6dc9f00::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit1a0806ecf77df05bfe8e09cca6dc9f00::$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.8.0",
"version_normalized": "7.8.0.0",
"version": "7.9.0",
"version_normalized": "7.9.0.0",
"source": {
"type": "git",
"url": "https://github.com/Automattic/woocommerce-subscriptions-core.git",
"reference": "14e7b3d5df82a0f4d4942b8119e85087e4863a65"
"reference": "36629b90e52bf1137fd4f7580414cea7e42ce920"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Automattic/woocommerce-subscriptions-core/zipball/14e7b3d5df82a0f4d4942b8119e85087e4863a65",
"reference": "14e7b3d5df82a0f4d4942b8119e85087e4863a65",
"url": "https://api.github.com/repos/Automattic/woocommerce-subscriptions-core/zipball/36629b90e52bf1137fd4f7580414cea7e42ce920",
"reference": "36629b90e52bf1137fd4f7580414cea7e42ce920",
"shasum": ""
},
"require": {
Expand All @@ -179,7 +179,7 @@
"woocommerce/woocommerce-sniffs": "0.1.0",
"yoast/phpunit-polyfills": "1.1.0"
},
"time": "2024-12-16T23:11:09+00:00",
"time": "2025-01-10T00:22:55+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.8.0",
"source": "https://github.com/Automattic/woocommerce-subscriptions-core/tree/7.9.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/7.0.0',
'version' => 'dev-release/7.0.0',
'reference' => '71fd6cf0194bb9921cb70197177e77436a8fe3d8',
'pretty_version' => 'dev-release/7.1.0',
'version' => 'dev-release/7.1.0',
'reference' => '4cd67267efc98d376b5db58714feb586f8d2be41',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand Down Expand Up @@ -32,18 +32,18 @@
),
),
'woocommerce/subscriptions-core' => array(
'pretty_version' => '7.8.0',
'version' => '7.8.0.0',
'reference' => '14e7b3d5df82a0f4d4942b8119e85087e4863a65',
'pretty_version' => '7.9.0',
'version' => '7.9.0.0',
'reference' => '36629b90e52bf1137fd4f7580414cea7e42ce920',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../woocommerce/subscriptions-core',
'aliases' => array(),
'dev_requirement' => false,
),
'woocommerce/woocommerce-subscriptions' => array(
'pretty_version' => 'dev-release/7.0.0',
'version' => 'dev-release/7.0.0',
'reference' => '71fd6cf0194bb9921cb70197177e77436a8fe3d8',
'pretty_version' => 'dev-release/7.1.0',
'version' => 'dev-release/7.1.0',
'reference' => '4cd67267efc98d376b5db58714feb586f8d2be41',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand Down
8 changes: 8 additions & 0 deletions vendor/woocommerce/subscriptions-core/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
*** WooCommerce Subscriptions Core Changelog ***

= 7.9.0 - 2025-01-10 =
* Add - Compatibility with WooCommerce's new preview email feature introduced in 9.6.
* Fix - Prevent payment gateways that complete Change Payment requests asynchronously from blocking future attempts to update payment methods for all subscriptions.
* Fix - Resolved an issue that could lead to undefined variable when attempting to send a customer notification email with no order.
* Fix - Prevents the customer's postal code being used as their billing city in the current session, following a change to payment details.
* Dev - Use the subscription's customer ID during the `wcs_can_user_renew_early()` function call when sending customer notification emails.
* Dev - Fix PHP deprecated warnings caused by calling esc_url with null.

= 7.8.0 - 2024-12-16 =
* Fix - Prevent failing non-recent renewal order from suspending the subscription and marking the most recent renewal order as failed.
* Fix - Use block theme-styled buttons for subscription and related-orders actions on My Account pages.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public static function change_payment_method_via_pay_shortcode() {
$subscription_billing_country = $subscription->get_billing_country();
$subscription_billing_state = $subscription->get_billing_state();
$subscription_billing_postcode = $subscription->get_billing_postcode();
$subscription_billing_city = $subscription->get_billing_postcode();
$subscription_billing_city = $subscription->get_billing_city();

// Set customer location to order location
if ( $subscription_billing_country ) {
Expand All @@ -314,6 +314,10 @@ public static function change_payment_method_via_pay_shortcode() {
WC()->customer->$setter( $subscription_billing_city );
}

// For each new change payment request, make sure we delete the delayed update payment method meta if it exists.
$subscription->delete_meta_data( '_delayed_update_payment_method_all' );
$subscription->save_meta_data();

// Update payment method
$new_payment_method = wc_clean( $_POST['payment_method'] );
$notice = $subscription->has_payment_gateway() ? __( 'Payment method updated.', 'woocommerce-subscriptions' ) : __( 'Payment method added.', 'woocommerce-subscriptions' );
Expand Down Expand Up @@ -434,6 +438,9 @@ public static function update_all_payment_methods_from_subscription( $subscripti
continue;
}

// Clear any stale _delayed_update_payment_method_all meta existing on the users other subscriptions if it exists.
$user_subscription->delete_meta_data( '_delayed_update_payment_method_all' );

self::update_payment_method( $user_subscription, $new_payment_method, $payment_meta_table );

$user_subscription->set_requires_manual_renewal( false );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class WC_Subscriptions_Core_Plugin {
* The version of subscriptions-core library.
* @var string
*/
protected $library_version = '7.8.0'; // WRCS: DEFINED_VERSION.
protected $library_version = '7.9.0'; // WRCS: DEFINED_VERSION.

/**
* The subscription scheduler instance.
Expand Down Expand Up @@ -200,6 +200,7 @@ public function init_version_dependant_classes() {
WCS_My_Account_Payment_Methods::init();
WCS_My_Account_Auto_Renew_Toggle::init();
new WCS_Deprecated_Filter_Hooks();
new WC_Subscriptions_Email_Preview();

// On some loads the WC_Query doesn't exist. To avoid a fatal, only load the WCS_Query class when it exists.
if ( class_exists( 'WC_Query' ) ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@ class WC_Subscriptions_Email_Notifications {
*/
public static $switch_setting_string = '_customer_notifications_enabled';

/**
* List of subscription notification email classes.
*
* @var array
*/
public static $email_classes = [
'WCS_Email_Customer_Notification_Manual_Trial_Expiration' => true,
'WCS_Email_Customer_Notification_Auto_Trial_Expiration' => true,
'WCS_Email_Customer_Notification_Manual_Renewal' => true,
'WCS_Email_Customer_Notification_Auto_Renewal' => true,
'WCS_Email_Customer_Notification_Subscription_Expiration' => true,
];

/**
* Init.
*/
Expand Down Expand Up @@ -107,12 +120,9 @@ public static function set_notification_settings_update_time() {
* Add Subscriptions notifications' email classes.
*/
public static function add_emails( $email_classes ) {

$email_classes['WCS_Email_Customer_Notification_Auto_Trial_Expiration'] = new WCS_Email_Customer_Notification_Auto_Trial_Expiration();
$email_classes['WCS_Email_Customer_Notification_Manual_Trial_Expiration'] = new WCS_Email_Customer_Notification_Manual_Trial_Expiration();
$email_classes['WCS_Email_Customer_Notification_Subscription_Expiration'] = new WCS_Email_Customer_Notification_Subscription_Expiration();
$email_classes['WCS_Email_Customer_Notification_Manual_Renewal'] = new WCS_Email_Customer_Notification_Manual_Renewal();
$email_classes['WCS_Email_Customer_Notification_Auto_Renewal'] = new WCS_Email_Customer_Notification_Auto_Renewal();
foreach ( self::$email_classes as $email_class => $_ ) {
$email_classes[ $email_class ] = new $email_class();
}

return $email_classes;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,24 @@
*/
class WC_Subscriptions_Email {

/**
* List of all core subscription email classes.
*
* @var array
*/
public static $email_classes = [
'WCS_Email_New_Renewal_Order' => true,
'WCS_Email_New_Switch_Order' => true,
'WCS_Email_Processing_Renewal_Order' => true,
'WCS_Email_Completed_Renewal_Order' => true,
'WCS_Email_Customer_On_Hold_Renewal_Order' => true,
'WCS_Email_Completed_Switch_Order' => true,
'WCS_Email_Customer_Renewal_Invoice' => true,
'WCS_Email_Cancelled_Subscription' => true,
'WCS_Email_Expired_Subscription' => true,
'WCS_Email_On_Hold_Subscription' => true,
];

/**
* Bootstraps the class and hooks required actions & filters.
*
Expand All @@ -36,16 +54,9 @@ public static function init() {
* @since 1.0.0 - Migrated from WooCommerce Subscriptions v1.4
*/
public static function add_emails( $email_classes ) {
$email_classes['WCS_Email_New_Renewal_Order'] = new WCS_Email_New_Renewal_Order();
$email_classes['WCS_Email_New_Switch_Order'] = new WCS_Email_New_Switch_Order();
$email_classes['WCS_Email_Processing_Renewal_Order'] = new WCS_Email_Processing_Renewal_Order();
$email_classes['WCS_Email_Completed_Renewal_Order'] = new WCS_Email_Completed_Renewal_Order();
$email_classes['WCS_Email_Customer_On_Hold_Renewal_Order'] = new WCS_Email_Customer_On_Hold_Renewal_Order();
$email_classes['WCS_Email_Completed_Switch_Order'] = new WCS_Email_Completed_Switch_Order();
$email_classes['WCS_Email_Customer_Renewal_Invoice'] = new WCS_Email_Customer_Renewal_Invoice();
$email_classes['WCS_Email_Cancelled_Subscription'] = new WCS_Email_Cancelled_Subscription();
$email_classes['WCS_Email_Expired_Subscription'] = new WCS_Email_Expired_Subscription();
$email_classes['WCS_Email_On_Hold_Subscription'] = new WCS_Email_On_Hold_Subscription();
foreach ( self::$email_classes as $email_class => $_ ) {
$email_classes[ $email_class ] = new $email_class();
}

return $email_classes;
}
Expand Down Expand Up @@ -306,11 +317,17 @@ public static function order_details( $order, $sent_to_admin = false, $plain_tex
public static function subscription_details( $subscriptions, $order = null, $sent_to_admin = false, $plain_text = false, $skip_my_account_link = false ) {
$template = ( $plain_text ) ? 'emails/plain/subscription-info.php' : 'emails/subscription-info.php';

if ( ! is_array( $subscriptions ) ) {
$subscriptions = [ $subscriptions ];
}

$order = ! $order && ! empty( $subscriptions ) ? reset( $subscriptions )->get_parent() : $order;

wc_get_template(
$template,
array(
'order' => ! $order ? $subscription->get_parent() : $order,
'subscriptions' => is_array( $subscriptions ) ? $subscriptions : [ $subscriptions ],
'order' => $order,
'subscriptions' => $subscriptions,
'is_admin_email' => $sent_to_admin,
'skip_my_account_link' => $skip_my_account_link,
),
Expand Down
Loading

0 comments on commit 15b2c61

Please sign in to comment.