Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

shopify api for add to cart

 let formData = {
                   'items': [{
                        'quantity': quantity,
                        'id': productID
                    }]
                };
              
                fetch(window.Shopify.routes.root + 'cart/add.js', {
                         method: 'POST',
                         headers: {
                         'Content-Type': 'application/json'
                         },
                         body: JSON.stringify(formData)
                }).then((response) => response.json())
  				  .then((product) => {
              		  
                    })
                  .catch( (error) => )
Source by shopify.dev #
 
PREVIOUS NEXT
Tagged: #shopify #api #add #cart
ADD COMMENT
Topic
Name
7+6 =