AffinityEmail.php
2.86 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
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
<?php
class AffinityEmail {
static public function toEmail() {
return 'DL-eBay-AU-LINK-Support@ebay.com';
}
static public function installs() {
$sentcheck = get_option('ebayaffinity_sent_installs');
if (empty($sentcheck)) {
$subject = 'Seller has successfully installed the eBay Sync plugin';
$message = 'Hi Sync Support Team,<br>
<br>
Seller has successfully installed the Sync plugin.<br>
Visit website: <a href="'.htmlspecialchars(get_option('siteurl')).'">'.htmlspecialchars(get_option('siteurl')).'</a><br>
<br>
Kind Regards<br>
eBay Sync Team';
update_option('ebayaffinity_sent_installs', 1);
self::sendEmail($subject, $message);
}
}
static public function setups() {
$sentcheck = get_option('ebayaffinity_sent_setups');
if (empty($sentcheck)) {
$subject = get_option('ebayaffinity_ebayuserid').' successfully completed the seller set up process for eBay Sync';
$message = 'Hi Sync Support Team,<br>
<br>
'.get_option('ebayaffinity_ebayuserid').' has successfully completed the seller setup process.<br>
Track seller\'s progress on eBay: <a href="'.get_option('ebayaffinity_ebaysite').'usr/'.rawurlencode(get_option('ebayaffinity_ebayuserid')).'">'.htmlspecialchars(get_option('ebayaffinity_ebayuserid')).'</a><br>
<br>
Kind Regards<br>
eBay Sync Team';
str_replace("\r", "", $message);
update_option('ebayaffinity_sent_setups', 1);
self::sendEmail($subject, $message);
}
}
static public function products($itemid) {
$sentcheck = get_option('ebayaffinity_sent_products');
if (empty($sentcheck)) {
require_once(__DIR__.'/../ecommerce-adapters/AffinityDataLayer.php');
$post_id = AffinityDataLayer::findObjectIdWithGivenData('affinity_ebayitemid', $itemid);
$post = get_post($post_id);
$title = $post->post_title;
$subject = get_option('ebayaffinity_ebayuserid').' successfully listed first product on eBay';
$message = 'Hi Sync Support Team,<br>
<br>
'.get_option('ebayaffinity_ebayuserid').' has successfully listed the very first product on eBay<br>
View product: <a href="'.get_option('ebayaffinity_ebaysite').'itm/'.rawurlencode($itemid).'">'.htmlspecialchars($title).'</a><br>
Track seller\'s progress on eBay: <a href="'.get_option('ebayaffinity_ebaysite').'usr/'.rawurlencode(get_option('ebayaffinity_ebayuserid')).'">'.htmlspecialchars(get_option('ebayaffinity_ebayuserid')).'</a><br>
<br>
Kind Regards<br>
eBay Sync Team';
update_option('ebayaffinity_sent_products', 1);
self::sendEmail($subject, $message);
}
}
static public function sendEmail($subject, $message) {
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/html; charset=".get_bloginfo('charset')."" . "\r\n";
$headers .= "From: ".get_option('woocommerce_email_from_name')." <".get_option('woocommerce_email_from_address').">" . "\r\n";
$to = self::toEmail();
wp_mail($to, $subject, $message, $headers);
}
}