File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -224,9 +224,17 @@ public function getOrderDetail($order)
224
224
225
225
public function getSupportEmail ($ store = null )
226
226
{
227
+ // Serves as the dafault email
227
228
$ domain = Mage::getStoreConfig ('zendesk/general/domain ' , $ store );
228
229
$ email = 'support@ ' . $ domain ;
229
230
231
+ // Get the actual default email from the API, return the default if somehow none is found
232
+ $ defaultRecipient = Mage::getModel ('zendesk/api_supportaddresses ' )->getDefault ();
233
+
234
+ if (!is_null ($ defaultRecipient )) {
235
+ $ email = $ defaultRecipient ['email ' ];
236
+ }
237
+
230
238
return $ email ;
231
239
}
232
240
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ class Zendesk_Zendesk_Model_Api_SupportAddresses extends Zendesk_Zendesk_Model_Api_Users
4
+ {
5
+ public function all ()
6
+ {
7
+ $ page = 1 ;
8
+ $ addresses = array ();
9
+
10
+ while ($ page ) {
11
+ $ response = $ this ->_call ('recipient_addresses.json?page= ' . $ page );
12
+ $ addresses = array_merge ($ addresses , $ response ['recipient_addresses ' ]);
13
+ $ page = is_null ($ response ['next_page ' ]) ? 0 : $ page + 1 ;
14
+ }
15
+
16
+ return $ addresses ;
17
+ }
18
+
19
+ /**
20
+ * Gets the default support address.
21
+ * @return array The default support address email.
22
+ */
23
+ public function getDefault ()
24
+ {
25
+ $ address = null ;
26
+
27
+ foreach ($ this ->all () as $ recipient_address ) {
28
+ if ($ recipient_address ['default ' ]) {
29
+ $ address = $ recipient_address ;
30
+ break ;
31
+ }
32
+ }
33
+
34
+ return $ address ;
35
+ }
36
+ }
You can’t perform that action at this time.
0 commit comments