PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.3.27
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.3.27
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 trunk All 48 releases
fluent-cart / app / Services / TemplateService.php

TemplateService.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.3.27, at app/Services/TemplateService.php

257 lines 10.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentCart\App\Services;
4
5 use FluentCart\Api\StoreSettings;
6 use FluentCart\App\App;
7 use FluentCart\App\Vite;
8 use FluentCart\Framework\Support\Arr;
9
10 class TemplateService
11 {
12 public static function getTemplateByPathName($name, $viewData)
13 {
14 ob_start();
15 $defaultBannerImage = Vite::getAssetUrl('images/email-template/email-banner.png');
16 $viewData = Arr::wrap($viewData);
17 $viewData = array_merge($viewData, [
18 'default_banner_image' => $defaultBannerImage,
19 ]);
20 App::make('view')->render('emails.' . $name, $viewData);
21 return ob_get_clean();
22 }
23
24 public static function getInvoicePackingTemplateByPathName($name)
25 {
26 ob_start();
27 App::make('view')->render('invoice.' . $name);
28 return ob_get_clean();
29 }
30
31 public static function getCurrentFcPageType()
32 {
33 $pageId = null;
34 if (is_page() && is_main_query()) {
35 $pageId = get_queried_object_id();
36 }
37
38 static $pageType = null;
39
40 if ($pageType !== null) {
41 return $pageType; // Return cached page type
42 }
43
44 if (!$pageId) {
45 if (is_singular('fluent-products')) {
46 $pageType = 'single_product';
47 return $pageType;
48 }
49
50 if (is_tax(get_object_taxonomies('fluent-products'))) {
51 $pageType = 'product_taxonomy';
52 return $pageType;
53 }
54
55 }
56
57 $pagesConfig = (new StoreSettings())->getPagesSettings();
58
59 if (!in_array($pageId, $pagesConfig)) {
60 $pageType = '';
61 return $pageType;
62 }
63
64 // find the key of the current page ID in the pagesConfig array
65 $pageTypeKey = array_search($pageId, $pagesConfig);
66 if ($pageTypeKey === false) {
67 $pageType = '';
68 return $pageType;
69 }
70
71 $pageTypeMaps = [
72 'checkout_page_id' => 'checkout',
73 'registration_page_id' => 'registration',
74 'login_page_id' => 'login',
75 'cart_page_id' => 'cart',
76 'receipt_page_id' => 'receipt',
77 'shop_page_id' => 'shop',
78 'customer_profile_page_id' => 'customer_dashboard',
79 ];
80
81 // Return the corresponding page type
82 $pageType = $pageTypeMaps[$pageTypeKey] ?? null;
83
84 return $pageType;
85 }
86
87 public static function isFcPageType($type)
88 {
89 $currentPageType = self::getCurrentFcPageType();
90 return $currentPageType === $type;
91 }
92
93 public static function getCustomerProfileUrl($extension = '')
94 {
95 $url = (new StoreSettings())->getCustomerProfilePage();
96 $url = rtrim($url, '/');
97
98 if ($extension) {
99 // add the extension with a leading slash
100 $url .= '/' . rtrim($extension, '/');
101 }
102
103 return $url;
104 }
105
106 public static function getAdminUrl($extension = '')
107 {
108 return URL::getDashboardUrl($extension);
109 }
110
111
112 public static function getCelebration($type = 'order')
113 {
114 if (apply_filters('fluent_cart/disable_email_celebration_messages', false, ['type' => $type])) {
115 return '';
116 }
117
118 $orderCelebrations = [
119 // translators: %1$s is celebration emoji(s)
120 wp_sprintf(_x('Woo-Hoo! Another Sale to Celebrate! %1$s', 'Email Celebration', 'fluent-cart'), '🎉✨'),
121
122 // translators: %1$s is celebration emoji(s)
123 wp_sprintf(_x('Cha-Ching! Your Shop\'s Raking It In! %1$s', 'Email Celebration', 'fluent-cart'), '💰🚀'),
124
125 // translators: %1$s is celebration emoji(s)
126 wp_sprintf(_x('Yasss! New Order, Let\'s Party! %1$s', 'Email Celebration', 'fluent-cart'), '🥳🎈'),
127
128 // translators: %1$s is celebration emoji(s)
129 wp_sprintf(_x('High-Five! You Nailed Another Sale! %1$s', 'Email Celebration', 'fluent-cart'), '🙌💥'),
130
131 // translators: %1$s is celebration emoji(s)
132 wp_sprintf(_x('Boom! Your Store\'s Popping Off! %1$s', 'Email Celebration', 'fluent-cart'), '🌟🎊'),
133
134 // translators: %1$s is celebration emoji(s)
135 wp_sprintf(_x('Heck Yeah! Another Sale in the Bag! %1$s', 'Email Celebration', 'fluent-cart'), '🛍️🔥'),
136
137 // translators: %1$s is celebration emoji(s)
138 wp_sprintf(_x('Dance Party! New Order Just Dropped! %1$s', 'Email Celebration', 'fluent-cart'), '💃🕺'),
139
140 // translators: %1$s is celebration emoji(s)
141 wp_sprintf(_x('Cheers! Your Shop\'s Got Another Win! %1$s', 'Email Celebration', 'fluent-cart'), '🥂🎉'),
142
143 // translators: %1$s is celebration emoji(s)
144 wp_sprintf(_x('Jackpot! Another Sale to Celebrate! %1$s', 'Email Celebration', 'fluent-cart'), '🎰✨'),
145
146 // translators: %1$s is celebration emoji(s)
147 wp_sprintf(_x('Epic Win! Your Store\'s Crushing It! %1$s', 'Email Celebration', 'fluent-cart'), '🏆🚀'),
148
149 // translators: %1$s is celebration emoji(s)
150 wp_sprintf(_x('Sweet Victory! Another Sale to Celebrate! %1$s', 'Email Celebration', 'fluent-cart'), '🏆🎉'),
151
152 // translators: %1$s is celebration emoji(s)
153 wp_sprintf(_x('Bling Bling! Your Shop\'s Cashin\' In! %1$s', 'Email Celebration', 'fluent-cart'), '💰✨'),
154
155 // translators: %1$s is celebration emoji(s)
156 wp_sprintf(_x('Huzzah! New Order, Time to Party! %1$s', 'Email Celebration', 'fluent-cart'), '🎈🥳'),
157
158 // translators: %1$s is celebration emoji(s)
159 wp_sprintf(_x('Fist Bump! You Scored Another Sale! %1$s', 'Email Celebration', 'fluent-cart'), '👊🔥'),
160
161 // translators: %1$s is celebration emoji(s)
162 wp_sprintf(_x('Wowza! Your Store\'s on a Roll! %1$s', 'Email Celebration', 'fluent-cart'), '🚀🌟'),
163
164 // translators: %1$s is celebration emoji(s)
165 wp_sprintf(_x('Yippee! Another Sale in the Books! %1$s', 'Email Celebration', 'fluent-cart'), '🛍️🎊'),
166
167 // translators: %1$s is celebration emoji(s)
168 wp_sprintf(_x('Let\'s Groove! New Order Just Landed! %1$s', 'Email Celebration', 'fluent-cart'), '🕺💃'),
169
170 // translators: %1$s is celebration emoji(s)
171 wp_sprintf(_x('Pop the Confetti! Another Sale Win! %1$s', 'Email Celebration', 'fluent-cart'), '🎉🚨'),
172
173 // translators: %1$s is celebration emoji(s)
174 wp_sprintf(_x('Money Moves! Your Shop\'s Killing It! %1$s', 'Email Celebration', 'fluent-cart'), '💸�
175 '),
176
177 // translators: %1$s is celebration emoji(s)
178 wp_sprintf(_x('Epic Haul! Another Sale to Cheer! %1$s', 'Email Celebration', 'fluent-cart'), '🥂⚡️'),
179 ];
180
181
182 $renewalCelebrations = [
183 // translators: %1$s is celebration emoji(s)
184 wp_sprintf(_x('Your Subscription\'s Renewed! Keep Rockin\' It! %1$s', 'Email Celebration', 'fluent-cart'), '🎉🚀'),
185
186 // translators: %1$s is celebration emoji(s)
187 wp_sprintf(_x('Big News! Another Subscription Locked In! %1$s', 'Email Celebration', 'fluent-cart'), '💰✨'),
188
189 // translators: %1$s is celebration emoji(s)
190 wp_sprintf(_x('Woohoo! A Customer Renewed Their Sub! %1$s', 'Email Celebration', 'fluent-cart'), '🥳🎈'),
191
192 // translators: %1$s is celebration emoji(s)
193 wp_sprintf(_x('High-Five! Your Shop\'s Got a Renewal! %1$s', 'Email Celebration', 'fluent-cart'), '🙌🔥'),
194
195 // translators: %1$s is celebration emoji(s)
196 wp_sprintf(_x('Cha-Ching! Subscription Renewed, Boss! %1$s', 'Email Celebration', 'fluent-cart'), '💸🌟'),
197
198 // translators: %1$s is celebration emoji(s)
199 wp_sprintf(_x('Yasss! Another Loyal Sub Stays On! %1$s', 'Email Celebration', 'fluent-cart'), '🏆🎊'),
200
201 // translators: %1$s is celebration emoji(s)
202 wp_sprintf(_x('Boom! Your Store\'s Sub Count Grows! %1$s', 'Email Celebration', 'fluent-cart'), '💥🛍️'),
203
204 // translators: %1$s is celebration emoji(s)
205 wp_sprintf(_x('Hooray! A Renewal Just Hit Your Shop! %1$s', 'Email Celebration', 'fluent-cart'), '🥂⚡️'),
206
207 // translators: %1$s is celebration emoji(s)
208 wp_sprintf(_x('Confetti Time! Subscription Renewed! %1$s', 'Email Celebration', 'fluent-cart'), '🎉🚨'),
209
210 // translators: %1$s is celebration emoji(s)
211 wp_sprintf(_x('Keep Shining! Another Sub Stays With You! %1$s', 'Email Celebration', 'fluent-cart'), '🌟💪'),
212
213 // translators: %1$s is celebration emoji(s)
214 wp_sprintf(_x('Party On! Your Shop\'s Got a Renewal! %1$s', 'Email Celebration', 'fluent-cart'), '🎈🕺'),
215
216 // translators: %1$s is celebration emoji(s)
217 wp_sprintf(_x('Score! A Customer Renewed Their Plan! %1$s', 'Email Celebration', 'fluent-cart'), '�
218 ✨'),
219
220 // translators: %1$s is celebration emoji(s)
221 wp_sprintf(_x('Woot Woot! Subscription Renewal Alert! %1$s', 'Email Celebration', 'fluent-cart'), '🛵🎉'),
222
223 // translators: %1$s is celebration emoji(s)
224 wp_sprintf(_x('Money Moves! Another Sub Renewed! %1$s', 'Email Celebration', 'fluent-cart'), '💰🔥'),
225
226 // translators: %1$s is celebration emoji(s)
227 wp_sprintf(_x('Epic Win! Your Shop\'s Sub is Back! %1$s', 'Email Celebration', 'fluent-cart'), '🎰⚡️'),
228
229 // translators: %1$s is celebration emoji(s)
230 wp_sprintf(_x('Cheers! A Loyal Customer Renewed! %1$s', 'Email Celebration', 'fluent-cart'), '🥳🥂'),
231
232 // translators: %1$s is celebration emoji(s)
233 wp_sprintf(_x('Fist Bump! Subscription Renewed, Champ! %1$s', 'Email Celebration', 'fluent-cart'), '👊🌟'),
234
235 // translators: %1$s is celebration emoji(s)
236 wp_sprintf(_x('Let\'s Dance! Another Sub Stays On Board! %1$s', 'Email Celebration', 'fluent-cart'), '💃🎊'),
237
238 // translators: %1$s is celebration emoji(s)
239 wp_sprintf(_x('Jackpot! Your Shop\'s Got a Renewal! %1$s', 'Email Celebration', 'fluent-cart'), '🎉🏆'),
240
241 // translators: %1$s is celebration emoji(s)
242 wp_sprintf(_x('You\'re Killing It! Another Sub Renewed! %1$s', 'Email Celebration', 'fluent-cart'), '🚀✨'),
243 ];
244
245
246 if ($type === 'renewal') {
247 $celebrations = $renewalCelebrations;
248 } else {
249 $celebrations = $orderCelebrations;
250 }
251
252 // send a random celebration message
253 return Arr::random($celebrations);
254 }
255
256 }
257