1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
|
<?php /** * Mini-cart * * @author NasaTheme * @package Elessi-theme/WooCommerce * @version 9.4.0 */
if (!defined('ABSPATH')) : exit; // Exit if accessed directly endif;
global $nasa_opt;
do_action('woocommerce_before_mini_cart');
if (WC()->cart && !WC()->cart->is_empty()) : $enable_button_ajax = 'yes' === get_option('woocommerce_enable_ajax_add_to_cart') ? true : false;
$is_change_variation_mini_cart = (isset($nasa_opt['mini_cart_change_variation_product']) && $nasa_opt['mini_cart_change_variation_product'] && $enable_button_ajax) ? true : false;
$extra_mini_cart_class = 'nasa-minicart-items';
if ($is_change_variation_mini_cart) : $extra_mini_cart_class .= ' nasa-change_variation_mini_cart'; endif;
$in_mobile = isset($nasa_opt['nasa_in_mobile']) && $nasa_opt['nasa_in_mobile'] ? true : false; $mini_cart_mobile_view_hide = ''; ?>
<div class="<?php echo esc_attr($extra_mini_cart_class); ?>" data-text="<?php echo esc_attr__('Update Cart', 'elessi-theme'); ?>"> <div class="woocommerce-mini-cart cart_list product_list_widget <?php echo esc_attr($args['list_class']); ?>"> <?php do_action('woocommerce_before_mini_cart_contents');
$cart_items = WC()->cart->get_cart(); if ($in_mobile && isset($nasa_opt['mobile_layout']) && $nasa_opt['mobile_layout'] == 'app') : $mini_cart_mobile_view_hide = isset($nasa_opt['mini_cart_mobile_view_hide']) && $nasa_opt['mini_cart_mobile_view_hide'] ? ' mini_cart_mobile_view_hidden' : ''; endif;
foreach ($cart_items as $cart_item_key => $cart_item) : $_product = apply_filters('woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key); $product_id = apply_filters('woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key); if ($_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters('woocommerce_widget_cart_item_visible', true, $cart_item, $cart_item_key)) : $variations = isset($cart_item['variation']) && $cart_item['variation'] ? $cart_item['variation'] : null; $_data_attr = ''; if (!empty($variations)) : $result = array();
foreach ($variations as $key => $variation) : $result[] = "$variation"; endforeach;
$_data_attr = implode(".", $result); endif; /** * Filter the product name. * * @param string $product_name Name of the product in the cart. */ $product_name = apply_filters('woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key); $product_var_id = apply_filters('ns_cart_item_variation_id', $_product->get_id(), $cart_item, $cart_item_key); $thumbnail = apply_filters('woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key); $product_price = apply_filters('woocommerce_cart_item_price', WC()->cart->get_product_price($_product), $cart_item, $cart_item_key); $product_permalink = apply_filters('woocommerce_cart_item_permalink', $_product->is_visible() ? $_product->get_permalink($cart_item) : '', $cart_item, $cart_item_key); ?> <div class="nasa-flex align-start mini-cart-item woocommerce-mini-cart-item <?php echo esc_attr(apply_filters('woocommerce_mini_cart_item_class', 'mini_cart_item', $cart_item, $cart_item_key)); ?>" data-variation-product="<?php echo esc_attr($product_var_id . '.' . $_data_attr); ?>" data-id-var-product="<?php echo esc_attr($product_var_id); ?>" data-id-product="<?php echo esc_attr($product_id); ?>"> <div class="nasa-image-cart-item"> <?php echo $thumbnail; ?> </div>
<div class="nasa-info-cart-item padding-left-15 rtl-padding-left-0 rtl-padding-right-15" data-variations-selected="<?php echo $is_change_variation_mini_cart && $variations != null ? htmlspecialchars(wp_json_encode($variations)): '' ?>"> <div class="mini-cart-info"> <div class="nasa-flex jbw align-start"> <?php if (empty($product_permalink)) : ?> <span class="product-name nasa-bold"><?php echo wp_kses_post($product_name); ?></span> <?php else : ?> <a class="product-name nasa-bold" href="<?php echo esc_url($product_permalink); ?>" title="<?php echo esc_attr($product_name); ?>"> <?php echo wp_kses_post($product_name); ?> </a> <?php endif; ?>
<span class="product-remove"> <?php echo apply_filters( 'woocommerce_cart_item_remove_link', sprintf( '<a href="%s" class="remove remove_from_cart_button item-in-cart nasa-stclose small ajax-sp_%s" aria-label="%s" data-product_id="%s" data-cart_item_key="%s" data-product_sku="%s"></a>', esc_url(wc_get_cart_remove_url($cart_item_key)), $enable_button_ajax ? 'yes' : 'no', /* translators: %s is the product name */ esc_attr(sprintf(__('Remove %s from cart', 'elessi-theme'), $product_name)), esc_attr($product_id), esc_attr($cart_item_key), esc_attr($_product->get_sku()) ), $cart_item_key ); ?> </span> </div>
<?php echo wc_get_formatted_cart_item_data($cart_item); ?> <?php if ($product_price) : echo '<div class="nasa-flex jbw align-start mini-cart-item-price margin-top-5">'; $wrap = false; $quantily_show = true; /** * Qty input * Elessi Theme Support */ if ((!isset($nasa_opt['mini_cart_qty']) || $nasa_opt['mini_cart_qty'])) : $quantily_show = false; $wrap = true; if ($_product->is_sold_individually()) : $min_quantity = 1; $max_quantity = 1; else : $min_quantity = 0; $max_quantity = $_product->get_max_purchase_quantity(); endif; $qty_args = array( 'input_name' => 'cart[' . $cart_item_key . '][qty]', 'input_value' => $cart_item['quantity'], 'max_value' => $max_quantity, 'min_value' => $min_quantity, 'product_name' => $_product->get_name(), 'mini_cart' => true ); $product_quantity = woocommerce_quantity_input($qty_args, $_product, false); echo '<div class="quantity-wrap nasa-flex flex-wrap">'; echo apply_filters('woocommerce_cart_item_quantity', $product_quantity, $cart_item_key, $cart_item); // PHPCS: XSS ok. endif;
echo apply_filters('woocommerce_widget_cart_item_quantity', '<div class="cart_list_product_quantity">' . ($quantily_show ? sprintf('%s × %s', $cart_item['quantity'], $product_price) : sprintf('× %s', $product_price)) . '</div>', $cart_item, $cart_item_key);
echo $wrap ? '</div>' : ''; /** * SubTotal * Elessi Theme Support */ if ((!isset($nasa_opt['mini_cart_subtotal']) || $nasa_opt['mini_cart_subtotal'])) : echo '<div class="mini-cart-item-subtotal nasa-bold margin-left-10 rtl-margin-left-0 rtl-margin-right-10">'; echo apply_filters('woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal($_product, $cart_item['quantity']), $cart_item, $cart_item_key); echo '</div>'; endif; echo '</div>'; endif; ?> </div> </div> </div> <?php endif; endforeach;
do_action('woocommerce_mini_cart_contents'); ?> </div> </div> <div class="nasa-minicart-footer<?php echo $mini_cart_mobile_view_hide; ?>"> <?php do_action('nasa_mini_cart_before_total'); ?> <div class="minicart_total_checkout woocommerce-mini-cart__total total"> <?php /** * Woocommerce_widget_shopping_cart_total hook. * * @removed woocommerce_widget_shopping_cart_subtotal - 10 * @hooked elessi_widget_shopping_cart_subtotal - 10 * @hooked elessi_subtotal_free_shipping - 20 */ do_action('woocommerce_widget_shopping_cart_total'); ?> </div> <div class="btn-mini-cart inline-lists text-center"> <?php do_action('woocommerce_widget_shopping_cart_before_buttons'); ?>
<p class="woocommerce-mini-cart__buttons buttons"> <?php do_action('woocommerce_widget_shopping_cart_buttons'); ?> </p>
<?php do_action('woocommerce_widget_shopping_cart_after_buttons'); ?> </div> </div> <?php /** * Empty cart */ else : $icon_empty = elessi_mini_cart_icon(); $target_shop = apply_filters('nasa_target_return_shop', 'javascript:void(0);'); // $str1 = array('nasa-icon cart-icon', 'width="28" height="28"'); // $str2 = array('nasa-icon cart-icon nasa-empty-icon', ' width="100%" height="122"'); // $icon_class = str_replace($str1, $str2, $icon_empty);
?> <p class="empty woocommerce-mini-cart__empty-message"> <?php echo $icon_empty ?> <?php echo esc_html__('No products in the cart.', 'elessi-theme')?> <a href="<?php echo esc_attr($target_shop); ?>" class="button nasa-sidebar-return-shop" rel="nofollow"> <?php echo esc_html__('RETURN TO SHOP', 'elessi-theme') ?> </a> </p> <?php endif;
do_action('woocommerce_after_mini_cart');
|