Support » Plugin: CoCart - Headless ecommerce » Get Session Cart and User Logged

  • Resolved cloudeweb

    (@cloudeweb)


    Hello, I have a Laravel project and a WordPress project into laravel ‘public’ folder.

    https://www.mysite.it/ (Laravel)
    https://www.mysite.it/wp/ (WordPress)

    I have this Laravel function

    class ProductController extends Controller
    {
       public function index(Request $request)
       {
    
         $curl = curl_init();
    
         curl_setopt_array( $curl, array(
           CURLOPT_URL => "http://site.test/wp/wp-json/cocart/v2/cart/items",
           CURLOPT_CUSTOMREQUEST => "GET",
           CURLOPT_RETURNTRANSFER => true,
           CURLOPT_TIMEOUT => 30,
           CURLOPT_HTTPHEADER => array(
             'Accept: application/json',
             'User-Agent: CoCart API/v2',
           )
         ) );
    
         $response = curl_exec($curl);
    
         curl_close($curl);
    
         echo $response;
    
       }
    
    }

    But results is always “No items in the cart.”

    I think that Laravel cannot read WordPress Sessions.

    There is a way?

    thanks!

    • This topic was modified 7 months, 3 weeks ago by cloudeweb.
    • This topic was modified 7 months, 3 weeks ago by cloudeweb.
Viewing 1 replies (of 1 total)
  • Plugin Author Sébastien Dumont

    (@sebd86)

    Hi @cloudeweb

    Happy new year. Hope you had a great holiday and are doing well.

    Yes you are right that some frameworks don’t read sessions which is why we have created this guide to help.

    If you have any further questions after reading please respond here.

    Thank you for your question.

    regards,

    Sébastien Dumont.
    Found of CoCart.

Viewing 1 replies (of 1 total)
  • The topic ‘Get Session Cart and User Logged’ is closed to new replies.