Can’t get cart. cocart_must_authenticate_user
-
Hi. I tried to get cart with authenticated user but I get this error.
{ "code": "cocart_must_authenticate_user", "message": "Must authenticate customer as the cart key provided is a registered customer." }
This is my code.
public function get_cart($_var) { $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "https://mystore.com/wp-json/cocart/v2/cart?cart_key=2", CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30, CURLOPT_HTTPHEADER => array( 'Accept: application/json', 'User-Agent: CoCart API/v2', 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczovL2RhbGxlc3RvcmUubGl2ZSIsImlhdCI6MTY2ODkyMzkxNSwibmJmIjoxNjY4OTIzOTE1LCJleHAiOjE2Njk1Mjg3MTUsImRhdGEiOnsidXNlciI6eyJpZCI6IjIifX19.yT7zZiCI9JE4r-zywzZFV0aj_mCmHQGzFkCE2XQzbkQ' ) )); $response = curl_exec($curl); curl_close($curl); $response = json_decode($response, true); echo json_encode($response); }
For JWT I use this plugin https://www.ads-software.com/plugins/jwt-authentication-for-wp-rest-api/
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Can’t get cart. cocart_must_authenticate_user’ is closed to new replies.