• Join the Best Wordpress and Elementor Support forum

    Provide or get advice on everything Elementor and Wordpress, ask questions, gain confirmation or just become apart of a friendly, like minded community who love Wordpress and Elementor


    Join us!

1.0.261 PHP Fatal error: Class “ProductStockStatus” not found

Community

Community

Administrator
Staff member
Error PHP Fatal error: Uncaught Error: Class "Automattic\WooCommerce\Enums\ProductStockStatus" not found in /wp-content/plugins/seo-by-rank-math/includes/modules/schema/snippets/class-product-woocommerce.php:353

Latest Rank Math relies on the latest version of woocommerce, obviously some people may not be running the latest version of woocommerce yet.


Adding this to the functions resolves it :
Code:
add_action( 'after_setup_theme', function () {
    if ( ! class_exists( '\Automattic\WooCommerce\Enums\ProductStockStatus' ) ) {
        // Define a minimal replacement matching the values older WC returns from get_stock_status().
        class_alias( 'RM_WC_ProductStockStatus_Shim', '\Automattic\WooCommerce\Enums\ProductStockStatus' );
    }
}, 0 );

if ( ! class_exists( 'RM_WC_ProductStockStatus_Shim' ) ) {
    class RM_WC_ProductStockStatus_Shim {
        public const IN_STOCK     = 'instock';
        public const OUT_OF_STOCK = 'outofstock';
        public const ON_BACKORDER = 'onbackorder';
    }
}
 

Latest Resources

Other Elementor Resources

elementor official

Still stuck? Ask the forum

Post your question with a screenshot and a link if you can, and a member will usually reply within a day. Free to join, no sales pitch.

Create a free account
Top