magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.54k stars 9.32k forks source link

Adding item to cart via API does not apply custom price set #38985

Open Lex-Weeks opened 3 months ago

Lex-Weeks commented 3 months ago

Summary

When you add an item to a cart via the API, if you specify a price with the item, the cart does not honor the price you supplied.

Examples

Steps to reproduce:

  1. Have a logged in user
  2. Get their cart id
  3. Add an item to their cart via the API
  4. When adding the item specify a price that is different than the catalog price
  5. Go to the users cart, the price will not be the specified price.

Proposed solution

No response

Release note

No response

Triage and priority

m2-assistant[bot] commented 3 months ago

Hi @Lex-Weeks. Thank you for your report. To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

m2-assistant[bot] commented 3 months ago

Hi @engcom-Bravo. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-Bravo commented 3 months ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 3 months ago

Hi @engcom-Bravo. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 3 months ago

Hi @engcom-Bravo, here is your Magento Instance: https://1c05d0cc8d4428e93f005ab0da3dd2d5.instances-prod.magento-community.engineering Admin access: https://1c05d0cc8d4428e93f005ab0da3dd2d5.instances-prod.magento-community.engineering/admin_5c44 Login: fc2aa57f Password: 1e95eb4fd2b4

engcom-Bravo commented 3 months ago

Hi @Lex-Weeks,

Thanks for your reporting and collaboration.

AS per the Magento devdocs https://developer.adobe.com/commerce/webapi/rest/tutorials/orders/order-add-items/ the payload will be without price field if we are adding the price field we are getting Decoding Error.

Screenshot 2024-07-30 at 12 23 14

It seems to be an expected behaviour of Magento.

Hence we are considering this as a improvement and marking this as feature request.

Thanks.

Lex-Weeks commented 3 months ago

It seems there may be a comma missing after price, which would be causing the decoding error. As per the documentation PUT carts/{cartId}/items/{itemId} does accept price as a parameter.

add_item

ignaciomnzz commented 1 month ago

@engcom-Bravo You have an error in the payload.

issue

I confirm the issue occurs also in version 2.4.6. I am having the same problem, the price is not updated.

Lex-Weeks commented 1 month ago

@ignaciomnzz I have talked to adobe commercial support and they effectively said that they are not going to fix this. Took a different path in writing our own endpoint that leverages the built in item functions to do this.

$item->setCustomPrice($YourPriceHere);
$item->setOriginalCustomPrice($YourPriceHere);