You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
observer "inventory_sales_virtual_source_deduction_processor" destroys checkout for free virtual and downloadable products, when store pickup is active
#3372
Open
norgeindian opened this issue
Feb 2, 2023
· 1 comment
Create a custom stock and source and activate in-store pickup for it.
Create a product A with a price of $10, assign the source with a qty of 99 to it. Set it to be in stock
Create a virtual product B with a price of $0, assign the source with a qty of 99 to it. Set it to be in stock.
Create two customers A and B
Purchase the product A with the logged in customer A and order it via in-store pickup
Now log out and log in as customer B
Try to purchase the free virtual product B in the checkout.
Expected result (*)
I would expect the order to be successfully placed.
Actual result (*)
After trying to purchase in the checkout, I get the error message No entry with orderID = xxx and the order can not be fulfilled.
We debugged that issue for a while and found out, in the end, that the observer inventory_sales_virtual_source_deduction_processor is the reason for this issue.
The call stack is the following:
What happens in the end, is, that the VirtualSourceDeductionProcessor starts to create a list of all orders, which still need to be collected from the in-store pickup location. (see \Magento\InventoryInStorePickupSales\Model\SourceSelection\GetActiveStorePickupOrdersBySource::execute).
It fails in the end, when it starts loading these orders.
The reason for that is, that free orders are invoiced directly during the checkout process.
When the old order A is now loaded, the plugin authorization is calling \Magento\Sales\Model\ResourceModel\Order\Plugin\Authorization::afterLoad, which calls \Magento\Sales\Model\ResourceModel\Order\Plugin\Authorization::isAllowed.
As the user context is still customer in the checkout, this check returns false, as user B is not allowed to load the order of user A.
For virtual products, which cost more than $0, this does not happen, as the invoice process starts later and this way, the check is not run.
Our workaround for this issue is to disable the observer completely, as we are lucky and don't need to care about stock in the virtual products of our project. But in general it would be great to find a better solution here to fix this issue properly.
The text was updated successfully, but these errors were encountered:
Preconditions (*)
magento/module-inventory-shipping 1.2.2
2.4.5-p1
Steps to reproduce (*)
sales/minimum_order/active
to 0carriers/instore/active
carriers/instore/price
to0.00
Expected result (*)
Actual result (*)
No entry with orderID = xxx
and the order can not be fulfilled.We debugged that issue for a while and found out, in the end, that the observer
inventory_sales_virtual_source_deduction_processor
is the reason for this issue.The call stack is the following:
What happens in the end, is, that the
VirtualSourceDeductionProcessor
starts to create a list of all orders, which still need to be collected from the in-store pickup location. (see\Magento\InventoryInStorePickupSales\Model\SourceSelection\GetActiveStorePickupOrdersBySource::execute
).It fails in the end, when it starts loading these orders.
The reason for that is, that free orders are invoiced directly during the checkout process.
When the old order A is now loaded, the plugin
authorization
is calling\Magento\Sales\Model\ResourceModel\Order\Plugin\Authorization::afterLoad
, which calls\Magento\Sales\Model\ResourceModel\Order\Plugin\Authorization::isAllowed
.As the user context is still customer in the checkout, this check returns false, as user B is not allowed to load the order of user A.
For virtual products, which cost more than $0, this does not happen, as the invoice process starts later and this way, the check is not run.
Our workaround for this issue is to disable the observer completely, as we are lucky and don't need to care about stock in the virtual products of our project. But in general it would be great to find a better solution here to fix this issue properly.
The text was updated successfully, but these errors were encountered: