feat(cart): implement cart editing policies and update related functionality
This commit is contained in:
32
app/Domains/Tenant/Enums/CartEditingPolicy.php
Normal file
32
app/Domains/Tenant/Enums/CartEditingPolicy.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Tenant\Enums;
|
||||
|
||||
enum CartEditingPolicy: string
|
||||
{
|
||||
case Disabled = 'disabled';
|
||||
case QuantityAndRemove = 'quantity_and_remove';
|
||||
case Full = 'full';
|
||||
|
||||
public function allowsQuantityChanges(): bool
|
||||
{
|
||||
return $this !== self::Disabled;
|
||||
}
|
||||
|
||||
public function allowsRemoval(): bool
|
||||
{
|
||||
return $this !== self::Disabled;
|
||||
}
|
||||
|
||||
public function allowsVariantChanges(): bool
|
||||
{
|
||||
return $this === self::Full;
|
||||
}
|
||||
|
||||
public function allowsModification(): bool
|
||||
{
|
||||
return $this->allowsRemoval()
|
||||
|| $this->allowsQuantityChanges()
|
||||
|| $this->allowsVariantChanges();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user