Salamo Alaykom Magento team,
NB : All the products are configurable
The test products :
Product 1 :
Chaz Kangeroo Hoodie
SKU: MH01-XS-Black
Color: Black
Size: XS
Product 2 :
Chaz Kangeroo Hoodie
SKU: MH01-M-Orange
Color: Orange
Size: M
- Add the 2 configurable products above to the cart [product 1 qty 2 product 2 qty 3]
- Place the order
- Invoice & ship partially the order
- Cancel the order
Magento shows Cancel button after i canceled the order
When i click on Cancel again, it returns to the old state
See the video
https://youtu.be/hA7Ov6t3P-Q
Other issues :
When i cancel the order --> no stock return of the item canceled
- Before the order
| Product |
qty on stock |
| product 1 |
100 |
| product 2 |
100 |
- Order then invoice, ship and cancel
| Product |
qty_ordered |
qty_invoiced |
qty_shipped |
qty_canceled |
| product 1 |
2 |
1 |
2 |
0 |
| product 2 |
3 |
2 |
0 |
1 |
- After the order
Actual result
| Product |
qty on stock |
| product 1 |
98 |
| product 2 |
97 |
Expected result
| Product |
qty on stock |
| product 1 |
98 |
| product 2 |
98 |
- Before the order
| Product |
qty on stock |
| product 1 |
100 |
| product 2 |
100 |
- Order then invoice, ship and cancel
| Product |
qty_ordered |
qty_invoiced |
qty_shipped |
qty_canceled |
| product 1 |
2 |
0 |
1 |
1 |
| product 2 |
3 |
0 |
2 |
1 |
- After the order
Actual result
| Product |
qty on stock |
| product 1 |
100 |
| product 2 |
100 |
Expected Result
| Product |
qty on stock |
| product 1 |
99 |
| product 2 |
98 |
- Before the order
| Product |
qty on stock |
| product 1 |
100 |
| product 2 |
100 |
- Order then invoice, ship and cancel
| Product |
qty_ordered |
qty_invoiced |
qty_shipped |
qty_canceled |
| product 1 |
2 |
1 |
0 |
1 |
| product 2 |
3 |
2 |
0 |
1 |
- After the order
Actual result
| Product |
qty on stock |
| product 1 |
98 |
| product 2 |
97 |
Expected Result
| Product |
qty on stock |
| product 1 |
99 |
| product 2 |
98 |
- Before the order
| Product |
qty on stock |
| product 1 |
100 |
| product 2 |
100 |
- Order then invoice, ship, refund , cancel
Actual result
| Product |
qty_ordered |
qty_invoiced |
qty_shipped |
qty_refunded |
qty_canceled |
| product 1 |
2 |
1 |
1 |
1 |
0 |
| product 2 |
3 |
2 |
1 |
1 |
1 |
Expected Result
| Product |
qty_ordered |
qty_invoiced |
qty_shipped |
qty_refunded |
qty_canceled |
| product 1 |
2 |
1 |
1 |
1 |
1 |
| product 2 |
3 |
2 |
1 |
1 |
1 |
In the case of the " Product 1"
QtyToCancel = min(QtyToInvoice,QtyToShip)
QtyToCancel =min(1,0) = 0 ==> False
QtyToCancel must be 1 because QtyToShip must be 1 not 0
QtyToShip must be 1 because , qty_ordered=2 , qty_invoiced=1 ,qty_shipped=1 then i refunded 1 qty
So the remaining qty to invoice & to ship is 1
public function getQtyToCancel()
{
$qtyToCancel = min($this->getQtyToInvoice(), $this->getQtyToShip());
return max($qtyToCancel, 0);
}
public function getQtyToInvoice()
{
if ($this->isDummy()) {
return 0;
}
$qty = $this->getQtyOrdered() - $this->getQtyInvoiced() - $this->getQtyCanceled();
return max($qty, 0);
}
public function getQtyToShip()
{
if ($this->isDummy(true)) {
return 0;
}
return $this->getSimpleQtyToShip();
}
public function getSimpleQtyToShip()
{
$qty = $this->getQtyOrdered() - $this->getQtyShipped() - $this->getQtyRefunded() - $this->getQtyCanceled();
return max($qty, 0);
}
- After the order
Actual result
| Product |
qty on stock |
| product 1 |
98 |
| product 2 |
97 |
Expected Result
| Product |
qty on stock |
| product 1 |
99 |
| product 2 |
98 |
I hope that everything is clear for you