Merging Public Carts
Cortex does not persist public carts. If a public user adds items to their cart and then authenticates, the cart’s contents are lost. To merge a public user’s cart with a registered user’s cart, provide the public user’s access token during the authentication process.
Merging a public cart with a registered user’s cart
Construct a
POST
request to the OAuth2 Resource, set the content-type toapplication/x-www-form-urlencoded
, and add thePUBLIC
access token to your request headers as shown in the example below:POST http://www.myapi.net/oauth2/tokens Content-Type: application/x-www-form-urlencoded Authorization: Bearer a9256d79-9273-4820-b45d-587f90d1dc9b
Include the following parameters in the request body:
grant_type=password&username=oliver.harris@elasticpath.com&password=password&scope=mobee&role=REGISTERED
Cortex authenticates the request, merges the carts, and returns either a success or failure HTTP response.
Successful authentication returns the following HTTP response:
{ "access_token": "c7326d79-9273-4820-b45d-587f90d1dc9b", "token_type":"bearer", "expires_in": 359, "scope" : "MOBEE", "role": "REGISTERED" }
Unsuccessful authentication returns a 401 status code and an error message.