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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
<?php
namespace AutomateWoo\Orders;
/** * Class StatusTransition. * * @since 5.2.0 */ class StatusTransition {
/** * @var string */ protected $old_status;
/** * @var string */ protected $new_status;
/** * StatusTransition constructor. * * @param string $old_status * @param string $new_status */ public function __construct( string $old_status, string $new_status ) { $this->old_status = $old_status; $this->new_status = $new_status; }
/** * @return string */ public function get_old_status(): string { return $this->old_status; }
/** * @return string */ public function get_new_status(): string { return $this->new_status; }
/** * Is the order transitioning from an unpaid to paid status? * * @return bool */ public function is_becoming_paid(): bool { $statuses = wc_get_is_paid_statuses(); return in_array( $this->new_status, $statuses, true ) && ! in_array( $this->old_status, $statuses, true ); }
/** * Is the order transitioning from a paid to unpaid status? * * @return bool */ public function is_becoming_unpaid(): bool { $statuses = wc_get_is_paid_statuses(); return ! in_array( $this->new_status, $statuses, true ) && in_array( $this->old_status, $statuses, true ); }
/** * Is the order transitioning from an uncounted to counted status? * * @return bool */ public function is_becoming_counted(): bool { $statuses = aw_get_counted_order_statuses( false ); return in_array( $this->new_status, $statuses, true ) && ! in_array( $this->old_status, $statuses, true ); }
/** * Is the order transitioning from a counted to uncounted status? * * @return bool */ public function is_becoming_uncounted(): bool { $statuses = aw_get_counted_order_statuses( false ); return ! in_array( $this->new_status, $statuses, true ) && in_array( $this->old_status, $statuses, true ); } }
|