Salman98's avatar

"trying to access array offset on value of type null $order->subtotal = session()->get('checkout')['subtotal'];

Hello Guys i've been following this Laravel/livewire E-Commerce series and i ecountered this frustrating error. Everything seems to be oky with the code but each time i click on the place order button from my checkout page, it raises a "trying to access array offset on value of type null ['subtotal']". i really dont know what to do. i am kinda a newbie. will really appreciate if someone helps me out. thanks.

0 likes
5 replies
Salman98's avatar

this is how my checkout compopnent looks like

tykus's avatar

In that case there is nothing in the Session with the checkout key. I don't know the detail of your app, so can't say if this is expected. You can check first:

if (session()->has('checkout'))
    //...

But no guarantee if it is there, it is an array!

1 like

Please or to participate in this conversation.