• Resolved vengoch

    (@vengoch)


    2024/04/16 15:47:06 [error] 103980#103980: *729892 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught ValueError: max(): Argument #1 ($value) must contain at least one element in /www/mywebsite/public/wp-content/plugins/advanced-woo-labels/includes/class-awl-product-data.php:111

    Dear support

    we found an issue depending on the stock status within one of your methods:

        /**
         * Get product quantity
         * @since 1.0
         * @param  object $product Product
         * @return integer
         */
        static public function get_quantity( $product ) {
    
            $stock_levels = array();
    
            if ( $product->is_type( 'variable' ) ) {
                foreach ( $product->get_children() as $variation ) {
                    $var = wc_get_product( $variation );
                    if ( $var->is_in_stock() && ! $var->get_manage_stock() ) {
                        $stock_levels[] = 999999;
                    } else {
                        $stock_levels[] = $var->get_stock_quantity();
                    }
                }
            } else {
                if ( $product->is_in_stock() && ! $product->get_manage_stock() ) {
                    $stock_levels[] = 999999;
                } else {
                    $stock_levels[] = $product->get_stock_quantity();
                }
            }
    
            return intval( max( $stock_levels ) );

    we defined four label:
    Sales = check if reduced price (not affected)
    New = assigned to a selected category(not affected)
    Favorit = checked as favorite (not affected)
    Limited = check that stock value is between 0-3 and not 0 (AFFECTED)

    the product which is causing the entire site to crash is one variable product with stock status but not yet created variants. this is why it does not really get stock status back.

    #Solution
    Your script should not crash on this. We can provide you with access if needed.

    thank you for your attention on this.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author ILLID

    (@mihail-barinov)

    Hi,

    Thanks for letting me know about this problem. I will fix it in the next plugin releases that will be available on Monday.

    Regards

    Thread Starter vengoch

    (@vengoch)

    Hi Mihail, thank you for this confirmation and update. We will let you know after update if you wish.

    best regards

    Plugin Author ILLID

    (@mihail-barinov)

    Yes, this will be great.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[NSFW] PHP Fatal error in stockstatus check’ is closed to new replies.