Advertisement
NikolayBezay

Example of add to cart functionality.

Oct 4th, 2023
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. const productData = {
  2. 'form_type': 'product',
  3. 'utf8': '✓',
  4. 'id': '43915159568629',
  5. 'Color': 'BLACK',
  6. 'Size': '6',
  7. 'quantity': '1',
  8. 'product-id': '8066621210869'
  9. };
  10. const requestBody = new FormData();
  11. for(key in productData) {
  12. requestBody.append(key, productData[key]);
  13. }
  14.  
  15.  
  16. fetch("https://ruumur.com/cart/add", {
  17. "body": requestBody,
  18. "method": "POST",
  19. "mode": "cors",
  20. "credentials": "include"
  21. }).then(response => {
  22. console.log(response.status)
  23. }).then(() => {
  24. window.location.reload();
  25. });
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement