In this video we are going to learn about Show Product Attribute on Cart Page.
So let see how can we Show Product Attribute on Cart Page.
Lets open DetailsComponent.php class file
And here lets create a property.


public $satt=[];


Now go to the details-component.blade.php view file
And here inside this select control just bind the property so write here


<div>
@foreach($product->attributeValues->unique('product_attribute_id') as $av)
<div class="row" style="margin-top: 20px">
<div class="col-xs-2">
<p>{{$av->productAttribute->name}}</p>
</div>
<div class="col-xs-10">
<select class="form-control" style="width: 200px" wire:model="satt.{{$av->productAttribute->name}}">
@foreach($av->productAttribute->attributeValues->where('product_id',$product->id) as $pav)
<option value="{{$pav->value}}">{{$pav->value}}</option>
@endforeach
</select>
</div>
</div>
@endforeach
</div>


Now go to the DetailsComponent class file inside this store function add the following code


public function store($product_id,$product_name,$product_price)
{
Cart::instance('cart')->add($product_id,$product_name,$this->qty,$product_price,$this->satt)->associate('App\Models\Product');
session()->flash('success_message','Item added in Cart');
return redirect()->route('product.cart');
}


Now lets go to the cart-component.blade.php file and here lets
display the product selected attributes So here after this product name add the following code.


@foreach($item->options as $key=>$value)
<div style="vertical-align:middle; width:180px;">
<p><b>{{$key}}: {{$value}}</b></p>
</div>
@endforeach


Now its done so lets check it
So switch to the browser and refresh the page
Now lets open any product and lets open this one
And here lets select the attribute color red and size 32 And quantity one
Now click on add to cart
And here you can see product added to the cart and here is the product attribute
Now lets add one more product to the cart
So go back to shop page page
And now click on this product select the attribute and add to the cart and here are the products with attributes
So in this way you can Show Product Attribute on Cart Page.