Tổng quan về sự cố
Khi xem các đơn hàng liên quan đến WooCommerce Subscriptions trong khi WPML đang hoạt động, người dùng có thể gặp phải lỗi PHP nghiêm trọng:
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
Giải pháp tạm thời
Sự cố này đã được khắc phục trong Woocommerce Subscriptions 8.2.0. Việc cập nhật giải quyết vấn đề này trên trang web của bạn, vì vậy bạn chỉ cần giải pháp tạm thời này nếu chưa thể cập nhật.
Vui lòng đảm bảo có một bản sao lưu đầy đủ trang web của bạn trước khi tiếp tục.
- Mở tệp …/wp-content/plugins/woocommerce-subscriptions/vendor/woocommerce/subscriptions-core/includes/wcs-helper-functions.php.
- Thay đổi từ:
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, '' ); } - Thành:
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, '' ); }