PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.4
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.4
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 1.2.0 All 47 releases
fluent-cart / app / Services / Renderer / CartRenderer.php

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

636 lines 26.3 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 // The Cart model already resolves & appends variation_display_title on
201 // every cart item (Cart::getCartDataAttribute), so just read it.
202 $variationTitle = (string) Arr::get($this->currentCartItem, 'variation_display_title', Arr::get($this->currentCartItem, 'title', ''));
203 $variationType = Arr::get($this->currentCartItem, 'variation_type', 'simple');
204
205 $aria_label = sprintf(
206 /* translators: 1: Post or product title */
207 esc_attr__('View %1$s', 'fluent-cart'),
208 esc_attr($postTitle)
209 );
210
211
212 ?>
213
214 <h3 class="fct-cart-item-title" data-fluent-cart-cart-list-item-title>
215 <a href="<?php echo esc_url($this->url); ?>"
216 aria-label="<?php echo esc_attr($aria_label); ?>"
217 data-fluent-cart-cart-list-item-title-url>
218 <span data-fluent-cart-cart-list-item-title-element>
219 <?php echo esc_html($postTitle); ?>
220 </span>
221 </a>
222 </h3>
223
224 <p class="fct-cart-item-variant <?php echo $variationType === 'simple' ? 'variant-title-hidden' : ''?>"
225 data-fluent-cart-cart-list-item-variation-title>
226 - <?php echo esc_html($variationTitle); ?>
227 </p>
228
229 <?php
230 }
231
232 public function renderItemPrice()
233 {
234 $price = Helper::toDecimal(Arr::get(
235 $this->currentCartItem,
236 'line_meta.original_unit_price',
237 Arr::get($this->currentCartItem, 'unit_price', 0)
238 ));
239 $quantity = Arr::get($this->currentCartItem, 'quantity', 1);
240
241 ?>
242 <div class="fct-cart-item-price <?php echo $quantity <= 1 ? 'item-price-hidden' : '' ?>">
243 <span><?php esc_html_e('Unit Price:', 'fluent-cart'); ?></span>
244 <span data-fluent-cart-cart-list-item-price aria-live="polite">
245 <?php echo esc_html($price); ?>
246 </span>
247 </div>
248
249 <?php
250 }
251
252 public function renderQuantity()
253 {
254 $quantity = Arr::get($this->currentCartItem, 'quantity', 0);
255
256 $productId = Arr::get($this->currentCartItem, 'post_id');
257 $this->product = Product::query()->with(['detail'])->find($productId);
258 $soldIndividually = false;
259 if ($this->product) {
260 $soldIndividually = $this->product->soldIndividually();
261 }
262
263 if ($soldIndividually) {
264 return;
265 }
266
267 ?>
268
269 <div class="fct-cart-item-quantity"
270 data-fluent-cart-cart-list-item-quantity-wrapper
271 role="group"
272 aria-label="<?php esc_attr_e('Change Quantity', 'fluent-cart'); ?>"
273 >
274
275 <button
276 class="qty-btn decrease-btn"
277 data-item-id="<?php echo esc_attr($this->currentCartItem['object_id']); ?>"
278 data-fluent-cart-cart-list-item-decrease-button
279 title="<?php esc_attr_e('Decrease Quantity', 'fluent-cart'); ?>"
280 aria-label="<?php esc_attr_e('Decrease Quantity', 'fluent-cart'); ?>"
281 >
282 <svg xmlns="http://www.w3.org/2000/svg" width="12" height="2" viewBox="0 0 12 2" fill="none">
283 <path d="M11.3333 1L0.666662 1" stroke="currentColor" stroke-linecap="round"
284 stroke-linejoin="round"/>
285 </svg>
286 </button>
287
288 <input
289 class="qty-value"
290 min="1"
291 data-item-id="<?php echo esc_attr($this->currentCartItem['object_id']); ?>"
292 data-fluent-cart-cart-list-item-quantity-input
293 value="<?php echo esc_attr($quantity); ?>"
294 aria-label="<?php esc_attr_e('Product Quantity', 'fluent-cart'); ?>"
295 aria-live="polite"
296 />
297
298 <button
299 class="qty-btn increase-btn"
300 data-fluent-cart-cart-list-item-increase-button
301 data-item-id="<?php echo esc_attr($this->currentCartItem['object_id']); ?>"
302 title="<?php esc_attr_e('Increase Quantity', 'fluent-cart'); ?>"
303 aria-label="<?php esc_attr_e('Increase Quantity', 'fluent-cart'); ?>"
304 >
305 <svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none">
306 <path d="M6 0.666748L6 11.3334M11.3333 6.00008L0.666672 6.00008" stroke="currentColor"
307 stroke-linecap="round" stroke-linejoin="round"></path>
308 </svg>
309 </button>
310 </div>
311
312 <?php
313 }
314
315
316 public function renderSummary()
317 {
318 ?>
319 <div class="fct-cart-item-summary" role="group"
320 aria-label="<?php esc_attr_e('Cart Item Summary', 'fluent-cart'); ?>">
321 <?php $this->renderItemTotal(); ?>
322 <?php $this->renderRemove(); ?>
323 </div>
324
325 <?php
326 }
327
328 public function renderItemTotal()
329 {
330 $quantity = Arr::get($this->currentCartItem, 'quantity', 0);
331 $displayUnitPrice = Arr::get(
332 $this->currentCartItem,
333 'line_meta.original_unit_price',
334 Arr::get($this->currentCartItem, 'unit_price', 0)
335 );
336 $totalPrice = $displayUnitPrice * $quantity;
337
338 if (Arr::get($this->currentCartItem, 'other_info.payment_type', 'onetime') == 'subscription') {
339 if (Arr::get($this->currentCartItem, 'other_info.manage_setup_fee') == 'yes') {
340 $signupFee = Arr::get($this->currentCartItem, 'other_info.signup_fee', 0);
341
342 if (Arr::get($this->currentCartItem, 'other_info.setup_fee_per_item', 'no') == 'yes') {
343 $signupFee = Arr::get($this->currentCartItem, 'other_info.signup_fee', 0) * $quantity;
344 }
345
346 $totalPrice += $signupFee;
347 }
348 }
349
350 $totalPrice = Helper::toDecimal($totalPrice);
351 $aria_label = sprintf(
352 /* translators: 1: Total price */
353 __('Total price for this item: %1$s', 'fluent-cart'),
354 $totalPrice
355 );
356
357 ?>
358 <div class="fct-cart-item-total">
359 <span
360 data-fluent-cart-cart-list-item-total-price
361 aria-live="polite"
362 aria-label="<?php echo esc_attr($aria_label); ?>"
363 >
364 <?php echo esc_html($totalPrice); ?>
365 </span>
366 </div>
367
368 <?php
369 }
370
371 public function renderTotal()
372 {
373 $cartItems = CartCheckoutHelper::make()->getItems();
374 $grossTotal = 0;
375 foreach ($cartItems as $item) {
376 $paymentType = Arr::get($item, 'other_info.payment_type', '');
377 $qty = max(1, (int) Arr::get($item, 'quantity', 1));
378 $displayUnitPrice = (int) Arr::get(
379 $item,
380 'line_meta.original_unit_price',
381 Arr::get($item, 'unit_price', 0)
382 );
383 if ($paymentType === 'subscription') {
384 if ((int) Arr::get($item, 'other_info.trial_days', 0) > 0) {
385 $grossTotal += (int) Arr::get($item, 'other_info.signup_fee', 0);
386 } else {
387 $grossTotal += $displayUnitPrice * $qty + (int) Arr::get($item, 'other_info.signup_fee', 0);
388 }
389 } else {
390 $grossTotal += $displayUnitPrice * $qty;
391 }
392 }
393 $subtotal = Helper::toDecimal($grossTotal);
394 $aria_label = sprintf(
395 /* translators: 1: Total price */
396 __('Total cart price: %1$s', 'fluent-cart'),
397 esc_attr($subtotal)
398 );
399 ?>
400
401 <div
402 data-fluent-cart-cart-total-wrapper
403 class="fct-cart-total-wrapper"
404 role="region"
405 aria-label="<?php esc_attr_e('Cart Total', 'fluent-cart'); ?>"
406 >
407 <span><?php
408 /**
409 * Filters the cart total label. Lets a caller relabel it without
410 * reimplementing this markup; the default renders exactly as before.
411 *
412 * @param string $label
413 */
414 echo esc_html(apply_filters('fluent_cart/cart/total_label', __('Total', 'fluent-cart')));
415 ?></span>
416 <span
417 data-fluent-cart-cart-total-price
418 aria-live="polite"
419 aria-label="<?php echo esc_attr($aria_label); ?>"
420 >
421 <?php echo esc_html($subtotal); ?>
422 </span>
423 </div>
424
425 <?php
426
427 }
428
429 public function renderRemove()
430 {
431
432 ?>
433 <div class="fct-cart-item-remove">
434 <button
435 type="button"
436 class="fct-cart-item-delete-button"
437 data-fluent-cart-cart-list-item-delete-button
438 data-item-id="<?php echo esc_attr($this->currentCartItem['object_id']); ?>"
439 aria-label="<?php esc_attr_e('Remove this item from cart', 'fluent-cart'); ?>"
440 title="<?php esc_attr_e('Remove From Cart', 'fluent-cart'); ?>"
441 >
442 <svg xmlns="http://www.w3.org/2000/svg" width="14" height="16" viewBox="0 0 14 16" fill="none">
443 <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"
444 stroke="currentColor" stroke-linecap="round"></path>
445 <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"
446 stroke="currentColor" stroke-linecap="round"></path>
447 <path d="M5.33334 11L5.33334 7" stroke="currentColor" stroke-linecap="round"></path>
448 <path d="M8.66666 11L8.66666 7" stroke="currentColor" stroke-linecap="round"></path>
449 </svg>
450 </button>
451 </div>
452
453 <?php
454 }
455
456 public function renderCheckoutButton()
457 {
458 ?>
459
460 <a class="checkout-button fct-primary-btn"
461 href="<?php echo esc_attr($this->storeSettings->getCheckoutPage()); ?>"
462 role="button"
463 aria-label="<?php esc_attr_e('Go to checkout page', 'fluent-cart'); ?>">
464 <?php
465 /**
466 * Filters the cart checkout button text. Lets a caller relabel it
467 * without reimplementing this markup; the default is unchanged.
468 *
469 * @param string $text
470 */
471 echo esc_html(apply_filters('fluent_cart/cart/checkout_button_text', __('Go to Checkout', 'fluent-cart')));
472 ?>
473 </a>
474
475 <?php
476
477 }
478
479 public function renderViewCartButton()
480 {
481 return;
482 ?>
483
484 <a class="view-cart-button"
485 href="<?php echo esc_attr($this->storeSettings->getCartPage()); ?>"
486 role="button"
487 aria-label="<?php esc_attr_e('View your shopping cart', 'fluent-cart'); ?>">
488 <?php esc_html_e('View Cart', 'fluent-cart'); ?>
489 </a>
490
491 <?php
492
493 }
494
495 public function renderEmptyCartIcon()
496 { ?>
497 <svg xmlns="http://www.w3.org/2000/svg" width="157" height="137" viewBox="0 0 157 137" fill="none">
498 <path d="M21.5017 135H134.91" stroke="#D6DCE8" stroke-width="2" stroke-miterlimit="10"
499 stroke-linejoin="round"/>
500 <path d="M8.60278 135H18.2925" stroke="#D6DCE8" stroke-width="2" stroke-miterlimit="10"
501 stroke-linejoin="round"/>
502 <path d="M23.1192 26.0612L18.0879 27.0789L21.8382 46.0468L26.8695 45.0291L23.1192 26.0612Z"
503 fill="#D5DDEA"/>
504 <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"
505 fill="#D5DDEA"/>
506 <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"
507 fill="url(#paint0_linear_2971_9229)"/>
508 <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"
509 fill="url(#paint1_linear_2971_9229)"/>
510 <path d="M53.4147 103.68L48.3865 104.713L52.6584 125.981L57.6867 124.948L53.4147 103.68Z"
511 fill="#D5DDEA"/>
512 <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"
513 fill="#D5DDEA"/>
514 <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"
515 fill="url(#paint2_linear_2971_9229)"/>
516 <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"
517 fill="#8691AA"/>
518 <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"
519 fill="url(#paint3_linear_2971_9229)"/>
520 <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"
521 fill="#8691AA"/>
522 <g filter="url(#filter0_d_2971_9229)">
523 <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"
524 fill="url(#paint4_linear_2971_9229)"/>
525 </g>
526 <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"
527 fill="#E7EAF4"/>
528 <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"
529 fill="#E7EAF4"/>
530 <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"
531 fill="#E7EAF4"/>
532 <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"
533 fill="#E7EAF4"/>
534 <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"
535 fill="#E7EAF4"/>
536 <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"
537 fill="#DBDFEC"/>
538 <defs>
539 <filter id="filter0_d_2971_9229" x="0.62207" y="35.3079" width="156.377" height="101.332"
540 filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
541 <feFlood flood-opacity="0" result="BackgroundImageFix"/>
542 <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"
543 result="hardAlpha"/>
544 <feOffset dy="11"/>
545 <feGaussianBlur stdDeviation="10"/>
546 <feColorMatrix type="matrix"
547 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"/>
548 <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_2971_9229"/>
549 <feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_2971_9229" result="shape"/>
550 </filter>
551 <linearGradient id="paint0_linear_2971_9229" x1="109.238" y1="125.457" x2="127.441" y2="125.457"
552 gradientUnits="userSpaceOnUse">
553 <stop stop-color="#B0BACC"/>
554 <stop offset="1" stop-color="#969EAE"/>
555 </linearGradient>
556 <linearGradient id="paint1_linear_2971_9229" x1="45.1018" y1="125.457" x2="63.3047" y2="125.457"
557 gradientUnits="userSpaceOnUse">
558 <stop stop-color="#B0BACC"/>
559 <stop offset="1" stop-color="#969EAE"/>
560 </linearGradient>
561 <linearGradient id="paint2_linear_2971_9229" x1="29.7097" y1="125.457" x2="47.9126" y2="125.457"
562 gradientUnits="userSpaceOnUse">
563 <stop stop-color="#B0BACC"/>
564 <stop offset="1" stop-color="#969EAE"/>
565 </linearGradient>
566 <linearGradient id="paint3_linear_2971_9229" x1="93.8452" y1="125.457" x2="112.048" y2="125.457"
567 gradientUnits="userSpaceOnUse">
568 <stop stop-color="#B0BACC"/>
569 <stop offset="1" stop-color="#969EAE"/>
570 </linearGradient>
571 <linearGradient id="paint4_linear_2971_9229" x1="78.7728" y1="42.8892" x2="78.7728" y2="106.301"
572 gradientUnits="userSpaceOnUse">
573 <stop stop-color="#FDFEFF"/>
574 <stop offset="0.9964" stop-color="#ECF0F5"/>
575 </linearGradient>
576 </defs>
577 </svg>
578 <?php }
579
580
581 public function renderEmpty($emptyMessage = null, $continueShoppingUrl = null, $continueShoppingLabel = null, $continueShoppingAriaLabel = null)
582 {
583 $emptyMessage ??= __('Your cart is empty.', 'fluent-cart');
584 ?>
585
586 <div
587 class="fluent-cart-cart-empty-content"
588 role="region"
589 aria-label="<?php echo esc_attr($emptyMessage); ?>"
590 >
591
592
593 <?php
594 $this->renderEmptyCartIcon();
595 $this->renderEmptyCart(
596 $emptyMessage,
597 $continueShoppingUrl,
598 $continueShoppingLabel,
599 $continueShoppingAriaLabel
600 ); ?>
601 </div>
602
603 <?php
604
605 }
606
607 public function renderEmptyCart(
608 $emptyMessage = null,
609 $continueShoppingUrl = null,
610 $continueShoppingLabel = null,
611 $continueShoppingAriaLabel = null
612 )
613 {
614 $emptyMessage ??= __('Your cart is empty.', 'fluent-cart');
615 $continueShoppingUrl ??= $this->storeSettings->getShopPage();
616 $continueShoppingLabel ??= __('Continue Shopping', 'fluent-cart');
617 $continueShoppingAriaLabel ??= __('Browse products and continue shopping', 'fluent-cart');
618 ?>
619 <div class="fluent-cart-cart-empty-content-text">
620 <?php echo esc_html($emptyMessage); ?>
621
622 <?php if ($continueShoppingUrl) : ?>
623
624 <a class="continue-shopping-link"
625 href="<?php echo esc_url($continueShoppingUrl); ?>"
626 aria-label="<?php echo esc_attr($continueShoppingAriaLabel); ?>">
627 <?php echo esc_html($continueShoppingLabel); ?>
628 </a>
629
630 <?php endif; ?>
631 </div>
632 <?php }
633
634
635 }
636