Nic*_*dot 5 wordpress woocommerce woocommerce-subscriptions
语境:
给定一个带有WooCommerce和WooCommerce订阅的WordPress网站,我试图获取特定用户订阅的列表.在最近的更新之前,这一行代码已经为我解决了这个问题.这是我一直在使用的代码:
$all_user_subscriptions = WC_Subscriptions_Manager::get_users_subscriptions( $user_id );
Run Code Online (Sandbox Code Playgroud)
其中$ user_id是WordPress中的有效用户ID.
问题:
自上次更新以来,我们经常看到以下错误:
致命错误:/home/warfarep/public_html/wp-content/plugins/woocommerce-subscriptions/includes/wcs-time-functions.php:332堆栈跟踪中未捕获的异常'InvalidArgumentException',消息'开始或结束时间不是整数' :#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_periods_between('1456308046',1487930566,'year','floor')#2/home/warfarep/public_html/wp- content/plugins/woocommerce-subscriptions/includes/class-wc-subscriptions-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):WC_Subscriptions_Manager :: get_users_subscriptions('2686')#4/home/warfarep/public_html/wp-content/themes/warfare-plugins-pro- 332线上的/home/warfarep/public_html/wp-content/plugins/woocommerce-subscriptions/includes/wcs-time-functions.php中的3/woocommerce/myaccount/my-account.ph
问题:
如果此函数不再起作用(不推荐使用),我该怎么做才能检索特定用户订阅的列表(对象,数组等),而不会抛出致命错误?