PluginProbe
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder / 51.1.63
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder v51.1.63
51.1.86 51.1.84 51.1.85 51.1.83 51.1.82 51.1.81 51.1.79 51.1.78 51.1.77 51.1.76 51.1.74 51.1.75 51.1.65 51.1.64 51.1.63 trunk 51.1.14 51.1.2 51.1.35 51.1.36 51.1.37 51.1.38 51.1.39 51.1.44 51.1.45 All 40 releases
king-addons / includes / widgets / Woo_Cart_Empty / Woo_Cart_Empty.php

Woo_Cart_Empty.php in King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder 51.1.63, at includes/widgets/Woo_Cart_Empty/Woo_Cart_Empty.php

146 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Woo Cart Empty Message widget.
4 *
5 * @package King_Addons
6 */
7
8 namespace King_Addons;
9
10 use Elementor\Controls_Manager;
11 use Elementor\Widget_Base;
12 use King_Addons\Woo_Builder\Context as Woo_Context;
13
14 if (!defined('ABSPATH')) {
15 exit;
16 }
17
18 /**
19 * Displays empty cart notice with optional button.
20 */
21 class Woo_Cart_Empty extends Widget_Base
22 {
23 /**
24 * Widget slug.
25 *
26 * @return string
27 */
28 public function get_name(): string
29 {
30 return 'woo_cart_empty';
31 }
32
33 /**
34 * Widget title.
35 *
36 * @return string
37 */
38 public function get_title(): string
39 {
40 return esc_html__('Cart Empty Message', 'king-addons');
41 }
42
43 /**
44 * Widget icon.
45 *
46 * @return string
47 */
48 public function get_icon(): string
49 {
50 return 'eicon-alert';
51 }
52
53 /**
54 * Widget categories.
55 *
56 * @return array<int,string>
57 */
58 public function get_categories(): array
59 {
60 return ['king-addons-woo-builder'];
61 }
62
63 /**
64 * Register controls.
65 *
66 * @return void
67 */
68 public function get_custom_help_url()
69 {
70 return 'mailto:[email protected]?subject=Bug Report - King Addons&body=Please describe the issue';
71 }
72
73 protected function register_controls(): void
74 {
75 $this->start_controls_section(
76 'section_content',
77 [
78 'label' => esc_html__('Content', 'king-addons'),
79 'tab' => Controls_Manager::TAB_CONTENT,
80 ]
81 );
82
83 $this->add_control(
84 'message',
85 [
86 'label' => esc_html__('Message', 'king-addons'),
87 'type' => Controls_Manager::TEXTAREA,
88 'default' => esc_html__('Your cart is currently empty.', 'king-addons'),
89 ]
90 );
91
92 $this->add_control(
93 'show_return_shop',
94 [
95 'label' => esc_html__('Show “Return to shop” button', 'king-addons'),
96 'type' => Controls_Manager::SWITCHER,
97 'return_value' => 'yes',
98 'default' => 'yes',
99 ]
100 );
101
102 $this->end_controls_section();
103 }
104
105 /**
106 * Render widget output.
107 *
108 * @return void
109 */
110 protected function render(): void
111 {
112 if (!Woo_Context::maybe_render_context_notice('cart')) {
113 return;
114 }
115
116 $in_builder = class_exists('King_Addons\\Woo_Builder\\Context') && Woo_Context::is_editing_template_type('cart');
117 if (!function_exists('is_cart') || (!is_cart() && !$in_builder)) {
118 return;
119 }
120
121 $cart_empty = function_exists('WC') && WC()->cart && WC()->cart->is_empty();
122 if (!$cart_empty && !$in_builder) {
123 return;
124 }
125
126 $settings = $this->get_settings_for_display();
127 echo '<div class="ka-woo-cart-empty">';
128 echo '<p>' . esc_html($settings['message']) . '</p>';
129
130 if (!empty($settings['show_return_shop'])) {
131 $shop_url = wc_get_page_permalink('shop');
132 if ($shop_url) {
133 echo '<a class="button" href="' . esc_url($shop_url) . '">' . esc_html__('Return to shop', 'king-addons') . '</a>';
134 }
135 }
136
137 echo '</div>';
138 }
139 }
140
141
142
143
144
145
146