laravelshoppingcart icon indicating copy to clipboard operation
laravelshoppingcart copied to clipboard

Undefined index: format_numbers with Livewire

Open Roywcm opened this issue 4 years ago • 2 comments

Hi,

I don't know if it's a Livewire issue or an issue by this package, but after I updated livewire from 2.5.5 to 2.7.2 the usage of this package in Livewire was not working properly anymore.

When I tried to access getPriceWithConditions() in the cart loop, I suddenly got the error Undefined index: format_numbers at <localpath>/vendor/darryldecode/cart/src/Darryldecode/Cart/Helpers/Helpers.php:72

In livewire I had this simple code:

public function render()
    {
        $this->cart = \Cart::getContent()->sortBy('id');
        return view('livewire.view');
    }

In the Livewire view I had this code:

@foreach ($this->cart as $item)
    {{ $item->getPriceWithConditions() }}
@endforeach

After this, I got the error. When I access the contents directly in the view it's working correctly, like this;

 @foreach (\Cart::getContent()->sortBy('id') as $item)
    {{ $item->getPriceWithConditions() }}
@endforeach

Looks like Livewire is removing the config in the ItemCollection or something?

Roywcm avatar Nov 04 '21 16:11 Roywcm

I have the same problem! Is there any solution?

zipferot3000 avatar Apr 11 '22 08:04 zipferot3000