Easystore warning "Attempt to read property "quantity" on null in...administrator/components/com_easystore/src/Checkout/OrderManager.php on line 827" - Forum | JoomShaper
Staff replied EasyStore

Easystore warning "Attempt to read property "quantity" on null in...administrator/components/com_easystore/src/Checkout/OrderManager.php on line 827"

Asked by Alexander Frenkel 1 year ago Last activity 1 year ago

Hi team,
getting this many times in my Orders list:

Warning: Attempt to read property "quantity" on null in /var/www/vhosts/.../administrator/components/com_easystore/src/Checkout/OrderManager.php on line 827

May be someone could check.
Thank you.
BR,
Alexander

2 replies

Toufiq Senior Staff
1 year ago · edited

Hi there,

Thank you for reaching out, and I apologize for any inconvenience caused by this oversight. Please check now. We will update it next update.

administrator/components/com_easystore/src/Checkout/OrderManager.php

old code

        return array_map(function ($item) {

            $item->weight = $item->weight ?? 0;
            $unit = $item->has_variants 
                ? (isset($item->variant_data->unit) ? $item->variant_data->unit : (isset($item->unit) ? $item->unit : null)) 
                : (isset($item->unit) ? $item->unit : null);
            $item->unit = $unit;
            $item->weight_total = bcmul($item->weight, (int) $item->cart_item->quantity, 2);
            $item->weight_total_with_unit = SettingsHelper::getWeightWithUnit($item->weight_total, $unit);
            $item->weight_with_unit = SettingsHelper::getWeightWithUnit($item->weight, $unit);
            return $item;
        }, $products);

New code

return array_map(function ($item) {

            $item->weight = $item->weight ?? 0;
            $unit = $item->has_variants 
                ? (isset($item->variant_data->unit) ? $item->variant_data->unit : (isset($item->unit) ? $item->unit : null)) 
                : (isset($item->unit) ? $item->unit : null);
            $item->unit = $unit;

            $quantity = isset($item->cart_item) && isset($item->cart_item->quantity) ? (int) $item->cart_item->quantity : 0;

            $item->weight_total = bcmul($item->weight, $quantity, 2);
            $item->weight_total_with_unit = SettingsHelper::getWeightWithUnit($item->weight_total, $unit);
            $item->weight_with_unit = SettingsHelper::getWeightWithUnit($item->weight, $unit);

            return $item;
        }, $products);

Best regards,

Toufiqur Rahman (Team Lead, Support)

Alexander Frenkel Asked this

OK, thank you. It works now.

Toufiq Senior Staff

You are most welcome & Thanks

Log in to reply.