wcs_subscription_meta_query is deprecated since version subscriptions-core 2.5.0
-
Debug log:
wcs_subscription_meta_query is deprecated since version subscriptions-core 2.5.0! Use wc_subscriptions_subscription_data instead.
Code:
Wf_Woocommerce_Packing_List_Invoice::__construct();
/**
* WC Subscriptions Support
* The subscription plugin copies all meta data from the parent order during renewal order
* creation.
* To prevent invoice number duplication, the copying of the invoice number should be avoided.
*
* @since 4.7.6
*/
if ( in_array( 'woocommerce-subscriptions/woocommerce-subscriptions.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true ) || class_exists( 'WC_Subscriptions' ) ) {
$subscription_version = class_exists( 'WC_Subscriptions' ) && ! empty( WC_Subscriptions::$version ) ? WC_Subscriptions::$version : null;
// Prevent data being copied to subscriptions
if ( null !== $subscription_version && version_compare( $subscription_version, '2.5.0', '>=' ) ) {
add_filter( 'wc_subscriptions_subscription_data', array( $this, 'remove_invoice_number_from_renewal_order_meta' ) );
add_filter( 'wc_subscriptions_renewal_order_data', array( $this, 'remove_invoice_number_from_renewal_order_meta') );
} else {
add_filter( 'wcs_subscription_meta_query', array( $this, 'subscriptions_remove_renewal_invoice_number_meta' ) );
add_filter( 'wcs_renewal_order_meta_query', array( $this, 'subscriptions_remove_renewal_invoice_number_meta' ), 10 );
}
}Issue:
$subscription_version = class_exists( 'WC_Subscriptions' ) && ! empty( WC_Subscriptions::$version ) ? WC_Subscriptions::$version : null;This code is called before WC_Subscriptions class has the chance to load hence $subscription_version will always be null.
Solution:
Move this code section to plugin_loaded action hook where all plugins would have been loaded and you also no longer need the following check condition since WC_Subscriptions class would already be loaded and can be check alone with class_exists method.
in_array( 'woocommerce-subscriptions/woocommerce-subscriptions.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true )Thanks
The topic ‘wcs_subscription_meta_query is deprecated since version subscriptions-core 2.5.0’ is closed to new replies.