|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
/** |
|
5
|
|
|
* @authors: Nicolaas [at] Sunny Side Up .co.nz |
|
6
|
|
|
* @package: ecommerce |
|
7
|
|
|
* @sub-package: model |
|
8
|
|
|
* @inspiration: Silverstripe Ltd, Jeremy |
|
9
|
|
|
**/ |
|
10
|
|
|
class OrderStep_SentAdminNotification extends OrderStep implements OrderStepInterface |
|
11
|
|
|
{ |
|
12
|
|
|
/** |
|
13
|
|
|
* @var string |
|
14
|
|
|
*/ |
|
15
|
|
|
protected $emailClassName = 'Order_ReceiptEmail'; |
|
16
|
|
|
|
|
17
|
|
|
private static $defaults = array( |
|
|
|
|
|
|
18
|
|
|
'CustomerCanEdit' => 0, |
|
19
|
|
|
'CustomerCanCancel' => 0, |
|
20
|
|
|
'CustomerCanPay' => 1, |
|
21
|
|
|
'Name' => 'Send Admin Notification', |
|
22
|
|
|
'Code' => 'NOTIFIED', |
|
23
|
|
|
'ShowAsInProcessOrder' => 1, |
|
24
|
|
|
'SendInvoiceToCustomer' => 1, |
|
25
|
|
|
); |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* can run step once order has been submitted. |
|
29
|
|
|
* NOTE: must have a payment (even if it is a fake payment). |
|
30
|
|
|
* The reason for this is if people pay straight away then they want to see the payment shown on their invoice. |
|
31
|
|
|
* |
|
32
|
|
|
* @param Order object |
|
33
|
|
|
* |
|
34
|
|
|
* @return bool - true if the current step is ready to be run... |
|
35
|
|
|
**/ |
|
36
|
|
|
public function initStep(Order $order) |
|
37
|
|
|
{ |
|
38
|
|
|
if ($order->IsSubmitted()) { |
|
|
|
|
|
|
39
|
|
|
return true; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
return false; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* send invoice to customer |
|
47
|
|
|
* or in case this is not selected, it will send a message to the shop admin only |
|
48
|
|
|
* The latter is useful in case the payment does not go through (and no receipt is received). |
|
49
|
|
|
* |
|
50
|
|
|
* @param DataObject $order Order |
|
51
|
|
|
* |
|
52
|
|
|
* @return bool |
|
53
|
|
|
**/ |
|
54
|
|
|
public function doStep(Order $order) |
|
55
|
|
|
{ |
|
56
|
|
|
return $this->sendEmailForStep( |
|
57
|
|
|
$order, |
|
58
|
|
|
$subject = $this->EmailSubject, |
|
|
|
|
|
|
59
|
|
|
$message = '', |
|
60
|
|
|
$resend = false, |
|
61
|
|
|
$adminOnlyOrToEmail = true, |
|
62
|
|
|
$this->getEmailClassName() |
|
63
|
|
|
); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* can do next step once the invoice has been sent or in case the invoice does not need to be sent. |
|
68
|
|
|
* |
|
69
|
|
|
* @param Order $order |
|
70
|
|
|
* |
|
71
|
|
|
* @return OrderStep | Null (next step OrderStep object) |
|
|
|
|
|
|
72
|
|
|
**/ |
|
73
|
|
|
public function nextStep(Order $order) |
|
74
|
|
|
{ |
|
75
|
|
|
if ($this->hasBeenSent($order)) { |
|
76
|
|
|
return parent::nextStep($order); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
return; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* Allows the opportunity for the Order Step to add any fields to Order::getCMSFields. |
|
84
|
|
|
* |
|
85
|
|
|
*@param FieldList $fields |
|
86
|
|
|
*@param Order $order |
|
87
|
|
|
* |
|
88
|
|
|
*@return FieldList |
|
89
|
|
|
**/ |
|
90
|
|
|
public function addOrderStepFields(FieldList $fields, Order $order) |
|
91
|
|
|
{ |
|
92
|
|
|
$fields = parent::addOrderStepFields($fields, $order); |
|
93
|
|
|
$title = _t('OrderStep.CANADDGENERALLOG', ' ... if you want to make some notes about this step then do this here...'); |
|
94
|
|
|
$fields->addFieldToTab('Root.Next', $order->getOrderStatusLogsTableField('OrderStatusLog', $title), 'ActionNextStepManually'); |
|
95
|
|
|
|
|
96
|
|
|
return $fields; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* For some ordersteps this returns true... |
|
101
|
|
|
* |
|
102
|
|
|
* @return bool |
|
103
|
|
|
**/ |
|
104
|
|
|
protected function hasCustomerMessage() |
|
105
|
|
|
{ |
|
106
|
|
|
return false; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* Explains the current order step. |
|
111
|
|
|
* |
|
112
|
|
|
* @return string |
|
113
|
|
|
*/ |
|
114
|
|
|
protected function myDescription() |
|
115
|
|
|
{ |
|
116
|
|
|
return _t( |
|
117
|
|
|
'OrderStep.SENTADMIN_NOTIFICATION', |
|
118
|
|
|
'Admin notification to admin about order.' |
|
119
|
|
|
); |
|
120
|
|
|
} |
|
121
|
|
|
} |
|
122
|
|
|
|