When creating an order, I experience an "Undefined array key 2" error
Steps To Reproduce:
Add 2 of the same products without merging and create the order
It seems that the mapping to order lines can't handle when there is 2 of the same product variants in the cart
foreach ($order->lines as $orderLine) {
$cartLine = $cart->lines->first(function ($cartLine) use ($orderLine) {
return $cartLine->purchasable_type == $orderLine->purchasable_type &&
$cartLine->purchasable_id == $orderLine->purchasable_id;
});
if ($cartLine) {
$cartLinesMappedToOrderLines[$cartLine->id] = $orderLine;
}
}
When it iterates through the 2nd line, the $cartline that is returned is the first one and then it overrides the same key in $cartLinesMappedToOrderLines .
This thing causes an issue when trying to reference the line later in the discountBreakdown and the key is undefined
Expected Behaviour:
To be able to create an order with no issue
Actual Behaviour:
When creating an order, I experience an "Undefined array key 2" error
Steps To Reproduce:
Add 2 of the same products without merging and create the order
It seems that the mapping to order lines can't handle when there is 2 of the same product variants in the cart
When it iterates through the 2nd line, the
$cartline
that is returned is the first one and then it overrides the same key in$cartLinesMappedToOrderLines
.This thing causes an issue when trying to reference the line later in the discountBreakdown and the key is undefined