PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.5.0
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.5.0
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
fluent-cart / app / Services / Renderer / CartRenderer.php

CartRenderer.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.5.0, at app/Services/Renderer/CartRenderer.php

618 lines 25.4 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\Renderer;
4
5 use FluentCart\Api\StoreSettings;
6 use FluentCart\Framework\Support\Arr;
7 use FluentCart\App\Vite;
8 use FluentCart\App\Helpers\Helper;
9 use FluentCart\App\Helpers\CartCheckoutHelper;
10 use FluentCart\App\Models\Product;
11
12 class CartRenderer
13 {
14 protected $cartItems;
15 protected $storeSettings;
16
17 protected $currentCartItem = [];
18 protected $url = [];
19
20 protected $product = [];
21
22
23 public function __construct($cartItems = [])
24 {
25 $this->storeSettings = new StoreSettings();
26 $this->cartItems = $cartItems;
27 $this->cartItems = Helper::loadBundleChild($this->cartItems, ['*']);
28 }
29
30 public function render()
31 {
32
33 ?>
34
35 <section class="fct-cart-page" aria-labelledby="fct-cart-page-title" role="region">
36 <h2 id="fct-cart-page-title" class="screen-reader-text">
37 <?php esc_html_e('Your Shopping Cart', 'fluent-cart'); ?>
38 </h2>
39
40 <?php $this->renderItems(); ?>
41
42 <?php $this->renderTotal(); ?>
43
44 <div class="fluent-cart-cart-cart-button-wrap" data-fluent-cart-cart-checkout-button-wrap>
45 <?php $this->renderCheckoutButton(); ?>
46 </div>
47
48
49 </section>
50
51 <?php
52 }
53
54
55 public function renderItems()
56 {
57 ?>
58
59 <div class="fct-cart-drawer-content-wrapper" data-fluent-cart-cart-content-wrapper role="presentation">
60 <?php $this->renderList(); ?>
61 </div>
62
63 <?php
64
65 }
66
67 public function renderDummyItems()
68 {
69 $dummy = [
70 [
71 'id' => 0,
72 'post_id' => 0,
73 'fulfillment_type' => '',
74 'other_info' => [
75 'payment_type' => '',
76 ],
77 'quantity' => 0,
78 'price' => 0,
79 'unit_price' => 0,
80 'line_total' => 0,
81 'subtotal' => 0,
82 'line_total_formatted' => '&#36;0',
83 'object_id' => 0,
84 'title' => '',
85 'post_title' => '',
86 'coupon_discount' => 0,
87 'cost' => 0,
88 'featured_media' => '',
89 'view_url' => '',
90 'variation_type' => '',
91 'shipping_charge' => 0,
92 'itemwise_shipping_charge' => 0,
93 ]
94 ];
95
96 $this->renderList($dummy);
97 }
98
99 public function renderList($items = [])
100 {
101 $items = empty($items) ? $this->cartItems : $items;
102
103
104 ?>
105 <div class="fct-cart-drawer-list" data-fluent-cart-cart-list>
106 <?php if (!empty($items)) { ?>
107 <ul class="fct-cart-drawer-list-content" data-fluent-cart-items-wrapper role="list">
108 <?php
109 foreach ($items as $cartItem) {
110 $this->currentCartItem = $cartItem;
111 $this->url = Arr::get($cartItem, 'view_url', '');
112 $this->renderItem();
113 }
114 ?>
115 </ul>
116 <?php } else { ?>
117 <?php $this->renderEmpty(); ?>
118 <?php } ?>
119 </div>
120 <?php
121
122 }
123
124 public function renderItem()
125 {
126 $title = Arr::get($this->currentCartItem, 'title', '');
127
128 ?>
129 <li data-cart-items class="fct-cart-item" role="listitem"
130 aria-label="<?php echo esc_attr($title); ?>">
131 <div class="fct-cart-item-info">
132 <?php $this->renderImage(); ?>
133 <?php $this->renderDetails(); ?>
134 </div>
135 <?php $this->renderSummary(); ?>
136 </li>
137
138 <?php
139 }
140
141 public function renderImage()
142 {
143 $image = Arr::get($this->currentCartItem, 'featured_media');
144 $title = Arr::get($this->currentCartItem, 'title', __('Product Image', 'fluent-cart'));
145
146 if (!$image) {
147 $image = Vite::getAssetUrl('images/placeholder.svg');
148 }
149
150 ?>
151
152 <div class="fct-cart-item-image">
153 <a href="<?php echo esc_url($this->url); ?>">
154 <img src="<?php echo esc_url($image); ?>"
155 data-fluent-cart-cart-list-item-image
156 alt="<?php echo esc_attr($title); ?>"
157 loading="lazy"
158 />
159 </a>
160
161 </div>
162
163 <?php
164 }
165
166 protected function getEventInfo()
167 {
168 return [
169 'item' => $this->currentCartItem,
170 'cart' => null,
171 'product' => $this->product,
172 'variant' => null,
173 ];
174 }
175
176 public function renderDetails()
177 {
178 ?>
179
180 <div class="fct-cart-item-details" role="group"
181 aria-label="<?php esc_attr_e('Product Details', 'fluent-cart'); ?>">
182 <?php
183 $this->renderTitles();
184 $this->renderItemPrice();
185 $this->renderQuantity();
186 (new CartItemRenderer($this->currentCartItem))->renderChildVariants();
187 do_action('fluent_cart/cart/line_item/line_meta', $this->getEventInfo());
188 ?>
189
190 </div>
191
192 <?php
193 }
194
195
196
197 public function renderTitles()
198 {
199 $postTitle = Arr::get($this->currentCartItem, 'post_title', '');
200 $variationTitle = Arr::get($this->currentCartItem, 'title', '');
201 $variationType = Arr::get($this->currentCartItem, 'variation_type', 'simple');
202
203 $aria_label = sprintf(
204 /* translators: 1: Post or product title */
205 esc_attr__('View %1$s', 'fluent-cart'),
206 esc_attr($postTitle)
207 );
208
209
210 ?>
211
212 <h3 class="fct-cart-item-title" data-fluent-cart-cart-list-item-title>
213 <a href="<?php echo esc_url($this->url); ?>"
214 aria-label="<?php echo esc_attr($aria_label); ?>"
215 data-fluent-cart-cart-list-item-title-url>
216 <span data-fluent-cart-cart-list-item-title-element>
217 <?php echo esc_html($postTitle); ?>
218 </span>
219 </a>
220 </h3>
221
222 <p class="fct-cart-item-variant <?php echo $variationType === 'simple' ? 'variant-title-hidden' : ''?>"
223 data-fluent-cart-cart-list-item-variation-title>
224 - <?php echo esc_html($variationTitle); ?>
225 </p>
226
227 <?php
228 }
229
230 public function renderItemPrice()
231 {
232 $price = Helper::toDecimal(Arr::get(
233 $this->currentCartItem,
234 'line_meta.original_unit_price',
235 Arr::get($this->currentCartItem, 'unit_price', 0)
236 ));
237 $quantity = Arr::get($this->currentCartItem, 'quantity', 1);
238
239 ?>
240 <div class="fct-cart-item-price <?php echo $quantity <= 1 ? 'item-price-hidden' : '' ?>">
241 <span><?php esc_html_e('Unit Price:', 'fluent-cart'); ?></span>
242 <span data-fluent-cart-cart-list-item-price aria-live="polite">
243 <?php echo esc_html($price); ?>
244 </span>
245 </div>
246
247 <?php
248 }
249
250 public function renderQuantity()
251 {
252 $quantity = Arr::get($this->currentCartItem, 'quantity', 0);
253
254 $productId = Arr::get($this->currentCartItem, 'post_id');
255 $this->product = Product::query()->with(['detail'])->find($productId);
256 $soldIndividually = false;
257 if ($this->product) {
258 $soldIndividually = $this->product->soldIndividually();
259 }
260
261 if ($soldIndividually) {
262 return;
263 }
264
265 ?>
266
267 <div class="fct-cart-item-quantity"
268 data-fluent-cart-cart-list-item-quantity-wrapper
269 role="group"
270 aria-label="<?php esc_attr_e('Change Quantity', 'fluent-cart'); ?>"
271 >
272
273 <button
274 class="qty-btn decrease-btn"
275 data-item-id="<?php echo esc_attr($this->currentCartItem['object_id']); ?>"
276 data-fluent-cart-cart-list-item-decrease-button
277 title="<?php esc_attr_e('Decrease Quantity', 'fluent-cart'); ?>"
278 aria-label="<?php esc_attr_e('Decrease Quantity', 'fluent-cart'); ?>"
279 >
280 <svg xmlns="http://www.w3.org/2000/svg" width="12" height="2" viewBox="0 0 12 2" fill="none">
281 <path d="M11.3333 1L0.666662 1" stroke="currentColor" stroke-linecap="round"
282 stroke-linejoin="round"/>
283 </svg>
284 </button>
285
286 <input
287 class="qty-value"
288 min="1"
289 data-item-id="<?php echo esc_attr($this->currentCartItem['object_id']); ?>"
290 data-fluent-cart-cart-list-item-quantity-input
291 value="<?php echo esc_attr($quantity); ?>"
292 aria-label="<?php esc_attr_e('Product Quantity', 'fluent-cart'); ?>"
293 aria-live="polite"
294 />
295
296 <button
297 class="qty-btn increase-btn"
298 data-fluent-cart-cart-list-item-increase-button
299 data-item-id="<?php echo esc_attr($this->currentCartItem['object_id']); ?>"
300 title="<?php esc_attr_e('Increase Quantity', 'fluent-cart'); ?>"
301 aria-label="<?php esc_attr_e('Increase Quantity', 'fluent-cart'); ?>"
302 >
303 <svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none">
304 <path d="M6 0.666748L6 11.3334M11.3333 6.00008L0.666672 6.00008" stroke="currentColor"
305 stroke-linecap="round" stroke-linejoin="round"></path>
306 </svg>
307 </button>
308 </div>
309
310 <?php
311 }
312
313
314 public function renderSummary()
315 {
316 ?>
317 <div class="fct-cart-item-summary" role="group"
318 aria-label="<?php esc_attr_e('Cart Item Summary', 'fluent-cart'); ?>">
319 <?php $this->renderItemTotal(); ?>
320 <?php $this->renderRemove(); ?>
321 </div>
322
323 <?php
324 }
325
326 public function renderItemTotal()
327 {
328 $quantity = Arr::get($this->currentCartItem, 'quantity', 0);
329 $displayUnitPrice = Arr::get(
330 $this->currentCartItem,
331 'line_meta.original_unit_price',
332 Arr::get($this->currentCartItem, 'unit_price', 0)
333 );
334 $totalPrice = $displayUnitPrice * $quantity;
335
336 if (Arr::get($this->currentCartItem, 'other_info.payment_type', 'onetime') == 'subscription') {
337 if (Arr::get($this->currentCartItem, 'other_info.manage_setup_fee') == 'yes') {
338 $signupFee = Arr::get($this->currentCartItem, 'other_info.signup_fee', 0);
339
340 if (Arr::get($this->currentCartItem, 'other_info.setup_fee_per_item', 'no') == 'yes') {
341 $signupFee = Arr::get($this->currentCartItem, 'other_info.signup_fee', 0) * $quantity;
342 }
343
344 $totalPrice += $signupFee;
345 }
346 }
347
348 $totalPrice = Helper::toDecimal($totalPrice);
349 $aria_label = sprintf(
350 /* translators: 1: Total price */
351 __('Total price for this item: %1$s', 'fluent-cart'),
352 $totalPrice
353 );
354
355 ?>
356 <div class="fct-cart-item-total">
357 <span
358 data-fluent-cart-cart-list-item-total-price
359 aria-live="polite"
360 aria-label="<?php echo esc_attr($aria_label); ?>"
361 >
362 <?php echo esc_html($totalPrice); ?>
363 </span>
364 </div>
365
366 <?php
367 }
368
369 public function renderTotal()
370 {
371 $cartItems = CartCheckoutHelper::make()->getItems();
372 $grossTotal = 0;
373 foreach ($cartItems as $item) {
374 $paymentType = Arr::get($item, 'other_info.payment_type', '');
375 $qty = max(1, (int) Arr::get($item, 'quantity', 1));
376 $displayUnitPrice = (int) Arr::get(
377 $item,
378 'line_meta.original_unit_price',
379 Arr::get($item, 'unit_price', 0)
380 );
381 if ($paymentType === 'subscription') {
382 if ((int) Arr::get($item, 'other_info.trial_days', 0) > 0) {
383 $grossTotal += (int) Arr::get($item, 'other_info.signup_fee', 0);
384 } else {
385 $grossTotal += $displayUnitPrice * $qty + (int) Arr::get($item, 'other_info.signup_fee', 0);
386 }
387 } else {
388 $grossTotal += $displayUnitPrice * $qty;
389 }
390 }
391 $subtotal = Helper::toDecimal($grossTotal);
392 $aria_label = sprintf(
393 /* translators: 1: Total price */
394 __('Total cart price: %1$s', 'fluent-cart'),
395 esc_attr($subtotal)
396 );
397 ?>
398
399 <div
400 data-fluent-cart-cart-total-wrapper
401 class="fct-cart-total-wrapper"
402 role="region"
403 aria-label="<?php esc_attr_e('Cart Total', 'fluent-cart'); ?>"
404 >
405 <span><?php echo esc_html__('Total', 'fluent-cart'); ?>:</span>
406 <span
407 data-fluent-cart-cart-total-price
408 aria-live="polite"
409 aria-label="<?php echo esc_attr($aria_label); ?>"
410 >
411 <?php echo esc_html($subtotal); ?>
412 </span>
413 </div>
414
415 <?php
416
417 }
418
419 public function renderRemove()
420 {
421
422 ?>
423 <div class="fct-cart-item-remove">
424 <button
425 type="button"
426 class="fct-cart-item-delete-button"
427 data-fluent-cart-cart-list-item-delete-button
428 data-item-id="<?php echo esc_attr($this->currentCartItem['object_id']); ?>"
429 aria-label="<?php esc_attr_e('Remove this item from cart', 'fluent-cart'); ?>"
430 title="<?php esc_attr_e('Remove From Cart', 'fluent-cart'); ?>"
431 >
432 <svg xmlns="http://www.w3.org/2000/svg" width="14" height="16" viewBox="0 0 14 16" fill="none">
433 <path d="M12 3.6665L11.5868 10.3499C11.4813 12.0575 11.4285 12.9113 11.0005 13.5251C10.7889 13.8286 10.5164 14.0847 10.2005 14.2772C9.56141 14.6665 8.70599 14.6665 6.99516 14.6665C5.28208 14.6665 4.42554 14.6665 3.78604 14.2765C3.46987 14.0836 3.19733 13.827 2.98579 13.5231C2.55792 12.9082 2.5063 12.0532 2.40307 10.3433L2 3.6665"
434 stroke="currentColor" stroke-linecap="round"></path>
435 <path d="M1 3.66659H13M9.70382 3.66659L9.2487 2.72774C8.94638 2.10409 8.79522 1.79227 8.53448 1.59779C8.47664 1.55465 8.4154 1.51628 8.35135 1.48305C8.06261 1.33325 7.71608 1.33325 7.02302 1.33325C6.31255 1.33325 5.95732 1.33325 5.66379 1.48933C5.59873 1.52392 5.53666 1.56385 5.4782 1.6087C5.21443 1.81105 5.06709 2.13429 4.7724 2.78076L4.36862 3.66659"
436 stroke="currentColor" stroke-linecap="round"></path>
437 <path d="M5.33334 11L5.33334 7" stroke="currentColor" stroke-linecap="round"></path>
438 <path d="M8.66666 11L8.66666 7" stroke="currentColor" stroke-linecap="round"></path>
439 </svg>
440 </button>
441 </div>
442
443 <?php
444 }
445
446 public function renderCheckoutButton()
447 {
448 ?>
449
450 <a class="checkout-button"
451 href="<?php echo esc_attr($this->storeSettings->getCheckoutPage()); ?>"
452 role="button"
453 aria-label="<?php esc_attr_e('Go to checkout page', 'fluent-cart'); ?>">
454 <?php esc_html_e('Go to Checkout', 'fluent-cart'); ?>
455 </a>
456
457 <?php
458
459 }
460
461 public function renderViewCartButton()
462 {
463 return;
464 ?>
465
466 <a class="view-cart-button"
467 href="<?php echo esc_attr($this->storeSettings->getCartPage()); ?>"
468 role="button"
469 aria-label="<?php esc_attr_e('View your shopping cart', 'fluent-cart'); ?>">
470 <?php esc_html_e('View Cart', 'fluent-cart'); ?>
471 </a>
472
473 <?php
474
475 }
476
477 public function renderEmptyCartIcon()
478 { ?>
479 <svg xmlns="http://www.w3.org/2000/svg" width="157" height="137" viewBox="0 0 157 137" fill="none">
480 <path d="M21.5017 135H134.91" stroke="#D6DCE8" stroke-width="2" stroke-miterlimit="10"
481 stroke-linejoin="round"/>
482 <path d="M8.60278 135H18.2925" stroke="#D6DCE8" stroke-width="2" stroke-miterlimit="10"
483 stroke-linejoin="round"/>
484 <path d="M23.1192 26.0612L18.0879 27.0789L21.8382 46.0468L26.8695 45.0291L23.1192 26.0612Z"
485 fill="#D5DDEA"/>
486 <path d="M41.6122 46.1949L38.3471 29.4465H11.9932C10.827 29.4465 9.89417 28.9747 9.1945 28.2671L7.32873 26.144C6.62907 25.4364 7.09551 24.021 8.26162 24.021H40.4461C41.6122 24.021 42.7783 24.9646 43.0116 26.144L46.7431 45.0155L41.6122 46.1949Z"
487 fill="#D5DDEA"/>
488 <path d="M118.342 134.655C123.365 134.655 127.437 130.536 127.437 125.455C127.437 120.374 123.365 116.255 118.342 116.255C113.318 116.255 109.246 120.374 109.246 125.455C109.246 130.536 113.318 134.655 118.342 134.655Z"
489 fill="url(#paint0_linear_2971_9229)"/>
490 <path d="M54.2057 134.655C59.2291 134.655 63.3014 130.536 63.3014 125.455C63.3014 120.374 59.2291 116.255 54.2057 116.255C49.1824 116.255 45.1101 120.374 45.1101 125.455C45.1101 130.536 49.1824 134.655 54.2057 134.655Z"
491 fill="url(#paint1_linear_2971_9229)"/>
492 <path d="M53.4147 103.68L48.3865 104.713L52.6584 125.981L57.6867 124.948L53.4147 103.68Z"
493 fill="#D5DDEA"/>
494 <path d="M118.109 128.05H39.28C38.1139 128.05 36.9478 127.106 36.7146 125.927L31.1173 98.5629C30.884 97.1476 31.8169 95.7322 33.2162 95.4963C34.6156 95.2604 36.0149 96.204 36.2481 97.6194L41.379 122.86H118.342C119.741 122.86 120.907 124.039 120.907 125.455C120.907 126.87 119.741 128.05 118.109 128.05Z"
495 fill="#D5DDEA"/>
496 <path d="M38.8136 134.655C43.837 134.655 47.9093 130.536 47.9093 125.455C47.9093 120.374 43.837 116.255 38.8136 116.255C33.7903 116.255 29.718 120.374 29.718 125.455C29.718 130.536 33.7903 134.655 38.8136 134.655Z"
497 fill="url(#paint2_linear_2971_9229)"/>
498 <path d="M38.8135 129.937C41.2608 129.937 43.2447 127.93 43.2447 125.455C43.2447 122.98 41.2608 120.973 38.8135 120.973C36.3662 120.973 34.3823 122.98 34.3823 125.455C34.3823 127.93 36.3662 129.937 38.8135 129.937Z"
499 fill="#8691AA"/>
500 <path d="M102.949 134.655C107.973 134.655 112.045 130.536 112.045 125.455C112.045 120.374 107.973 116.255 102.949 116.255C97.9258 116.255 93.8535 120.374 93.8535 125.455C93.8535 130.536 97.9258 134.655 102.949 134.655Z"
501 fill="url(#paint3_linear_2971_9229)"/>
502 <path d="M102.949 129.937C105.397 129.937 107.38 127.93 107.38 125.455C107.38 122.98 105.397 120.973 102.949 120.973C100.502 120.973 98.5181 122.98 98.5181 125.455C98.5181 127.93 100.502 129.937 102.949 129.937Z"
503 fill="#8691AA"/>
504 <g filter="url(#filter0_d_2971_9229)">
505 <path d="M136.999 44.3079L127.437 99.7427C126.738 103.281 123.939 105.64 120.441 105.64H38.3469C34.8486 105.64 32.0499 103.281 31.3502 99.7427L20.6221 44.3079H136.999Z"
506 fill="url(#paint4_linear_2971_9229)"/>
507 </g>
508 <path d="M69.3652 98.0914C70.5313 98.0914 71.6974 97.1478 71.6974 95.7325V54.4512C71.6974 53.2717 70.7645 52.0923 69.3652 52.0923C68.1991 52.0923 67.033 53.0359 67.033 54.4512V95.7325C67.033 97.1478 67.9658 98.0914 69.3652 98.0914Z"
509 fill="#E7EAF4"/>
510 <path d="M81.2596 98.0914C82.4257 98.3272 83.5918 97.3837 83.8251 95.9683L87.7898 54.9229C88.023 53.7435 87.0902 52.564 85.6908 52.3281C84.5247 52.0922 83.3586 53.0358 83.1254 54.4512L79.1606 95.4965C79.1606 96.9119 79.8603 97.8555 81.2596 98.0914Z"
511 fill="#E7EAF4"/>
512 <path d="M93.3871 97.8554C94.5532 98.0913 95.7193 97.1477 95.9525 95.9682L103.416 55.3946C103.649 54.2152 102.716 53.0357 101.55 52.7998C100.384 52.5639 99.2176 53.5075 98.9844 54.687L91.7545 95.2606C91.2881 96.44 92.2209 97.6195 93.3871 97.8554Z"
513 fill="#E7EAF4"/>
514 <path d="M57.2378 98.0914C56.0717 98.3272 54.9056 97.3837 54.6723 95.9683L50.7076 54.9229C50.4744 53.7435 51.4073 52.564 52.8066 52.3281C53.9727 52.0922 55.1388 53.0358 55.372 54.4512L59.3368 95.4965C59.3368 96.9119 58.6371 97.8555 57.2378 98.0914Z"
515 fill="#E7EAF4"/>
516 <path d="M45.1104 97.8554C43.9443 98.0913 42.7782 97.1477 42.5449 95.9682L35.0819 55.3946C34.8487 54.2152 35.7815 53.0357 36.9476 52.7998C38.1137 52.5639 39.2799 53.5075 39.5131 54.687L46.7429 95.2606C47.2094 96.44 46.2765 97.6195 45.1104 97.8554Z"
517 fill="#E7EAF4"/>
518 <path d="M137 44.3069L127.438 99.7417C126.738 103.28 123.94 105.639 120.441 105.639H98.7517C102.716 105.639 105.982 102.808 106.681 99.0341L116.71 44.3069H137Z"
519 fill="#DBDFEC"/>
520 <defs>
521 <filter id="filter0_d_2971_9229" x="0.62207" y="35.3079" width="156.377" height="101.332"
522 filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
523 <feFlood flood-opacity="0" result="BackgroundImageFix"/>
524 <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"
525 result="hardAlpha"/>
526 <feOffset dy="11"/>
527 <feGaussianBlur stdDeviation="10"/>
528 <feColorMatrix type="matrix"
529 values="0 0 0 0 0.397708 0 0 0 0 0.47749 0 0 0 0 0.575 0 0 0 0.27 0"/>
530 <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_2971_9229"/>
531 <feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_2971_9229" result="shape"/>
532 </filter>
533 <linearGradient id="paint0_linear_2971_9229" x1="109.238" y1="125.457" x2="127.441" y2="125.457"
534 gradientUnits="userSpaceOnUse">
535 <stop stop-color="#B0BACC"/>
536 <stop offset="1" stop-color="#969EAE"/>
537 </linearGradient>
538 <linearGradient id="paint1_linear_2971_9229" x1="45.1018" y1="125.457" x2="63.3047" y2="125.457"
539 gradientUnits="userSpaceOnUse">
540 <stop stop-color="#B0BACC"/>
541 <stop offset="1" stop-color="#969EAE"/>
542 </linearGradient>
543 <linearGradient id="paint2_linear_2971_9229" x1="29.7097" y1="125.457" x2="47.9126" y2="125.457"
544 gradientUnits="userSpaceOnUse">
545 <stop stop-color="#B0BACC"/>
546 <stop offset="1" stop-color="#969EAE"/>
547 </linearGradient>
548 <linearGradient id="paint3_linear_2971_9229" x1="93.8452" y1="125.457" x2="112.048" y2="125.457"
549 gradientUnits="userSpaceOnUse">
550 <stop stop-color="#B0BACC"/>
551 <stop offset="1" stop-color="#969EAE"/>
552 </linearGradient>
553 <linearGradient id="paint4_linear_2971_9229" x1="78.7728" y1="42.8892" x2="78.7728" y2="106.301"
554 gradientUnits="userSpaceOnUse">
555 <stop stop-color="#FDFEFF"/>
556 <stop offset="0.9964" stop-color="#ECF0F5"/>
557 </linearGradient>
558 </defs>
559 </svg>
560 <?php }
561
562
563 public function renderEmpty($emptyMessage = null, $continueShoppingUrl = null, $continueShoppingLabel = null, $continueShoppingAriaLabel = null)
564 {
565 $emptyMessage ??= __('Your cart is empty.', 'fluent-cart');
566 ?>
567
568 <div
569 class="fluent-cart-cart-empty-content"
570 role="region"
571 aria-label="<?php echo esc_attr($emptyMessage); ?>"
572 >
573
574
575 <?php
576 $this->renderEmptyCartIcon();
577 $this->renderEmptyCart(
578 $emptyMessage,
579 $continueShoppingUrl,
580 $continueShoppingLabel,
581 $continueShoppingAriaLabel
582 ); ?>
583 </div>
584
585 <?php
586
587 }
588
589 public function renderEmptyCart(
590 $emptyMessage = null,
591 $continueShoppingUrl = null,
592 $continueShoppingLabel = null,
593 $continueShoppingAriaLabel = null
594 )
595 {
596 $emptyMessage ??= __('Your cart is empty.', 'fluent-cart');
597 $continueShoppingUrl ??= $this->storeSettings->getShopPage();
598 $continueShoppingLabel ??= __('Continue Shopping', 'fluent-cart');
599 $continueShoppingAriaLabel ??= __('Browse products and continue shopping', 'fluent-cart');
600 ?>
601 <div class="fluent-cart-cart-empty-content-text">
602 <?php echo esc_html($emptyMessage); ?>
603
604 <?php if ($continueShoppingUrl) : ?>
605
606 <a class="continue-shopping-link"
607 href="<?php echo esc_url($continueShoppingUrl); ?>"
608 aria-label="<?php echo esc_attr($continueShoppingAriaLabel); ?>">
609 <?php echo esc_html($continueShoppingLabel); ?>
610 </a>
611
612 <?php endif; ?>
613 </div>
614 <?php }
615
616
617 }
618