3

How can I remove product from cart REST API. I searched on

http://devdocs.magento.com/guides/v2.0/rest/list.html

and could not find any help from above reference.

4 Answers 4

7

There is one API under quoteCartItemRepositoryV1

DELETE /V1/carts/mine/items/{itemId}
1
  • anyway we can pass multiple itemIds in this?
    – Fokker
    May 14, 2019 at 6:52
0

There is no API call to remove products from cart.

You have to implement it.

See \Magento\Checkout\Controller\Cart\Delete::execute for a code example.

1
  • Thanks for your answer but how can I implement. Please give more details.
    – Jsparo30
    Mar 14, 2017 at 11:37
0

I have got a nice tutorial for you. Which explains about how to create a custom REST APIs for Magento 2.x. It has all the detailed process. Please check this.

If you have any doubts please reach me out via comments.

4
  • Like the updateCart() function in the example try to create for deleteCart() function. Mar 14, 2017 at 11:43
  • Hi @Asheem Patro Sep 5, 2018 at 9:04
  • I wants to remove an item from after order placed. Sep 5, 2018 at 9:04
  • Is there any way to remove an item after place order in magento2 Sep 5, 2018 at 9:04
0

The docs are very unclear on how this works.
Here is how i did it.

<?php
  $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); 
  $quoteId = $objectManager->get('Magento\Checkout\Model\Session')->getQuoteId();
?>

<script>window.quoteId = <?= $quoteId ?></script>


<script>
$('.thing').on('click', function (){
  $.ajax({
     url: '/rest/V1/carts/' + window.quoteId + '/items/' + $(this).attr('data-productid'),
     type: 'DELETE',
     headers: { "Authorization": "Bearer <AUTH_TOKEN>"},
     success: function(result) {console.log('Done')}
  });
})
</script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.