diff --git a/changelog.txt b/changelog.txt index a5947dd..153a4e5 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,8 @@ *** WooCommerce Subscriptions Changelog *** +2024-06-28 - version 6.4.1 +* Fix: Resolved errors preventing subscription-related webhooks from sending on WC 9.0 stores. + 2024-06-13 - version 6.4.0 * Add: New WP CLI support to manage subscriptions via command line. * Add: Introduce wc/v2 subscription REST API endpoints. diff --git a/includes/class-wcs-api.php b/includes/class-wcs-api.php index 83c52f6..a1c0bfd 100644 --- a/includes/class-wcs-api.php +++ b/includes/class-wcs-api.php @@ -151,4 +151,23 @@ class WCS_API { return (bool) preg_match( '/\/wc\/v[1-3]\/orders\b/', $GLOBALS['wp']->query_vars['rest_route'] ); } + + /** + * Fetches WooCommerce API endpoint data in a WooCommerce version compatible way. + * + * This method is a wrapper for the WooCommerce API get_endpoint_data method. In WooCommerce 9.0.0 and later, the + * WC()->api was deprecated in favor of the new Automattic\WooCommerce\Utilities\RestApiUtil class. + * + * @since 6.4.1 + * + * @param string $endpoint The endpoint to get data for. + * @return array|\WP_Error The endpoint data or WP_Error if the request fails. + */ + public static function get_wc_api_endpoint_data( $endpoint ) { + if ( wcs_is_woocommerce_pre( '9.0.0' ) ) { + return WC()->api->get_endpoint_data( $endpoint ); + } + + return wc_get_container()->get( Automattic\WooCommerce\Utilities\RestApiUtil::class )->get_endpoint_data( $endpoint ); + } } diff --git a/includes/class-wcs-webhooks.php b/includes/class-wcs-webhooks.php index 1044835..eb9d65b 100644 --- a/includes/class-wcs-webhooks.php +++ b/includes/class-wcs-webhooks.php @@ -132,6 +132,11 @@ class WCS_Webhooks { switch ( $webhook->get_api_version() ) { case 'legacy_v3': + + if ( is_null( wc()->api ) ) { + throw new \Exception( 'The Legacy REST API plugin is not installed on this site. More information: https://developer.woocommerce.com/2023/10/03/the-legacy-rest-api-will-move-to-a-dedicated-extension-in-woocommerce-9-0/ ' ); + } + WC()->api->WC_API_Subscriptions->register_routes( array() ); $payload = WC()->api->WC_API_Subscriptions->get_subscription( $resource_id ); break; @@ -147,7 +152,7 @@ class WCS_Webhooks { break; case 'wp_api_v3': - $payload = wc()->api->get_endpoint_data( "/wc/v3/subscriptions/{$resource_id}" ); + $payload = WCS_API::get_wc_api_endpoint_data( "/wc/v3/subscriptions/{$resource_id}" ); break; } diff --git a/languages/woocommerce-subscriptions.pot b/languages/woocommerce-subscriptions.pot index 88c13ce..fa4ecd1 100644 --- a/languages/woocommerce-subscriptions.pot +++ b/languages/woocommerce-subscriptions.pot @@ -2,14 +2,14 @@ # This file is distributed under the same license as the WooCommerce Subscriptions plugin. msgid "" msgstr "" -"Project-Id-Version: WooCommerce Subscriptions 6.4.0\n" +"Project-Id-Version: WooCommerce Subscriptions 6.4.1\n" "Report-Msgid-Bugs-To: https://woocommerce.com/contact-us\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"POT-Creation-Date: 2024-06-13T01:43:31+00:00\n" +"POT-Creation-Date: 2024-06-28T01:10:56+00:00\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "X-Generator: WP-CLI 2.9.0\n" "X-Domain: woocommerce-subscriptions\n" diff --git a/vendor/autoload.php b/vendor/autoload.php index 05985c7..92f4bda 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) { require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInit02567f250c7765c8ea2ed71a416c6653::getLoader(); +return ComposerAutoloaderInitb6faa2b65c1d08bc372be5e5be1acee6::getLoader(); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index ebc175f..bda99fa 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit02567f250c7765c8ea2ed71a416c6653 +class ComposerAutoloaderInitb6faa2b65c1d08bc372be5e5be1acee6 { private static $loader; @@ -24,12 +24,12 @@ class ComposerAutoloaderInit02567f250c7765c8ea2ed71a416c6653 require __DIR__ . '/platform_check.php'; - spl_autoload_register(array('ComposerAutoloaderInit02567f250c7765c8ea2ed71a416c6653', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInitb6faa2b65c1d08bc372be5e5be1acee6', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); - spl_autoload_unregister(array('ComposerAutoloaderInit02567f250c7765c8ea2ed71a416c6653', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInitb6faa2b65c1d08bc372be5e5be1acee6', 'loadClassLoader')); require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInit02567f250c7765c8ea2ed71a416c6653::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInitb6faa2b65c1d08bc372be5e5be1acee6::getInitializer($loader)); $loader->register(true); diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 77bc462..4d77762 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInit02567f250c7765c8ea2ed71a416c6653 +class ComposerStaticInitb6faa2b65c1d08bc372be5e5be1acee6 { public static $prefixLengthsPsr4 = array ( 'C' => @@ -129,9 +129,9 @@ class ComposerStaticInit02567f250c7765c8ea2ed71a416c6653 public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInit02567f250c7765c8ea2ed71a416c6653::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInit02567f250c7765c8ea2ed71a416c6653::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInit02567f250c7765c8ea2ed71a416c6653::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInitb6faa2b65c1d08bc372be5e5be1acee6::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInitb6faa2b65c1d08bc372be5e5be1acee6::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInitb6faa2b65c1d08bc372be5e5be1acee6::$classMap; }, null, ClassLoader::class); } diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index d0db352..4bef9df 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -1,9 +1,9 @@ array( 'name' => 'woocommerce/woocommerce-subscriptions', - 'pretty_version' => 'dev-release/6.4.0', - 'version' => 'dev-release/6.4.0', - 'reference' => '4f5a7362b75b8b0f747cc271320809adba667cb7', + 'pretty_version' => 'dev-release/6.4.1', + 'version' => 'dev-release/6.4.1', + 'reference' => '1731999c38ad73e9593177e016f02aa815ed4dca', 'type' => 'wordpress-plugin', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -41,9 +41,9 @@ 'dev_requirement' => false, ), 'woocommerce/woocommerce-subscriptions' => array( - 'pretty_version' => 'dev-release/6.4.0', - 'version' => 'dev-release/6.4.0', - 'reference' => '4f5a7362b75b8b0f747cc271320809adba667cb7', + 'pretty_version' => 'dev-release/6.4.1', + 'version' => 'dev-release/6.4.1', + 'reference' => '1731999c38ad73e9593177e016f02aa815ed4dca', 'type' => 'wordpress-plugin', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), diff --git a/woocommerce-subscriptions.php b/woocommerce-subscriptions.php index f711922..4d81ce2 100644 --- a/woocommerce-subscriptions.php +++ b/woocommerce-subscriptions.php @@ -5,11 +5,11 @@ * Description: Sell products and services with recurring payments in your WooCommerce Store. * Author: WooCommerce * Author URI: https://woocommerce.com/ - * Version: 6.4.0 + * Version: 6.4.1 * Requires Plugins: woocommerce * * WC requires at least: 8.7.1 - * WC tested up to: 8.9.0 + * WC tested up to: 9.0.0 * Woo: 27147:6115e6d7e297b623a169fdcf5728b224 * * Copyright 2019 WooCommerce @@ -78,7 +78,7 @@ class WC_Subscriptions { public static $plugin_file = __FILE__; /** @var string */ - public static $version = '6.4.0'; // WRCS: DEFINED_VERSION. + public static $version = '6.4.1'; // WRCS: DEFINED_VERSION. /** @var string */ public static $wc_minimum_supported_version = '7.7';