laravelshoppingcart
laravelshoppingcart copied to clipboard
Undefined index: format_numbers with Livewire
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?
I have the same problem! Is there any solution?