-
Notifications
You must be signed in to change notification settings - Fork 474
Expand file tree
/
Copy pathOrderLineCapabilities.php
More file actions
44 lines (36 loc) · 1.19 KB
/
OrderLineCapabilities.php
File metadata and controls
44 lines (36 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace Lunar\Base;
use Lunar\Models\OrderLine;
class OrderLineCapabilities implements OrderLineCapabilitiesInterface
{
public function isRefundable(OrderLine $orderLine): bool
{
return $orderLine->order->isPlaced()
&& in_array($orderLine->type, ['physical', 'digital'], true)
&& $orderLine->total->value > 0;
}
public function isCancellable(OrderLine $orderLine): bool
{
return $orderLine->order->isPlaced()
&& $orderLine->type === 'digital'
&& $orderLine->total->value > 0;
}
public function requiresPhysicalReturn(OrderLine $orderLine): bool
{
return $orderLine->order->isPlaced() && $orderLine->type === 'physical';
}
public function createsEntitlement(OrderLine $orderLine): bool
{
return $orderLine->type === 'digital';
}
public function supportsEndOfTerm(OrderLine $orderLine): bool
{
return false;
}
public function allowsAccountCredit(OrderLine $orderLine): bool
{
return $orderLine->order->isPlaced()
&& in_array($orderLine->type, ['physical', 'digital'], true)
&& $orderLine->total->value > 0;
}
}