1

if i add a item to cart via api it set Magento 2 default price of the item instead price set via API

1st i create a cart for a customer:

index.php/rest/default/V1/customers/631/carts

via POST

index.php/rest/default/V1/carts/{cartid}/items

via POST

json:

{ "cartItem": { "quote_id": "cart_id_from_1st_response", "sku": "test_sku", "qty": 1, "price": "11" } }

the response is like that:

stdClass Object
 (
 [item_id] => 186
 [sku] => test_sku
 [qty] => 1
 [name] => Testarticle
 [price] => 15
 [product_type] => simple
 [quote_id] => 287
 )

the price should be 11 as in the post, but the API response the prie of 15

asked May 23, 2019 at 7:15
1
  • want You to post custom price which you have sent from post parameters Commented May 23, 2019 at 9:21

1 Answer 1

0

/V1/carts/{cartId}/items is an endpoint for GET request.
Try with the following endpoint instead:

For POST:

/V1/carts/{quoteId}/items
/V1/carts/mine/items

For PUT

/V1/carts/{cartId}/items/{itemId} 
/V1/carts/mine/items/{itemId}
answered May 23, 2019 at 8:22
3
  • quoteId and cartId are still the same? the response of POST V1/customers/631/carts is the id to which i post the items Commented May 23, 2019 at 14:07
  • @Jan I'm not really sure but I think is the same. The id from V1/customers/631/carts is the quoteId you use to POST items to cart using /V1/carts/{quoteId}/items endpoint and then from there, you get the cart id from response which you use to update the cart items using /V1/carts/{cartId}/items/{itemId} endpoint Commented May 24, 2019 at 4:05
  • yes i think im right but...i send to the endpoint this json: { "cartItem": { "item_id": 189, "quoteId":289, "price": 89, "qty":1 } } and get this response: { "cartItem": { "item_id": 189, "quoteId":289, "price": 89, "qty":1 } } so the price will not accept Commented May 25, 2019 at 11:01

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.