PluginProbe
QuadMenu – Mega Menu / 1.8.4
QuadMenu – Mega Menu v1.8.4
3.3.7 3.3.6 trunk 1.8.4 1.8.5 1.8.7 1.8.8 1.8.9 1.9.0 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 All 87 releases
quadmenu / includes / frontend / walker / QuadMenuItemCart.class.php

QuadMenuItemCart.class.php in QuadMenu – Mega Menu 1.8.4, at includes/frontend/walker/QuadMenuItemCart.class.php

129 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!defined('ABSPATH')) {
3 die('-1');
4 }
5
6 class QuadMenuItemCart extends QuadMenuItem {
7
8 protected $type = 'cart';
9 public $count = 0;
10
11 function init() {
12
13 $this->item->url = '';
14 $this->args->has_title = false;
15
16 if (empty($this->item->title)) {
17 $this->item->title = esc_html__('Your cart', 'quadmenu');
18 }
19
20 if (function_exists('is_woocommerce') && !is_cart() && !is_checkout()) {
21 $this->args->has_dropdown = $this->has_children = $this->args->has_caret = true;
22 }
23 }
24
25 function get_end_el() {
26 if (!class_exists('WooCommerce'))
27 return '';
28 }
29
30 function get_start_el() {
31
32 if (!class_exists('WooCommerce'))
33 return '';
34
35 $item_output = '';
36
37 $this->add_item_classes();
38
39 $this->add_item_classes_prefix();
40
41 $this->add_item_classes_quadmenu();
42
43 $this->add_item_classes_cart();
44
45 $id = $this->get_item_id();
46
47 $class = $this->get_item_classes();
48
49 $item_output .= '<li' . $id . $class . '>';
50
51 $this->add_link_atts();
52
53 $this->add_link_atts_toggle();
54
55 $this->add_link_atts_cart();
56
57 $item_output .= $this->get_link();
58
59 $item_output .= $this->get_dropdown_wrap_start();
60
61 $item_output .= $this->widget();
62
63 $item_output .= $this->get_dropdown_wrap_end();
64
65 return $item_output;
66 }
67
68 function add_item_classes_cart() {
69
70 $this->count = WC()->cart->get_cart_contents_count();
71
72 if (empty($this->count)) {
73 $this->item_classes[] = 'quadmenu-cart-empty';
74 } else {
75 $this->item->url = wc_get_cart_url();
76 }
77 }
78
79 function add_link_atts_cart() {
80
81 $this->item_atts['data-cart-url'] = wc_get_cart_url();
82
83 $this->item_atts['data-cart-price'] = wc_price(0);
84
85 $this->item_atts['data-cart-qty'] = esc_attr($this->count);
86
87 if (!empty($this->args->navbar_animation_cart)) {
88 $this->item_atts['data-cart-animation'] = join(' ', array_map('sanitize_html_class', (array) $this->args->navbar_animation_cart));
89 }
90 }
91
92 function get_icon() {
93 ob_start();
94 ?>
95 <span class="quadmenu-cart-magic">
96 <span class="quadmenu-icon <?php echo esc_attr($this->item->icon); ?><?php //echo esc_attr($this->item->animation->icon); ?>"></span>
97 <span class="quadmenu-cart-qty"><?php echo esc_html($this->count); ?></span>
98 </span>
99 <span class="quadmenu-cart-total"><?php echo WC()->cart->get_cart_total(); ?></span>
100 <?php
101 return ob_get_clean();
102 }
103
104 function widget() {
105 ob_start();
106 ?>
107 <?php $this->get_cart_icon(); ?>
108 <?php the_widget('WC_Widget_Cart', 'title='); ?>
109 <?php $this->get_cart_text(); ?>
110 <?php
111 return ob_get_clean();
112 }
113
114 function get_cart_text() {
115 if (!empty($this->item->cart_text)) {
116 ?>
117 <div class="quadmenu-bottom-text"><?php echo $this->item->cart_text; ?></div>
118 <?php
119 }
120 }
121
122 function get_cart_icon() {
123 ?>
124 <span class="quadmenu-empty-icon quadmenu-icon <?php echo esc_attr($this->item->icon); ?>"></span>
125 <?php
126 }
127
128 }
129