No matter how many time I look at it this bit jumps out as it gets all the options not just the available ones:
@foreach ($item->options as $option)
I wonder what's in the $item
@if ($item->availableColours() && $item->availableStock())
// {{ dd($item) }}
Colours
@foreach ($item->options as $option)
{{ $option->colour }}
@endforeach
@endif
The $item is just from the controller passed as a foreach
If you replace the existing if/endif in the html what does this give you?
@if ($item->availableColours() && $item->availableStock())
{{ dd($item->availableColours()) }}
Colours
@foreach ($item->options as $option)
{{ $option->colour }}
@endforeach
@endif
That returns
array (size=1)
0 => string 'Black' (length=5)
What colours are available for the product you're looking at?
Just black for this example. So that dd() shows correctly.
hmmmmm.
Can you find a product that has stock in at least 2 colours in stock and at least one colour out of stock just to make sure that we can tell if what 's being tested is working properly.
Then try the last bit again.
black & white as stock and purple has none
I've no idea about this doing my head in now
or is there a way to show if the colour has not stock then in the size select just show "no stock" or something?
Please sign in or create an account to participate in this conversation.