- Статус
- Решено автором
- Решено в
- Woocommerce Subscriptions 8.2.0
- Связанный плагин/тема
- WooCommerce Subscriptions
- Теги темы
- Compatibility
Обзор проблемы
При просмотре заказов, связанных с WooCommerce Subscriptions, когда активен WPML, пользователи могут столкнуться с фатальной ошибкой 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, '' ); }