- 状态
- 已由作者解决
- 解决于
- Woocommerce Subscriptions 8.2.0
- 相关插件/主题
- WooCommerce Subscriptions
- 主题标签
- Compatibility
问题概述
在启用 WPML 的情况下查看与 WooCommerce Subscriptions 相关的订单时,用户可能会遇到 PHP 致命错误:
PHP Fatal error: Uncaught TypeError: Illegal offset type in isset or empty in .../wp-content/plugins/sitepress-multilingual-cms/classes/core-abstract-classes/class-wpml-element-translation.php:259
临时解决方法
在继续操作之前,请确保已对您的站点进行了完整备份。
- 打开 …/wp-content/plugins/woocommerce-subscriptions/vendor/woocommerce/subscriptions-core/includes/wcs-helper-functions.php 文件。
- 将:
function wcs_get_edit_post_link( $post_id ) { $object = wc_get_order( $post_id ); // works for both WC Order and WC Subscription objects. if ( ! $object || ! in_array( $object->get_type(), array( 'shop_order', 'shop_subscription' ), true ) ) { return; } return apply_filters( 'get_edit_post_link', $object->get_edit_order_url(), $post_id, '' ); } - 更改为:
function wcs_get_edit_post_link( $post_id ) { if ($post_id instanceof('WC_Subscription')){ $post_id = $post_id->id; } $object = wc_get_order( $post_id ); // works for both WC Order and WC Subscription objects. if ( ! $object || ! in_array( $object->get_type(), array( 'shop_order', 'shop_subscription' ), true ) ) { return; } return apply_filters( 'get_edit_post_link', $object->get_edit_order_url(), $post_id, '' ); }