feat: refactor cart item handling to use mapped buyable types and improve method signatures

This commit is contained in:
2026-07-14 16:43:00 -03:00
parent ab042acf9b
commit 341cc16ee8
8 changed files with 54 additions and 31 deletions

View File

@@ -138,11 +138,11 @@ class CheckoutService
}
// Check tenant relation depending on type
if ($item->buyable_type === 'variant' && $buyable->product->tenant_codigo !== $tenant->codigo) {
if ($item->buyable_type === \App\Domains\Catalog\Models\ProductVariant::class && $buyable->product->tenant_codigo !== $tenant->codigo) {
throw ValidationException::withMessages([
'cart_id' => 'One or more product variants do not belong to the tenant.',
]);
} elseif ($item->buyable_type === 'bundle' && $buyable->tenant_codigo !== $tenant->codigo) {
} elseif ($item->buyable_type === \App\Domains\Bundle\Models\Bundle::class && $buyable->tenant_codigo !== $tenant->codigo) {
throw ValidationException::withMessages([
'cart_id' => 'One or more bundles do not belong to the tenant.',
]);