Jump to content

How get what is in the cart at what price when using webservice


lem__mel

Recommended Posts

Hi !

I'm currently developping an application using the Prestashop Webservices, and I would like to know how to figure the price of each row of the cart.

By using such a request for a given cart :

/api/carts/146

we get something looking like this :

<CART_ROW>
	<ID_PRODUCT xlink:href="http://truc.fr/api/products/410"><![CDATA[410]]></ID_PRODUCT>
	<ID_PRODUCT_ATTRIBUTE xlink:href="http://truc.fr/api/combinations/0"><![CDATA[0]]></ID_PRODUCT_ATTRIBUTE>
	<ID_ADDRESS_DELIVERY xlink:href="http://truc.fr/api/addresses/1"><![CDATA[1]]></ID_ADDRESS_DELIVERY>
	<QUANTITY><![CDATA[1]]></QUANTITY>
</CART_ROW>

In short, there isn't much, and to be specific we don't find :

  • the final taxe rule that will be applied
  • the final product price  (useful when there is some king of price modificator), or even the total price

 

It may seems to be possible to do it manually, but it quick get complex:

  • which tax rule to apply ? through the product, we can get id_tax_rules_group but I didn't find an explicit link to a specific id_tax
  • what will be the final price when there is some kind of modificator ?

 

So to make it short : how to know what is in the cart, at what price ?

 

P.S. :

  • I found that someone else already ask a similar question (c.f. prestashop-webservice-cart-price-calculation) but got no response :-(
  • the only way around that I imagine is to use a regular order as they do provide correct informations, but I fear the consequences

 

Link to comment
Share on other sites

Well, I found it when looking for something else: you need to ask on a product its price.

Link to the official documentation : PS16/Chapter+10+-+Price+management

Exemple :

/api/products/325?price[my_price][use_tax]=1&price[my_price][?price[my_price][use_tax]=1&price[my_price][quantity]=2

where my_price is the XML tag that will be used for storing the final unitary price of the product.

Link to comment
Share on other sites

  • 1 year later...
On 3/23/2018 at 8:43 PM, lem__mel said:

Well, I found it when looking for something else: you need to ask on a product its price.

Link to the official documentation : PS16/Chapter+10+-+Price+management

Exemple :


/api/products/325?price[my_price][use_tax]=1&price[my_price][?price[my_price][use_tax]=1&price[my_price][quantity]=2

where my_price is the XML tag that will be used for storing the final unitary price of the product.

Hello, I am doing something similar, is this working on JSON as well?

It seems that filtering on the field "my_price" is not working.

EDIT: yes it is working even on JSON

Thank you

Camillo

Edited by camillo777 (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...