• Hello,

    I’ve encountered a fatal error in the current version of WPC Product Quantity Premium.
    The issue occurs in wpc-product-quantity.php around line 858:

    Fatal error: Uncaught Error: Call to a member function is_type() on false in
    /wp-content/plugins/wpc-product-quantity-premium/wpc-product-quantity.php:858
    Stack trace:
    0 /wp-content/plugins/wpc-product-quantity-premium/wpc-product-quantity.php(876): WPCleverWoopq->get_quantity()
    1 /wp-content/plugins/wpc-product-quantity-premium/wpc-product-quantity.php(921): WPCleverWoopq->get_type()
    2 /wp-content/plugins/wpc-product-quantity-premium/wpc-product-quantity.php(1850): WPCleverWoopq->get_min()
    3 /wp-includes/class-wp-hook.php(324): WPCleverWoopq->available_variation()

    The error happens when the method available_variation() is executed in a context where the $product parameter is false or null, so calling $product->is_type() throws a fatal error.

    The plugin assumes that $product is always an instance of WC_Product,
    but in some contexts (for example during certain AJAX calls or variation rendering),
    the woocommerce_available_variation filter can be triggered with an invalid or empty product reference.

    To prevent the fatal error, a simple instance check should be added before accessing $product methods, e.g.:

    if ( ! $product instanceof WC_Product ) { return $data; }

    Suggested fix:

    Add this validation in the following methods before using $product:

    • get_type()
    • get_min()
    • available_variation()

    This ensures compatibility with all WooCommerce contexts and prevents fatal errors when $product is not properly initialized.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Fatal error when calling available_variation()’ is closed to new replies.