-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Description
Preconditions and environment
- Magento version : 2.4.7 (but probably valid for all versions)
- Get a recent order
- Get an old order still processing status
- Get a Sales Rules saying you will earn some fidelity points when the order is shipped (We setup that using Amasty Promo but the core issue is also in Magento).
Steps to reproduce
1 - Make an order today
2 - Ship it from back office
3 - You can see the sales rule is properly applied
4 - To to an older order, like a few week or monrth
5 - Ship it
6 - You can see the sales rule is not properly applied
Expected result
We expect the sales rule to be properly applied if the condition is met by the product from the order. But it's not
Actual result
The reason behind all that lies on the core file
vendor/magento/module-sales-rule/Model/Rule/Condition/Product/Subselect.php
And more specifically in the validate method
/**
* Validate
*
* @param \Magento\Framework\Model\AbstractModel $model
* @return bool
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function validate(\Magento\Framework\Model\AbstractModel $model)
{
if (!$this->getConditions()) {
return false;
}
$attr = $this->getAttribute();
$total = 0;
foreach ($model->getQuote()->getAllVisibleItems() as $item) {
The validate method check condition by iterating the Quote. But the issue doing that is that the Quote is not a consistent object to rely on as she can be deleted after X days depending on your configuration.
Si if you ship your order after the Quote suppression, your shipping rule is not applied anymore !
Magento should inclure a fall back to that method to work from the Order object instead of the Quote.
I agree that is most cases, Quote validity stand for a month and the shipping will probably be below that period. But considering the quote validity is dynamic due to configuration and can be modified (in my specific scenario we have Quote validity for 7 days only). So this use case where the sales rules need to be checked after a full week is not that rare.
Additional information
No response
Release note
No response
Triage and priority
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status