• Resolved mmdrzw122

    (@mmdrzw122)


    Hello,

    I would like to report a compatibility issue that appears to affect your plugin when running on PHP 8.4.

    Environment

    • WordPress: 7.0.2
    • WooCommerce: Latest version
    • PHP: 8.4
    • Theme: Woodmart 8.5.5

    Problem

    A fatal error occurs while updating the WooCommerce cart via AJAX.

    The error is:

    Uncaught TypeError: method_exists(): Argument #1 ($object_or_class) must be of type object|string, false given
    

    File:

    wp-content/plugins/woo-min-max-quantity-step-control-single/includes/min-max-controller.php
    

    Line:

    987
    

    Backtrace:

    #0 .../min-max-controller.php(987): method_exists(false, 'is_sold_individually')
    #1 .../class-wp-hook.php(341): WC_MMQ\Includes\Min_Max_Controller->update_cart_validation(...)
    #2 .../plugin.php(205): WP_Hook->apply_filters(...)
    #3 .../woodmart/inc/integrations/woocommerce/modules/quantity.php(62): apply_filters('woocommerce_update_cart_validation', ...)
    #4 .../class-wp-hook.php(341): woodmart_update_cart_item('')
    #5 .../plugin.php(522): WP_Hook->do_action(...)
    #6 .../wp-admin/admin-ajax.php(207): do_action(...)
    

    Cause

    It appears that wc_get_product( $product_id ) can return false in some situations. However, the plugin immediately calls:

    method_exists( $this->product, 'is_sold_individually' )
    

    When $this->product is false, PHP 8.4 throws a fatal TypeError.

    This seems to be caused by a missing validation before calling method_exists() or other product methods.

    Suggested Fix

    Before calling any product methods, please verify that the returned value is a valid WC_Product object. For example:

    $this->product = wc_get_product( $product_id );
    
    if ( ! $this->product instanceof WC_Product ) {
        return $bool;
    }
    
    if ( $this->product->is_sold_individually() ) {
        return $bool;
    }
    

    or use another equivalent validation that ensures $this->product is a valid object before accessing its methods.

    I believe this is a compatibility issue with newer PHP versions rather than WooCommerce itself.

    Thank you for your work on the plugin. I hope this issue can be addressed in a future update.

Viewing 1 replies (of 1 total)
  • Plugin Support NAZMUL

    (@bmnazmul)

    Hello @mmdrzw122,

    Thank you so much for bringing this to our attention and for providing such a detailed report and helpful fix!

    We have resolved this issue in the latest update of the plugin by adding proper validation checks to ensure the product is a valid WC_Product object before calling its methods.

    Please update the plugin to the latest version. If you run into any other issues or have further feedback, feel free to reach out.

    Thanks again for helping us make the plugin better!

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.