WPML

Panoramica del problema

Visualizzando gli ordini associati a WooCommerce Subscriptions mentre WPML è attivo, gli utenti potrebbero riscontrare un errore fatale di 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

Soluzione alternativa

Questo problema è stato risolto in Woocommerce Subscriptions 8.2.0. L'aggiornamento risolve il problema sul tuo sito, quindi hai bisogno di questa soluzione alternativa solo se non puoi ancora aggiornare.

Assicurati di avere un backup completo del tuo sito prima di procedere.

  • Apri il file …/wp-content/plugins/woocommerce-subscriptions/vendor/woocommerce/subscriptions-core/includes/wcs-helper-functions.php.
  • Cambia da:
    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, '' );
    }
  • A:
    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, '' );
    }

Tutti i problemi noti

Riscontri ancora questo problema?

Se l’aggiornamento non risolve il problema, fai una richiesta di supporto e lo analizzeremo con te.