Fix access to orders in bo when a product doesn't exist

This commit is contained in:
Noah Lancien 2023-10-17 14:32:05 +02:00
parent c8090420ca
commit 57b16ddb1f

View file

@ -42,7 +42,9 @@ class ToolboxHelper
$cart = self::createVirtualCart(\collect($basket)
->map(function (object $basketItem) {
$cartItem = self::basketItemObjectToCartItem($basketItem);
$cartItem->associate(Product::query()->where('id', $cartItem->id)->first());
if (Product::query()->where('id', $cartItem->id)->exists()) {
$cartItem->associate(Product::query()->where('id', $cartItem->id)->first());
}
return $cartItem;
})
// * Enlever les produits qui ne seront pas livrés.