i wanted to add a subtotal to my cart page and i had this problem from laravel-9x, and actually i was watching a video on youtube that they used the same methode and that worked nicely with laravel 5.6 and i'm using this laravelshopping cart from github: https://github.com/darryldecode/laravelshoppingcart
so this is my function :
use Cart;
use App\Models\Produit;
use Darryldecode\Cart\CartCondition;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class CartController extends Controller
{
//add product to card
public function add(Request $request)
{
$produit = Produit::find($request->id);
Cart::add(array(
'id' => $produit->id,
'name' => $produit->nom,
'price' => $produit->prix_ht,
'quantity' => $request->qty,
'attributes' => array('size'=>$request->size,
'photo'=>$produit->photo_principale,
'prix_ttc'=>$produit->prixTTC()
)
));
return redirect(route(name:'cart_index'));
}
and this is the function prixTTC():
public function prixTTC(){
$prix_ttc = $this->prix_ht * self::$facteur_tva;
return number_format($prix_ttc,2);
}
and this is my HTML:
<td>
{{ $produit->attributes['prix_ttc'] }} €
</td>
<td>
{{ number_format($produit->attributes['prix_ttc'] * $produit->quantity,2)}} €
</td>
and laravel gives me this message: Undefined array key "prix_ttc"