diff --git a/includes/class-wc-data-store.php b/includes/class-wc-data-store.php index 6583dbbff43..ad8995388c1 100644 --- a/includes/class-wc-data-store.php +++ b/includes/class-wc-data-store.php @@ -71,11 +71,19 @@ class WC_Data_Store { if ( array_key_exists( $object_type, $this->stores ) ) { $store = apply_filters( 'woocommerce_' . $object_type . '_data_store', $this->stores[ $object_type ] ); - if ( ! class_exists( $store ) ) { - throw new Exception( __( 'Invalid data store.', 'woocommerce' ) ); + if ( is_object( $store ) ) { + if ( ! class_implements( $store, WC_Object_Data_Store_Interface::class ) ) { + throw new Exception( __( 'Invalid data store.', 'woocommerce' ) ); + } + $this->current_class_name = get_class( $store ); + $this->instance = $store; + } else { + if ( ! class_exists( $store ) ) { + throw new Exception( __( 'Invalid data store.', 'woocommerce' ) ); + } + $this->current_class_name = $store; + $this->instance = new $store; } - $this->current_class_name = $store; - $this->instance = new $store; } else { throw new Exception( __( 'Invalid data store.', 'woocommerce' ) ); }