PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.6
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.6
1.6.6 1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 All 49 releases
← All changes | app/Services/Email/EmailPreviewService.php +53 -2 1.3.25 → 1.6.6 View file →
@@ -30,8 +30,18 @@
30 30 'trial_end_date' => DateTime::gmtNow()->addDays(3)->format('Y-m-d H:i:s'),
31 31 ],
32 32 ];
33 33
34 + if (Str::startsWith($template, 'order.reminder.renewal_overdue.')) {
35 + if (Str::contains($template, '.final.')) {
36 + $previewData['reminder']['stage'] = 'overdue_7';
37 + } elseif (Str::contains($template, '.followup.')) {
38 + $previewData['reminder']['stage'] = 'overdue_3';
39 + } else {
40 + $previewData['reminder']['stage'] = 'overdue_1';
41 + }
42 + }
43 +
34 44 if (Str::startsWith($template, 'subscription.')) {
35 45 $previewData['transaction'] = $subscription->getLatestTransaction();
36 46
37 47 if (Str::contains($template, 'trial_end')) {
@@ -37,8 +47,12 @@
37 47 if (Str::contains($template, 'trial_end')) {
38 48 $previewData['reminder']['stage'] = 'trial_end_3';
39 49 }
40 50
51 + if (Str::contains($template, 'renewal_failed')) {
52 + $previewData['error'] = __('Your card was declined.', 'fluent-cart');
53 + }
54 +
41 55 if (Str::contains($template, 'canceled')) {
42 56 $previewData['reason'] = __('canceled on customer request', 'fluent-cart');
43 57 $previewData['subscription'] = $this->getDummySubscription($previewData['order']);
44 58 }
@@ -59,13 +73,18 @@
59 73
60 74 private function getDummyTransaction(): object
61 75 {
62 76 return new class {
63 - public $created_at = '';
77 + public $created_at;
64 78 public $total = 4900;
65 79 public $vendor_charge_id = 'ch_preview_123';
66 80 public $order = null;
67 81
82 + public function __construct()
83 + {
84 + $this->created_at = DateTime::gmtNow();
85 + }
86 +
68 87 public function getPaymentMethodText()
69 88 {
70 89 return 'card';
71 90 }
@@ -76,9 +95,9 @@
76 95 {
77 96 $customer = $this->getDummyCustomer();
78 97 $transaction = $this->getDummyTransaction();
79 98
80 - return new class($customer, $transaction, new Collection()) {
99 + $order = new class($customer, $transaction, new Collection()) {
81 100 public $id = 1001;
82 101 public $uuid = 'preview-order-uuid';
83 102 public $invoice_no = 'FC-1001';
84 103 public $customer;
@@ -98,8 +117,9 @@
98 117 public $total_amount = 4900;
99 118 public $total_paid = 0;
100 119 public $total_refund = 0;
101 120 public $payment_status = 'pending';
121 + public $config = [];
102 122 private $latestTransaction;
103 123
104 124 public function __construct($customer, $transaction, $emptyCollection)
105 125 {
@@ -139,8 +159,26 @@
139 159 {
140 160 return '#';
141 161 }
142 162
163 + public function getMeta($metaKey, $defaultValue = false)
164 + {
165 + if ($metaKey === 'due_date') {
166 + return gmdate('Y-m-d H:i:s', strtotime('+7 days'));
167 + }
168 + return $defaultValue;
169 + }
170 +
171 + public function isReverseChargeTaxOrder()
172 + {
173 + return false;
174 + }
175 +
176 + public function getOrderRcMode()
177 + {
178 + return 'fixed';
179 + }
180 +
143 181 public function getLatestTransaction()
144 182 {
145 183 return $this->latestTransaction;
146 184 }
@@ -154,8 +192,14 @@
154 192 {
155 193 return new Collection([]);
156 194 }
157 195 };
196 +
197 + // Templates reach the order through the transaction too (e.g. the
198 + // renewal admin email's $transaction->order->getViewUrl('admin')).
199 + $transaction->order = $order;
200 +
201 + return $order;
158 202 }
159 203
160 204 private function getDummySubscription($order): object
161 205 {
@@ -165,8 +209,9 @@
165 209 return new class($customer, $transaction, $order) {
166 210 public $id = 2001;
167 211 public $uuid = 'preview-subscription-uuid';
168 212 public $item_name = 'Sample Subscription';
213 + public $display_item_name = 'Sample Subscription';
169 214 public $billing_interval = 'yearly';
170 215 public $next_billing_date;
171 216 public $recurring_total = 4900;
172 217 public $status = 'active';
@@ -179,8 +224,9 @@
179 224 {
180 225 $this->customer = $customer;
181 226 $this->latestTransaction = $transaction;
182 227 $this->order = $order;
228 + $transaction->order = $order;
183 229 $this->next_billing_date = \FluentCart\App\Services\DateTime\DateTime::gmtNow()->addDays(30)->format('Y-m-d H:i:s');
184 230 $this->trial_ends_at = \FluentCart\App\Services\DateTime\DateTime::gmtNow()->addDays(3)->format('Y-m-d H:i:s');
185 231 }
186 232
@@ -196,8 +242,13 @@
196 242
197 243 public function getReactivateUrl()
198 244 {
199 245 return '#';
246 + }
247 +
248 + public function getPaymentMethodText()
249 + {
250 + return 'Visa ***4242';
200 251 }
201 252 };
202 253 }
203 254 }