I am trying to get information from the database to appear in my shopping cart. Trying to get the price_total, qty_total and embedded base64 img(LONGBLOB) to appear in my cart.
Although am new to coding. However, i have been able to successfully save those data in my database through post method. i have tried getting those stored data to appear in my cart but it always comes up with an error message as such;
ERROR: Trying to get property '{"id":1,"price_total":80,"qty_total":4,"img_front":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAeAAAAH+CAYAAABECN1+AAAgAElEQVR4Xuy9C7BmV3Umts/jf9x7+63Wg5YEiJeNBQZsjAEjRBOEDJgxkwxdtsupGSeOnUlSTJJJUpXEFVmpmkrVzKQqqdQkRVzjyaRScSxPnAcZMsQPgSVhBG0..............
I HAVE TRIED THIS (ProductsController.php)
public function CustomCart(){
    if(Auth::check()){          
        $user_email = Auth::user()->email;
        $userCustomCart = DB::table('customcart')->where(['user_email' => 
        $user_email])->get();
    }else{
        $session_id = Session::get('session_id');
        $userCustomCart = DB::table('customcart')->where(['session_id' => 
         $session_id])->get();
       }
    $userCustomCart = Custom::get();
    foreach($userCustomCart as $custom){
        $CustomDetails = Custom::where(['id' =>$custom- 
                 >price_total])->first();
        $userCustomCart->CustomDetails = $CustomDetails- 
                    >$custom;
    }
    $userCustomCart = json_decode(json_encode($userCustomCart));
          $meta_title = "CartCustom";
   return view('products.CustomCart')->with(compact('userCustomCart','meta_title'));
} 
HTML CODE FOR THE CART
<tbody>
@foreach($userCustomCart as $customcart)
<tr>
<td class="cart_image">
header("Content-type: image/png");
   echo '<img src="data:image/png;base64,' . $data . '" />';
</td>
<td class="cart_description">
    <h4>Your Creative Ideas</h4>    
</td>
<td class="cart_price">
    <h4><a href=""></a></h4>
</td>
     <td class="cart_quantity">
<h4><a href=""></a></h4>
</td>
    </tr>
@endforeach
</tbody>
via Chebli Mohamed
 
Aucun commentaire:
Enregistrer un commentaire