-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Fixed #22545 Status downloadable product stays pending after succesfu… #22658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed #22545 Status downloadable product stays pending after succesfu… #22658
Conversation
…uccesfull payment
Hi @shikhamis11. Thank you for your contribution
For more details, please, review the Magento Contributor Assistant documentation |
|
||
$linkstatus = \Magento\Downloadable\Model\Link\Purchased\Item::LINK_STATUS_PENDING; | ||
if( $orderStatusToEnableItem == \Magento\Sales\Model\Order\Item::STATUS_PENDING | ||
|| $orderItem->getOrder()->getStatus() == \Magento\Sales\Model\Order::STATE_COMPLETE){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we should use the getState
instead of getStatus
method in this case.
Could you please check this point?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
@@ -131,6 +131,13 @@ public function execute(\Magento\Framework\Event\Observer $observer) | |||
ScopeInterface::SCOPE_STORE | |||
); | |||
$linkPurchased->setLinkSectionTitle($linkSectionTitle)->save(); | |||
|
|||
$linkstatus = \Magento\Downloadable\Model\Link\Purchased\Item::LINK_STATUS_PENDING; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please change the variable name to $linkStatus
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
@@ -131,6 +131,13 @@ public function execute(\Magento\Framework\Event\Observer $observer) | |||
ScopeInterface::SCOPE_STORE | |||
); | |||
$linkPurchased->setLinkSectionTitle($linkSectionTitle)->save(); | |||
|
|||
$linkstatus = \Magento\Downloadable\Model\Link\Purchased\Item::LINK_STATUS_PENDING; | |||
if( $orderStatusToEnableItem == \Magento\Sales\Model\Order\Item::STATUS_PENDING |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix minor styling issues for if
statement according to PSR-2 standard (spacings etc.).
An if
structure should look like the following:
if ($a == $b
|| $b == $c
|| $c == $d
) {
// code here
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
@dmytro-ch, Thanks for your review. |
@shikhamis11, could you please also check and fix the static test failures. |
sure I will |
Hi @sidolov, thank you for the review. |
Hi @shikhamis11 ! I cannot reproduce the issue #22545 . Manual testing scenario:
Actual result: Could you take a look, please? |
hello @stoleksiy |
I have had this problem for a few months now. My website is completely down as customers cannot get downloadable purchase. Just wondering when and how this fix would be released. Thanks. |
hello @stoleksiy |
Well that can be fixed easily by applying the fixes mentioned, next to that it is easy to update this in your DB. No need for a website to be completely down for this. |
KooTjoo, Thanks for the reply. I am a skilled Magento user but not a developer. I see code changes, testing and test failures in these threads. I do not see any quick fix. If there was an option that needed to be changed in the Admin, I could do that, but I am not trained in PHP or how to update code. Yes the site is completely down, as customers buy a product but do not get the link to download the file. They try to buy it again and again until they give up. Then they think I am going to mail something and when nothing arrives I get complaints from PayPal. I contacted dozens of developers for help but only one replied and they required $900 to start looking at it. I keep hoping for a quick fix being that it is such a serious problem. Any ideas? Thanks Bob |
It is a 5 minute fix so $900?????? I don't know how to get into contact with you to discuss further otherwise we could help you. |
The Problem is that the Observer We need a function that provides the correct status instead of forcing something like this: (conditions are copied from ... ...
/**
* Function provides correct downloadLink Status
*
* @param $orderItem
* @return string
*/
protected function _getStatus($orderItem)
{
$orderStatus = \Magento\Downloadable\Model\Link\Purchased\Item::LINK_STATUS_PENDING;
$order = $orderItem->getOrder();
if (!$order || !$order->getId()) {
return $orderStatus;
}
$orderItemStatusToEnable = $this->_scopeConfig->getValue(
\Magento\Downloadable\Model\Link\Purchased\Item::XML_PATH_ORDER_ITEM_STATUS,
ScopeInterface::SCOPE_STORE,
$order->getStoreId()
);
if ($order->getState() == \Magento\Sales\Model\Order::STATE_HOLDED) {
$orderStatus = \Magento\Downloadable\Model\Link\Purchased\Item::LINK_STATUS_PENDING;
} elseif ($order->isCanceled()
|| $order->getState() == \Magento\Sales\Model\Order::STATE_CLOSED
|| $order->getState() == \Magento\Sales\Model\Order::STATE_COMPLETE
) {
$expiredStatuses = [
\Magento\Sales\Model\Order\Item::STATUS_CANCELED,
\Magento\Sales\Model\Order\Item::STATUS_REFUNDED,
];
if ($orderItem->getProductType() == \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE
|| $orderItem->getRealProductType() == \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE
) {
if ($order->isCanceled() || in_array($orderItem->getStatusId(), $expiredStatuses)) {
$orderStatus = \Magento\Downloadable\Model\Link\Purchased\Item::LINK_STATUS_EXPIRED;
} else {
$orderStatus = \Magento\Downloadable\Model\Link\Purchased\Item::LINK_STATUS_AVAILABLE;
}
}
} elseif ($order->getState() == \Magento\Sales\Model\Order::STATE_PENDING_PAYMENT) {
$orderStatus = \Magento\Downloadable\Model\Link\Purchased\Item::LINK_STATUS_PENDING_PAYMENT;
} elseif ($order->getState() == \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW) {
$orderStatus = \Magento\Downloadable\Model\Link\Purchased\Item::LINK_STATUS_PAYMENT_REVIEW;
} else {
$availableStatuses = [$orderItemStatusToEnable, \Magento\Sales\Model\Order\Item::STATUS_INVOICED];
if ($orderItem->getProductType() == \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE
|| $orderItem->getRealProductType() == \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE
) {
if ($orderItem->getStatusId() == \Magento\Sales\Model\Order\Item::STATUS_BACKORDERED
&& $orderItemStatusToEnable == \Magento\Sales\Model\Order\Item::STATUS_PENDING
&& !in_array(
\Magento\Sales\Model\Order\Item::STATUS_BACKORDERED,
$availableStatuses,
true
)
) {
$availableStatuses[] = \Magento\Sales\Model\Order\Item::STATUS_BACKORDERED;
}
if (in_array($orderItem->getStatusId(), $availableStatuses)) {
$orderStatus = \Magento\Downloadable\Model\Link\Purchased\Item::LINK_STATUS_AVAILABLE;
}
}
}
return $orderStatus;
} |
@stoleksiy I just reported this issue in #23549. It definitely still exists. I also verified it exists on the 2.3-develop instance. |
@magento run Functional Tests build |
✔️ QA passed |
Hi @shikhamis11, thank you for your contribution! |
…fter succesfu… #22658
Great, it looks like a fix is in. I have had this problem for months now. My website is completely down as customers do not get link to downloadable purchase. Just wondering when and how Release 2.3.3 would be released. Thanks. |
Fixed #22545 Status downloadable product stays pending after succesfull payment
When a downloadable product has been order and paid for download status should automatically become available. Status remains pending although order is invoiced and completed automatically by payment processor. When order is invoiced from admin it all works.
Preconditions (*)
Steps to reproduce (*)
Expected result (*)
Actual result (*)
When an order is placed and in Magento admin the order is invoiced the it works as it should. So somehow downloadable status is not changed when an order is automatically set to completed when payment is succesfull.
This issue occured only after upgrading to Magento 2.3.1 in 2.3.0 it all worked like it should.
Contribution checklist (*)