feat(checkout): enforce editing policy on items

This commit is contained in:
2026-08-20 10:56:19 -03:00
parent d36a929f8c
commit c8ce3b0da3
12 changed files with 272 additions and 17 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Domains\Cart\Resources;
use App\Domains\Cart\Models\Cart;
use App\Domains\Cart\Models\CartItem;
use App\Domains\Catalog\Enums\InventoryPolicy;
use App\Domains\Catalog\Models\Variant;
@@ -22,9 +23,13 @@ class CartItemResource extends JsonResource
$selectedItem = $this->selectedItem();
$imageUrl = null;
$tenant = $request->route('tenant');
$checkoutCart = $request->route('cart');
$displayImage = ! $tenant instanceof Tenant || $tenant->display_cart_item_images;
$includeVariants = $tenant instanceof Tenant
&& $tenant->cart_editing_policy->allowsVariantChanges();
&& ($checkoutCart instanceof Cart
? $tenant->checkout_editing_policy
: $tenant->cart_editing_policy)
->allowsVariantChanges();
if ($displayImage && $selectedItem?->relationLoaded('attachments')) {
$imageUrl = $selectedItem->attachments->first()?->getTemporaryUrl(1440);