Guest User

Untitled

a guest
May 25th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. //GET CART
  2. $.get('/api/storefront/carts?include=', (data) => {
  3. console.log(data)
  4. });
  5.  
  6.  
  7. //POST Cart
  8. const body = {
  9. "lineItems": [{
  10. "quantity": 1,
  11. "productId": 17332,
  12. "listPrice": 100.00
  13. }]
  14. };
  15.  
  16. $.post('/api/storefront/carts', (JSON.stringify(body)))
  17. .done((msg) => {
  18. //..
  19. })
  20. .fail((jqXHR, textStatus, errorThrown) => {
  21. console.log(jqXHR);
  22. console.log(textStatus);
  23. console.log(errorThrown);
  24. });
  25.  
  26. //POST Item to Cart
  27. const addItem = {
  28. "lineItems": [{
  29. "quantity": 1,
  30. "productId": 17323,
  31. "listPrice": 100.00
  32. }]
  33. };
  34.  
  35. const cartId = "CXXXXX-XXX-4510-bf2b-XXXXXXX";
  36.  
  37. $.post(`/api/storefront/carts/${cartId}/items`, (JSON.stringify(addItem)))
  38. .done((msg) => {
  39. //..
  40. })
  41. .fail((jqXHR, textStatus, errorThrown) => {
  42. console.log(jqXHR);
  43. console.log(textStatus);
  44. console.log(errorThrown);
  45. });
Add Comment
Please, Sign In to add comment