Closed Darkwolf81 closed 5 years ago
Hi @Darkwolf81. Thank you for your report. To help us process this issue please make sure that you provided the following information:
Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:
@magento-engcom-team give me 2.3-develop instance
- upcoming 2.3.x release
For more details, please, review the Magento Contributor Assistant documentation.
@Darkwolf81 do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?
@magento-engcom-team give me 2.3-develop instance
Hi @Darkwolf81. Thank you for your request. I'm working on Magento 2.3-develop instance for you
Hi @Darkwolf81, here is your Magento instance.
Admin access: https://i-22215-2-3-develop.instances.magento-community.engineering/admin
Login: admin
Password: 123123q
Instance will be terminated in up to 3 hours.
I could reproduct the issue in vanilla magento. Product price is 17 $, API custom price was 9 $, order is still 17 $.
Hi @engcom-backlog-nazar. 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:
[ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).Details
If the issue has a valid description, the label Issue: Format is valid
will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid
appears.
[ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description
label to the issue by yourself.
[ ] 3. Add Component: XXXXX
label(s) to the ticket, indicating the components it may be related to.
[ ] 4. Verify that the issue is reproducible on 2.3-develop
branchDetails
- Add the comment @magento-engcom-team give me 2.3-develop instance
to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.3-develop
branch, please, add the label Reproduced on 2.3.x
.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
[ ] 5. Verify that the issue is reproducible on 2.2-develop
branch. Details
- Add the comment @magento-engcom-team give me 2.2-develop instance
to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.2-develop
branch, please add the label Reproduced on 2.2.x
[ ] 6. Add label Issue: Confirmed
once verification is complete.
[ ] 7. Make sure that automatic system confirms that report has been added to the backlog.
Hi @Darkwolf81, thank you for you report, you can use many ways to set custom price, one of this is observer and plugin.
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="checkout_cart_product_add_after">
<observer name="customprice" instance="Test\Hello\Observer\CustomPrice" />
</event>
</config>
namespaceTest\Hello\Observer;
use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\App\RequestInterface;
class CustomPrice implements ObserverInterface
{
public function execute(\Magento\Framework\Event\Observer $observer) {
$item = $observer->getEvent()->getData('quote_item');
$item = ( $item->getParentItem() ? $item->getParentItem() : $item );
$price = 100; //set your price here
$item->setCustomPrice($price);
$item->setOriginalCustomPrice($price);
$item->getProduct()->setIsSuperMode(true);
}
}
Thanks for collaboration.
Thanks for this. I tried the code, but it dont work in the rest api, event is not fired. And i dont understand why this is not a bug. It is possible to tell a price value in the rest order product call. But it is ignored / overridden by the original price. That worked in Magento 1, and we use this for long time, then it should work in Magento 2, too.
I am running into the exact same issue.
How is this not a bug? API's are designed to utilize internal functionality without having to create plugins. Second, if that parameter is not supposed to do anything, then why does the parameter exist in the first place? Please, reopen this issue.
Hi @shikhamis11. 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:
[ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).Details
If the issue has a valid description, the label Issue: Format is valid
will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid
appears.
[ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description
label to the issue by yourself.
[ ] 3. Add Component: XXXXX
label(s) to the ticket, indicating the components it may be related to.
[ ] 4. Verify that the issue is reproducible on 2.3-develop
branchDetails
- Add the comment @magento give me 2.3-develop instance
to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.3-develop
branch, please, add the label Reproduced on 2.3.x
.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
[ ] 5. Verify that the issue is reproducible on 2.2-develop
branch. Details
- Add the comment @magento give me 2.2-develop instance
to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.2-develop
branch, please add the label Reproduced on 2.2.x
[ ] 6. Add label Issue: Confirmed
once verification is complete.
[ ] 7. Make sure that automatic system confirms that report has been added to the backlog.
:white_check_mark: Confirmed by @shikhamis11
Thank you for verifying the issue. Based on the provided information internal tickets MAGETWO-99855
, MAGETWO-99856
were created
Issue Available: @shikhamis11, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.
Hi @shikhamis11. Thank you for working on this issue. Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:
[ ] 1. Add/Edit Component: XXXXX
label(s) to the ticket, indicating the components it may be related to.
[ ] 2. Verify that the issue is reproducible on 2.3-develop
branchDetails
- Add the comment @magento give me 2.3-develop instance
to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.3-develop
branch, please, add the label Reproduced on 2.3.x
.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
[ ] 3. Verify that the issue is reproducible on 2.2-develop
branch. Details
- Add the comment @magento give me 2.2-develop instance
to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.2-develop
branch, please add the label Reproduced on 2.2.x
[ ] 4. If the issue is not relevant or is not reproducible any more, feel free to close it.
hi @Darkwolf81 & @teqt ,
while working on this issue I found that there is event available that is called during rest api and with this you can change the price of the product while add to cart in REST API
<event name="sales_quote_item_set_product"> </event>
@magento-engcom-team I'm testing this on the 2.3-develop and this is not currently working. Where can I check tickets MAGETWO-99855 and MAGETWO-99856. Are they not public? Can you update me on the state of these? Thanks
@shikhamis11 did you manage to make this work without adding an observer? Thanks
Has the original issue been fixed at all? Is it possible to set a cart item's price when adding the item via the REST API?
@shikhamis11 @magento-engcom-team
Is there any information on when this issue will be fixed? As this is still not working with 2.3.3
This is still an issue in 2.3.5, which is really annoying...
bump
@shikhamis11 Why was this issue closed? This remains a bug in the API.
This issue is also present when creating a negotiable quote (EE module) using the API. To circumvent the issue, I've tried a custom API endpoint which explicitly sets the custom_price value when adding items to a quote, but the custom price gets overridden later in the chain. Making it impossible to create an order using custom prices using the API.
What's the status of internal tickets MAGETWO-99856
and MAGETWO-99855
?
Magento ver. 2.4.2 issue is still present. Can we have API V2 with fix in it? 4 years pass...
Preconditions (*)
Steps to reproduce (*)
Expected result (*)
Actual result (*)
I used the same logic in Magento 1, there the custom price is used in the order. In Magento 2 i tried to debug the problem. I saw in a price setter function when the price is set, first the custom price is used, then the function called again with the store price.
I used following code to set the custom price API: /rest/V1/carts/mine/items