WPML
สถานะ
แก้ไขแล้วโดยผู้พัฒนา
แก้ไขใน
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, '' );
    }

ปัญหาที่ทราบแล้วทั้งหมด →