Menu Close
    Hire us Request quote Reading list Switch to dark mode

    How to use cart api in Opencart

    In our previous blog : http://webkul.com/blog/use-customer-api-opencart/  , we learnt how to use customer api in opencart . Today we will learn , how use cart api in opencart  .

    Opencart uses the cart api in the product section while adding or editing the order from the admin end . After adding the customer from the  sales->orders then add/edit  when we click the continue button , then it goes to the product section .

    After selecting the product when , we click on add product button , Two methods of the cart api will be called  .First is ‘add’ . The add method is used to add the product into the cart . The code is given below:


    If product is added successfully then add method will return the success message.

    After adding the product , ‘products’ method will be called . The ‘products’ method is used to fetch the cart products .The code is given below:


    If products fetched successfully , then it will return the details of the product that are currently in the cart . The response will look like as follows :

    We can also remove the added product by clicking the remove button placed in the action column of product table . When we click the remove button , remove method of cart api will be called . The code for remove method is :


    If product successfully removed , then it will return the success method as given below :

     

    . . .

    Comments (3)

    Add Your Comment

  • Kshitij Baluni
    i am facing the issue with the remove function in cart.api.
    Not able to remove or update product from cart, as i am nit able to fetch the Key that is used for the product id.

    {“success”:”Success: You have modified your shopping cart!”}
    Showing success, but the cart is not update.
    This is because of the key is not fetched for the product_id.

    Thanks in advance.

  • Kshitij Baluni
    Not Able to use the remove function
    Getting {“success”:”Success: You have modified your shopping cart!”}
    but when seeing the cart data, it’s not modified removed.
    Same goes with the update funtion.
    Please help
    Thanks in advance
    Please help its urgent
    • sara
      please till me the solution if you know it :”)
  • Back to Top
    css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just received your message and our expert will get back to you shortly.
    Send Again
    Close