{"_id":"58112e72ded0340f0085d03b","parentDoc":null,"user":"560990bc40a2b81900136142","category":{"_id":"58112e72ded0340f0085d032","project":"551e85be610f400d00837db7","__v":0,"version":"58112e71ded0340f0085d02a","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-08-17T19:28:09.961Z","from_sync":false,"order":7,"slug":"merchant-api-methods","title":"Merchant API Methods"},"version":{"_id":"58112e71ded0340f0085d02a","project":"551e85be610f400d00837db7","__v":4,"createdAt":"2016-10-26T22:30:09.862Z","releaseDate":"2016-10-26T22:30:09.862Z","categories":["58112e72ded0340f0085d02b","58112e72ded0340f0085d02c","58112e72ded0340f0085d02d","58112e72ded0340f0085d02e","58112e72ded0340f0085d02f","58112e72ded0340f0085d030","58112e72ded0340f0085d031","58112e72ded0340f0085d032","58112e72ded0340f0085d033","58112e72ded0340f0085d034","581137cc604d3c230048b7e4","58dc367221742d0f00a73f98","590768e54669da0f00db5c0b"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"new designer","version_clean":"2.0.0","version":"2.0"},"__v":0,"project":"551e85be610f400d00837db7","updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-09-28T20:44:29.783Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":1,"body":"The following methods operate on the [Cart data model](doc:cart).\n\n# List all carts, or get a cart\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint list\\\">\\n  <span class=\\\"method get\\\">GET</span>\\n  <span class=\\\"uri\\\">\\n    http://api.cratejoy.com/v1/carts/\\n  </span>\\n</div>\"\n}\n[/block]\n\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint list\\\">\\n  <span class=\\\"method get\\\">GET</span>\\n  <span class=\\\"uri\\\">\\n    http://api.cratejoy.com/v1/carts/{cart_id}/\\n  </span>\\n</div>\"\n}\n[/block]\n# Create, get, or delete Cart metadata\n\nThese endpoints operate on the [Cart metadata](doc:cart-metadata) subresource.\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint list\\\">\\n  <span class=\\\"method get\\\">GET</span>\\n  <span class=\\\"uri\\\">\\n   http://api.cratejoy.com/v1/carts/{cart_id}/metadata/\\n  </span>\\n</div>\"\n}\n[/block]\n\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint list\\\">\\n  <span class=\\\"method post\\\">POST</span>\\n  <span class=\\\"uri\\\">\\n   http://api.cratejoy.com/v1/carts/{cart_id}/metadata/\\n  </span>\\n</div>\"\n}\n[/block]\n\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint list\\\">\\n  <span class=\\\"method delete\\\">DELETE</span>\\n  <span class=\\\"uri\\\">\\n   http://api.cratejoy.com/v1/carts/{cart_id}/metadata/\\n  </span>\\n</div>\"\n}\n[/block]\n# List Carts\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint\\\">\\n  <span class=\\\"method get\\\">GET</span>\\n  <span class=\\\"uri\\\">\\n    http://api.cratejoy.com/v1/carts/\\n  </span>\\n</div>\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$.ajax({\\n    url: 'https://api.cratejoy.com/v1/carts/',\\n    method: 'GET'\\n});\",\n      \"language\": \"javascript\",\n      \"name\": \"List\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"count\\\": 1,\\n  \\\"next\\\": null,\\n  \\\"prev\\\": null,\\n  \\\"results\\\": [\\n    {\\n      \\\"completed\\\": true,\\n      \\\"customer_id\\\": 86517999,\\n      \\\"id\\\": 86515947,\\n      \\\"is_test\\\": true,\\n      \\\"order_id\\\": 86518012,\\n      \\\"ship_price\\\": 400,\\n      \\\"store_id\\\": 5340102,\\n      \\\"tax_price\\\": 0,\\n      \\\"tax_rates\\\": [],\\n      \\\"type\\\": \\\"cart\\\",\\n      \\\"url\\\": \\\"/v1/carts/86515947/\\\"\\n    }\\n  ]\\n}\",\n      \"language\": \"json\",\n      \"name\": \"Response: 200 OK\"\n    }\n  ]\n}\n[/block]\n# Get Cart\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint\\\">\\n  <span class=\\\"method get\\\">GET</span>\\n  <span class=\\\"uri\\\">\\n    http://api.cratejoy.com/v1/carts/{cart_id}/\\n  </span>\\n</div>\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$.ajax({\\n    url: 'https://api.cratejoy.com/v1/carts/85497102/',\\n    method: 'GET'\\n});\",\n      \"language\": \"javascript\",\n      \"name\": null\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"completed\\\": true,\\n  \\\"customer_id\\\": 2445749,\\n  \\\"id\\\": 85497102,\\n  \\\"is_test\\\": true,\\n  \\\"order_id\\\": 86518813,\\n  \\\"ship_price\\\": 400,\\n  \\\"store_id\\\": 5340102,\\n  \\\"tax_price\\\": 0,\\n  \\\"tax_rates\\\": [],\\n  \\\"type\\\": \\\"cart\\\"\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nNote: this will only work with carts that have an order associated with them, so the customer has to at least have attempted to checkout.","excerpt":"","slug":"cart-methods","type":"basic","title":"Cart Methods"}
The following methods operate on the [Cart data model](doc:cart). # List all carts, or get a cart [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method get\">GET</span>\n <span class=\"uri\">\n http://api.cratejoy.com/v1/carts/\n </span>\n</div>" } [/block] [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method get\">GET</span>\n <span class=\"uri\">\n http://api.cratejoy.com/v1/carts/{cart_id}/\n </span>\n</div>" } [/block] # Create, get, or delete Cart metadata These endpoints operate on the [Cart metadata](doc:cart-metadata) subresource. [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method get\">GET</span>\n <span class=\"uri\">\n http://api.cratejoy.com/v1/carts/{cart_id}/metadata/\n </span>\n</div>" } [/block] [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method post\">POST</span>\n <span class=\"uri\">\n http://api.cratejoy.com/v1/carts/{cart_id}/metadata/\n </span>\n</div>" } [/block] [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method delete\">DELETE</span>\n <span class=\"uri\">\n http://api.cratejoy.com/v1/carts/{cart_id}/metadata/\n </span>\n</div>" } [/block] # List Carts [block:html] { "html": "<div class=\"endpoint\">\n <span class=\"method get\">GET</span>\n <span class=\"uri\">\n http://api.cratejoy.com/v1/carts/\n </span>\n</div>" } [/block] [block:code] { "codes": [ { "code": "$.ajax({\n url: 'https://api.cratejoy.com/v1/carts/',\n method: 'GET'\n});", "language": "javascript", "name": "List" } ] } [/block] [block:code] { "codes": [ { "code": "{\n \"count\": 1,\n \"next\": null,\n \"prev\": null,\n \"results\": [\n {\n \"completed\": true,\n \"customer_id\": 86517999,\n \"id\": 86515947,\n \"is_test\": true,\n \"order_id\": 86518012,\n \"ship_price\": 400,\n \"store_id\": 5340102,\n \"tax_price\": 0,\n \"tax_rates\": [],\n \"type\": \"cart\",\n \"url\": \"/v1/carts/86515947/\"\n }\n ]\n}", "language": "json", "name": "Response: 200 OK" } ] } [/block] # Get Cart [block:html] { "html": "<div class=\"endpoint\">\n <span class=\"method get\">GET</span>\n <span class=\"uri\">\n http://api.cratejoy.com/v1/carts/{cart_id}/\n </span>\n</div>" } [/block] [block:code] { "codes": [ { "code": "$.ajax({\n url: 'https://api.cratejoy.com/v1/carts/85497102/',\n method: 'GET'\n});", "language": "javascript", "name": null } ] } [/block] [block:code] { "codes": [ { "code": "{\n \"completed\": true,\n \"customer_id\": 2445749,\n \"id\": 85497102,\n \"is_test\": true,\n \"order_id\": 86518813,\n \"ship_price\": 400,\n \"store_id\": 5340102,\n \"tax_price\": 0,\n \"tax_rates\": [],\n \"type\": \"cart\"\n}", "language": "json" } ] } [/block] Note: this will only work with carts that have an order associated with them, so the customer has to at least have attempted to checkout.