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 480ee70393
commit c05206cc51
7 changed files with 50 additions and 31 deletions

View File

@@ -45,20 +45,20 @@ class CartService
];
}
public function updateItemQuantity(Tenant $tenant, Request $request, string $buyableType, int $buyableId, int $quantity): Cart
public function updateItemQuantity(Tenant $tenant, Request $request, int $cartItemId, int $quantity): Cart
{
$identity = $this->requireIdentity($request);
$cart = $this->findCartOrFail($tenant, $identity);
$cart->updateItem($buyableType, $buyableId, $quantity);
$cart->updateItem($cartItemId, $quantity);
return $this->loadCart($cart);
}
public function removeItem(Tenant $tenant, Request $request, string $buyableType, int $buyableId): Cart
public function removeItem(Tenant $tenant, Request $request, int $cartItemId): Cart
{
$identity = $this->requireIdentity($request);
$cart = $this->findCartOrFail($tenant, $identity);
$cart->removeItem($buyableType, $buyableId);
$cart->removeItem($cartItemId);
return $this->loadCart($cart);
}