上下文:
给定一个带有WooCommerce和WooCommerce订阅的WordPress网站,我试图获取特定用户的订阅列表。直到最近的更新,这一行代码已经为我解决了这个问题。下面是我一直在使用的代码:
$all_user_subscriptions = WC_Subscriptions_Manager::get_users_subscriptions( $user_id );
字符串
其中$user_id是WordPress中有效的用户ID。
问题:
自上次更新以来,我们经常看到以下错误:
致命错误:Uncaught exception 'InvalidArgumentException' with message 'Start or end times are not integers' in /home/warfarep/public_html/wp-content/plugins/woocommerce-subscriptions/includes/wcs-time-functions.php:332堆栈跟踪:#0 /home/warfarep/public_html/wp-content/plugins/woocommerce-subscriptions/includes/wcs-time-functions.php(309):wcs_number_of_leap_days('1456308046 ',1487930566)#1 /home/warfarep/public_html/wp-content/plugins/woocommerce-subscriptions/includes/wcs-deprecated-functions.php(171):wcs_estimate_period_between('1456308046 ',1487930566,' year ',' floor ')#2 /home/warfarep/public_html/wp-content/plugins/woocommerce-subscributions/includes/class-wc-subscributions-manager.php(1460)wcs_get_subscription_in_deprecated_structure(Object(WC_Subscription))#3 /home/warfarep/public_html/wp-content/themes/warfare-plugins-pro-3/functions.php(334):© 2019 my-account.ph权利
问题:
如果这个函数不再工作(被弃用),我该怎么做才能检索特定用户订阅的列表(对象,数组,无论什么)而不抛出致命错误?
2条答案
按热度按时间bjg7j2ky1#
我相信您现在可以使用
wcs_get_users_subscriptions($user_id)
函数获取Subscriptions对象了。f45qwnt82#
您可以使用以下
WC_Subscriptions_Order::get_users_subscription_orders( $user_id );
查找活动订阅ID数组获取更具体的订阅
字符串