WPML
Statut
Résolu par l’auteur
Résolu dans
Woocommerce Subscriptions 8.2.0
Extension/thème associé
WooCommerce Subscriptions
Étiquettes de sujet
Compatibility

Aperçu de l’anomalie

Lors de l’affichage des commandes associées à WooCommerce Subscriptions lorsque WPML est actif, les utilisateurs peuvent rencontrer une erreur fatale 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

Solution de contournement

Assurez-vous d’avoir une sauvegarde complète de votre site avant de continuer.


  • Ouvrez le fichier …/wp-content/plugins/woocommerce-subscriptions/vendor/woocommerce/subscriptions-core/includes/wcs-helper-functions.php.

  • Remplacez :
    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, '' );
    }

  • Par :
    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, '' );
    }

Toutes les anomalies connues →