PluginProbe
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant / 2.2.8
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant v2.2.8
2.3.2 2.3.1 2.3.0 2.2.8 2.2.7 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.11.0 1.11.1 1.11.2 1.6 1.7 1.8 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 1.9.10 1.9.11 All 60 releases
merchant / inc / modules / clear-cart / class-clear-cart.php

class-clear-cart.php in Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant 2.2.8, at inc/modules/clear-cart/class-clear-cart.php

702 lines 23.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Clear Cart.
5 *
6 * @package Merchant
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 /**
14 * Clear Cart Class.
15 *
16 */
17 class Merchant_Clear_Cart extends Merchant_Add_Module {
18
19 /**
20 * Module ID.
21 *
22 */
23 const MODULE_ID = 'clear-cart';
24
25 /**
26 * Is module preview.
27 *
28 */
29 public static $is_module_preview = false;
30
31 /**
32 * Whether the module has a shortcode or not.
33 *
34 * @var bool
35 */
36 public $has_shortcode = true;
37
38 /**
39 * Constructor.
40 *
41 */
42 public function __construct() {
43 if ( ! class_exists( 'Woocommerce' ) ) {
44 return;
45 }
46
47 // Module id.
48 $this->module_id = self::MODULE_ID;
49
50 // WooCommerce only.
51 $this->wc_only = true;
52
53 // Module section.
54 $this->module_section = 'improve-experience';
55
56 // Parent construct.
57 parent::__construct();
58
59 // Module default settings.
60 $this->module_default_settings = array(
61 'cart_threshold' => 1,
62 'enable_auto_clear' => false,
63 'auto_clear_expiration_hours' => 24,
64 'popup_message' => __( 'Are you sure you want to empty your shopping cart?', 'merchant' ),
65 'popup_message_inactive' => __( 'It looks like you haven’t been active for a while. Would you like to empty your shopping cart?', 'merchant' ),
66 'redirect_link' => '',
67 'redirect_link_custom' => '',
68 'enable_cart_page' => true,
69 'cart_page_position' => 'woocommerce_cart_coupon',
70 'enable_mini_cart' => false,
71 'mini_cart_position' => 'after_checkout',
72 'enable_side_cart' => false,
73 'side_cart_position' => 'after_view_cart',
74 'label' => __( 'Clear Cart', 'merchant' ),
75 'style' => 'solid',
76 );
77
78 $this->module_data = Merchant_Admin_Modules::$modules_data[ self::MODULE_ID ];
79
80 // Module options path.
81 $this->module_options_path = MERCHANT_DIR . 'inc/modules/' . self::MODULE_ID . '/admin/options.php';
82
83 // Is module preview page.
84 if ( is_admin() && parent::is_module_settings_page() ) {
85 self::$is_module_preview = true;
86
87 // Enqueue admin styles.
88 add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_css' ) );
89
90 // Enqueue admin scripts.
91 add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_js' ) );
92
93 // Admin preview box.
94 add_filter( 'merchant_module_preview', array( $this, 'render_admin_preview' ), 10, 2 );
95
96 // Custom CSS.
97 // The custom CSS should be added here as well due to ensure preview box works properly.
98 add_filter( 'merchant_custom_css', array( $this, 'admin_custom_css' ) );
99 }
100
101 if ( ! Merchant_Modules::is_module_active( self::MODULE_ID ) ) {
102 return;
103 }
104
105 if ( Merchant_Modules::is_module_active( self::MODULE_ID ) && is_admin() ) {
106 $this->init_translations();
107 }
108
109 // Return early if it's on admin but not in the respective module settings page.
110 if ( is_admin() && ! wp_doing_ajax() && ! parent::is_module_settings_page() ) {
111 return;
112 }
113
114 $settings = $this->get_module_settings();
115
116 // Cart Page
117 if ( ! empty( $settings['enable_cart_page'] ) ) {
118 $hook_name = ! empty( $settings['cart_page_position'] ) ? $settings['cart_page_position'] : 'woocommerce_cart_coupon';
119
120 add_action( $hook_name, array( $this, 'button_cart_page' ) );
121 }
122
123 // Mini Cart
124 if ( ! empty( $settings['enable_mini_cart'] ) ) {
125 $position = $settings['mini_cart_position'] ?? 'after_checkout';
126 $hook_priority = $position === 'before_view_cart' ? 9 : ( $position === 'after_view_cart' ? 15 : 30 );
127
128 add_action( 'woocommerce_widget_shopping_cart_buttons', array( $this, 'button_mini_cart' ), $hook_priority );
129 }
130
131 // Side Cart
132 if ( ! empty( $settings['enable_side_cart'] ) && merchant_is_pro_active() && Merchant_Modules::is_module_active( Merchant_Side_Cart::MODULE_ID ) ) {
133 $position = $settings['side_cart_position'] ?? 'after_view_cart';
134 $hook_priority = $position === 'before_view_cart' ? 15 : ( $position === 'before_checkout' ? 30 : 9 );
135
136 // Side Cart
137 add_action( 'merchant_widget_shopping_cart_buttons', array( $this, 'button_side_cart' ), $hook_priority );
138 }
139
140 // Enqueue CSS.
141 add_action( 'merchant_enqueue_before_main_css_js', array( $this, 'enqueue_css' ) );
142
143 // Enqueue scripts.
144 add_action( 'merchant_enqueue_after_main_css_js', array( $this, 'enqueue_scripts' ) );
145
146 // Localize script.
147 add_filter( 'merchant_localize_script', array( $this, 'localize_script' ) );
148
149 // Custom CSS.
150 add_filter( 'merchant_custom_css', array( $this, 'frontend_custom_css' ) );
151
152 add_action( 'wp_ajax_clear_cart', array( $this, 'clear_cart_ajax_handler' ) );
153 add_action( 'wp_ajax_nopriv_clear_cart', array( $this, 'clear_cart_ajax_handler' ) );
154
155 add_filter( 'woocommerce_add_to_cart_fragments', array( $this, 'cart_count_fragment' ) );
156 }
157
158 /**
159 * Init translations.
160 *
161 * @return void
162 */
163 public function init_translations() {
164 $settings = $this->get_module_settings();
165 if ( ! empty( $settings['label'] ) ) {
166 Merchant_Translator::register_string( $settings['label'], esc_html__( 'Clear Cart', 'merchant' ) );
167 }
168 }
169
170 /**
171 * Admin enqueue CSS.
172 *
173 * @return void
174 */
175 public function admin_enqueue_css() {
176 if ( $this->is_module_settings_page() ) {
177 wp_enqueue_style( 'merchant-admin-' . self::MODULE_ID, MERCHANT_URI . 'assets/css/modules/' . self::MODULE_ID . '/admin/preview.min.css', array(), MERCHANT_VERSION );
178 }
179 }
180
181 /**
182 * Admin enqueue scripts.
183 *
184 * @return void
185 */
186 public function admin_enqueue_js() {
187 if ( $this->is_module_settings_page() ) {
188 wp_enqueue_script( "merchant-{$this->module_id}", MERCHANT_URI . "assets/js/modules/{$this->module_id}/admin/preview.min.js", array( 'jquery' ), MERCHANT_VERSION, true );
189 }
190 }
191
192 /**
193 * Render admin preview
194 *
195 * @param Merchant_Admin_Preview $preview
196 * @param string $module
197 *
198 * @return Merchant_Admin_Preview
199 */
200 public function render_admin_preview( $preview, $module ) {
201 if ( self::MODULE_ID === $module ) {
202 $preview->set_html( array( $this, 'admin_preview_content' ), $this->get_module_settings() );
203
204 // Button Label.
205 $preview->set_text( 'label', '.merchant-clear-cart-button' );
206 }
207
208 return $preview;
209 }
210
211 /**
212 * Admin preview content.
213 *
214 * @return void
215 */
216 public static function admin_preview_content( $settings ) {
217 $products = array(
218 array(
219 'title' => __( 'Product title', 'merchant' ),
220 'price' => '$30',
221 'subtotal' => '$30',
222 ),
223 array(
224 'title' => __( 'Product title', 'merchant' ),
225 'price' => '$55',
226 'subtotal' => '$55',
227 ),
228 );
229
230 ?>
231 <table class="shop_table" cellspacing="0">
232 <thead>
233 <tr>
234 <th class="product-remove"><span class="screen-reader-text"><?php esc_html_e( 'Remove item', 'merchant' ); ?></span></th>
235 <th class="product-thumbnail"><span class="screen-reader-text"><?php esc_html_e( 'Thumbnail image', 'merchant' ); ?></span></th>
236 <th class="product-name"><?php esc_html_e( 'Product', 'merchant' ); ?></th>
237 <th class="product-price"><?php esc_html_e( 'Price', 'merchant' ); ?></th>
238 <th class="product-quantity"><?php esc_html_e( 'Quantity', 'merchant' ); ?></th>
239 <th class="product-subtotal"><?php esc_html_e( 'Total', 'merchant' ); ?></th>
240 </tr>
241 </thead>
242 <tbody>
243 <?php foreach ( $products as $p ) : ?>
244 <tr class="woocommerce-cart-form__cart-item cart_item">
245 <td class="product-remove">
246 <svg width="10" height="10" viewBox="0 0 5 5" fill="none" xmlns="http://www.w3.org/2000/svg">
247 <path d="M0.715086 0.0388184L0.400391 0.353514L2.32277 2.27589L0.400391 4.19827L0.715086 4.51297L2.63747 2.59059L4.55985 4.51297L4.87454 4.19827L2.95216 2.27589L4.87454 0.353514L4.55985 0.0388184L2.63747 1.9612L0.715086 0.0388184Z" fill="#424242"/>
248 </svg>
249 </td>
250 <td class="product-thumbnail"><span></span></td>
251 <td class="product-name"><?php echo esc_html( $p['title'] ); ?></td>
252 <td class="product-price"><?php echo esc_html( $p['price'] ); ?></td>
253 <td class="product-quantity">
254 <div class="merchant-preview-qty">
255 <button>+</button>
256 <input type="text" value="1">
257 <button>-</button>
258 </div>
259 </td>
260 <td class="product-subtotal"><?php echo esc_html( $p['subtotal'] ); ?></td>
261 </tr>
262 <?php endforeach; ?>
263 </tbody>
264 </table>
265 <div class="shop_table-bottom">
266 <div class="shop_table-bottom__start">
267 <div class="shop_table__coupon">
268 <input type="text" placeholder="<?php echo esc_attr__( 'Coupon Code', 'merchant' ); ?>">
269 <button class="shop_table__button shop_table__button__apply-coupon"><?php echo esc_html__( 'Apply Coupon', 'merchant' ); ?></button>
270 </div>
271 <div class="shop_table__clear-cart">
272 <button class="hide shop_table__button merchant-clear-cart-button woocommerce_cart_coupon"><?php echo esc_html( $settings['label'] ); ?></button>
273 </div>
274 </div>
275 <div class="shop_table-bottom__end">
276 <button class="shop_table__button shop_table__button__update-cart"><?php echo esc_html__( 'Update Cart', 'merchant' ); ?></button>
277 <button class="hide shop_table__button merchant-clear-cart-button woocommerce_cart_actions"><?php echo esc_html( $settings['label'] ); ?></button>
278 </div>
279 </div>
280 <button class="hide shop_table__button merchant-clear-cart-button woocommerce_after_cart_table"><?php echo esc_html( $settings['label'] ); ?></button>
281 <?php
282 }
283
284 /**
285 * Print shortcode content.
286 *
287 * @return string
288 */
289 public function shortcode_handler() {
290 // Check if module is active.
291 if ( ! Merchant_Modules::is_module_active( self::MODULE_ID ) ) {
292 return '';
293 }
294
295 // Check if shortcode is enabled.
296 if ( ! $this->is_shortcode_enabled() ) {
297 return '';
298 }
299
300 ob_start();
301 $this->print_button();
302 $shortcode_content = ob_get_clean();
303
304 /**
305 * Filter the shortcode html content.
306 *
307 * @param string $shortcode_content shortcode html content
308 * @param string $module_id module id
309 * @param int $post_id product id
310 *
311 * @since 1.8
312 */
313 return apply_filters( 'merchant_module_shortcode_content_html', $shortcode_content, self::MODULE_ID, get_the_ID() );
314 }
315
316 /**
317 * Display Button on Cart Page
318 *
319 * @return void
320 */
321 public function button_cart_page() {
322 if ( $this->is_shortcode_enabled() ) {
323 return;
324 }
325
326 $this->print_button( 'cart-page' );
327 }
328
329 /**
330 * Display Button on Side Cart
331 *
332 * @return void
333 */
334 public function button_side_cart() {
335 if ( $this->is_shortcode_enabled() ) {
336 return;
337 }
338
339 $this->print_button( 'side-cart' );
340 }
341
342 /**
343 * Display Button on Mini Cart
344 *
345 * @return void
346 */
347 public function button_mini_cart() {
348 if ( $this->is_shortcode_enabled() ) {
349 return;
350 }
351
352 $this->print_button( 'mini-cart' );
353 }
354
355 /**
356 * Display Button
357 *
358 * @param $context
359 *
360 * @return void
361 */
362 public function print_button( $context = '' ) {
363 $settings = $this->get_module_settings();
364 $threshold = $settings['cart_threshold'] ?? 1;
365
366 // Early return if the cart item count is less than the threshold
367 if ( WC()->cart->get_cart_contents_count() < $threshold ) {
368 return;
369 }
370
371 $theme = wp_get_theme();
372 $theme_name = $theme->get( 'Name' );
373
374 $is_enabled_cart_page = $settings['enable_cart_page'] ?? true;
375 $cart_page_position = $settings['cart_page_position'] ?? 'woocommerce_cart_coupon';
376
377 $label = $settings['label'] ?? esc_html__( 'Clear Cart', 'merchant' );
378 $style = $settings['style'] ?? 'solid';
379
380 $classes = 'merchant-clear-cart-button';
381 $classes .= ' merchant-clear-cart-button--' . $style;
382 $classes .= $context ? ' merchant-clear-cart-button--' . $context : '';
383 $classes .= $context === 'cart-page' ? ' ' . ( $settings['cart_page_position'] ?? 'woocommerce_cart_coupon' ) : '';
384 ?>
385 <button type="button" class="button<?php echo esc_attr( wc_wp_theme_get_element_class_name( 'button' ) ? ' ' . wc_wp_theme_get_element_class_name( 'button' ) : '' ); ?> <?php echo esc_attr( $classes ); ?>">
386 <?php echo esc_html( $label ); ?>
387 </button>
388 <?php
389 // Because of a CSS issue, adding extra Update cart button on Botiga. Default one hidden by CSS.
390 if ( $context === 'cart-page' && $theme_name === 'Botiga' && ! $this->is_shortcode_enabled() && $is_enabled_cart_page && $cart_page_position === 'woocommerce_cart_actions' ) {
391 ?>
392 <button type="submit" class="button<?php echo esc_attr( wc_wp_theme_get_element_class_name( 'button' ) ? ' ' . wc_wp_theme_get_element_class_name( 'button' ) : '' ); ?> merchant-clear-cart-button__update-cart" name="update_cart" value="<?php esc_attr_e( 'Update cart', 'merchant' ); ?>"><?php esc_html_e( 'Update cart', 'merchant' ); ?></button>
393 <?php
394 }
395 }
396
397 /**
398 * Cart count fragments.
399 *
400 * @param $fragments
401 *
402 * @return mixed
403 */
404 public function cart_count_fragment( $fragments ) {
405 $fragments['.merchant_clear_cart_cart_count'] = WC()->cart->get_cart_contents_count();
406
407 return $fragments;
408 }
409
410 /**
411 * Clear Cart AJAX
412 *
413 * @return void
414 */
415 public function clear_cart_ajax_handler() {
416 check_ajax_referer( 'merchant-nonce', 'nonce' );
417
418 if ( WC()->cart && ! WC()->cart->is_empty() ) {
419 $settings = $this->get_module_settings();
420
421 $redirect_url = '';
422 $redirect_link = $settings['redirect_link'] ?? '';
423
424 switch ( $redirect_link ) {
425 case 'home':
426 $redirect_url = home_url();
427 break;
428
429 case 'shop':
430 $redirect_url = wc_get_page_permalink( 'shop' );
431 break;
432
433 case 'custom':
434 $custom_link = $settings['redirect_link_custom'] ?? '';
435 $redirect_url = ! empty( $custom_link ) ? esc_url( $custom_link ) : '';
436 break;
437 }
438
439 WC()->cart->empty_cart();
440 wp_send_json_success( array( 'url' => $redirect_url ) );
441 }
442
443 wp_send_json_error( array( 'message' => esc_html__( 'Cart is Empty.', 'merchant' ) ) );
444 }
445
446 /**
447 * Determine if assets should be enqueued.
448 *
449 * @return bool
450 */
451 private function should_load_assets() {
452 $settings = $this->get_module_settings();
453
454 // Check if auto-clear is enabled or if the shortcode is being used
455 $load_assets = ( $settings['enable_auto_clear'] ?? false ) || $this->is_shortcode_enabled();
456
457 // Check additional conditions: cart page, mini cart, or side cart enabled
458 $load_assets = $load_assets || ( $settings['enable_cart_page'] && is_cart() ) || $settings['enable_mini_cart'] || $settings['enable_side_cart'];
459
460 return $load_assets;
461 }
462
463 /**
464 * Enqueue CSS.
465 *
466 * @return void
467 */
468 public function enqueue_css() {
469 if ( ! $this->should_load_assets() ) {
470 return;
471 }
472
473 // Specific module styles.
474 wp_enqueue_style( 'merchant-' . self::MODULE_ID, MERCHANT_URI . 'assets/css/modules/' . self::MODULE_ID . '/clear-cart.min.css', array(), MERCHANT_VERSION );
475 }
476
477 /**
478 * Enqueue scripts.
479 *
480 * @return void
481 */
482 public function enqueue_scripts() {
483 if ( ! $this->should_load_assets() ) {
484 return;
485 }
486
487 wp_enqueue_script( 'merchant-' . self::MODULE_ID, MERCHANT_URI . 'assets/js/modules/' . self::MODULE_ID . '/clear-cart.min.js', array( 'jquery' ), MERCHANT_VERSION, true );
488 }
489
490 /**
491 * Localize script with module settings.
492 *
493 * @param array $setting The merchant global object setting parameter.
494 * @return array $setting The merchant global object setting parameter.
495 */
496 public function localize_script( $setting ) {
497 if ( ! $this->should_load_assets() ) {
498 return $setting;
499 }
500
501 $module_settings = $this->get_module_settings();
502
503 $expiration_in_hours = (int) ( $module_settings['auto_clear_expiration_hours'] ?? 24 );
504 $expiration_in_seconds = $expiration_in_hours * 60 * 60;
505
506 $setting['clear_cart'] = array(
507 'threshold' => (int) ( $module_settings['cart_threshold'] ?? 1 ),
508 'auto_clear' => (bool) ( $module_settings['enable_auto_clear'] ?? false ),
509 'expiration_time' => $expiration_in_seconds,
510 'wc_session_expiration_time' => DAY_IN_SECONDS * 2, // Default 48h,
511 'popup_message' => $module_settings['popup_message'] ?? '',
512 'popup_message_inactive' => $module_settings['popup_message_inactive'] ?? '',
513 'is_cart_page' => is_cart(),
514 'is_product_single' => is_product(),
515 'added_to_cart_no_ajax' => ! empty( $_REQUEST['add-to-cart'] ) || ! empty( $_REQUEST['botiga-adtc-added-to-cart'] ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
516 'total_items' => WC()->cart->get_cart_contents_count(),
517 );
518
519 return $setting;
520 }
521
522 /**
523 * Admin custom CSS.
524 *
525 * @param string $css The custom CSS.
526 * @return string $css The custom CSS.
527 */
528 public function admin_custom_css( $css ) {
529 $css .= $this->get_module_custom_css();
530
531 return $css;
532 }
533
534 /**
535 * Frontend custom CSS.
536 *
537 * @param string $css The custom CSS.
538 * @return string $css The custom CSS.
539 */
540 public function frontend_custom_css( $css ) {
541 if ( ! $this->should_load_assets() ) {
542 return $css;
543 }
544
545 $settings = $this->get_module_settings();
546
547 $is_enabled_cart_page = $settings['enable_cart_page'] ?? true;
548 $cart_page_position = $settings['cart_page_position'] ?? 'woocommerce_cart_coupon';
549 $is_enabled_mini_cart = $settings['enable_mini_cart'] ?? false;
550
551 $theme = wp_get_theme();
552 $theme_name = $theme->get( 'Name' );
553
554 $css .= $this->get_module_custom_css();
555
556 if ( $theme_name === 'Botiga' && ! $this->is_shortcode_enabled() ) {
557 if ( $is_enabled_mini_cart ) {
558 $css .= '
559 #site-header-cart button.merchant-clear-cart-button {
560 color: var(--mrc-clear-cart-text-color, #ffffff);
561 font-size: var(--mrc-clear-cart-font-size, 16px) !important;
562 padding-block: var(--mrc-clear-cart-padding-vertical, 13px) !important;
563 padding-inline: var(--mrc-clear-cart-padding-horizontal, 25px) !important;
564 margin-top: 5px;
565 text-decoration: none;
566 }
567
568 #site-header-cart button.merchant-clear-cart-button:hover {
569 background: none;
570 color: var(--mrc-clear-cart-text-color-hover, #ffffff);
571 }
572
573 #site-header-cart button.merchant-clear-cart-button--solid,
574 #site-header-cart button.merchant-clear-cart-button--outline {
575 margin-top: 15px;
576 }
577
578 #site-header-cart button.merchant-clear-cart-button--solid {
579 background-color: var(--mrc-clear-cart-bg-color, #212121) !important;
580 }
581
582 #site-header-cart button.merchant-clear-cart-button--solid:hover {
583 background-color: var(--mrc-clear-cart-bg-color-hover, #414141) !important;
584 }
585
586 #site-header-cart button.merchant-clear-cart-button--outline {
587 border: 2px solid var(--mrc-clear-cart-border-color, #212121);
588 }
589
590 #site-header-cart button.merchant-clear-cart-button--outline:hover {
591 border-color: var(--mrc-clear-cart-border-color-hover, #414141);
592 }
593 ';
594 }
595
596 // After Coupon
597 if ( $is_enabled_cart_page && $cart_page_position === 'woocommerce_cart_coupon' ) {
598 $css .= '@media (max-width: 767px) {';
599 $css .= '
600 .woocommerce-cart .woocommerce-cart-form .actions .coupon {
601 flex-wrap: wrap;
602 }
603
604 ';
605 $css .= '}';
606
607 $css .= '@media (max-width: 575px) {';
608 $css .= '
609 .button.merchant-clear-cart-button {
610 min-width: 100%;
611 margin-top: 10px;
612 }
613 ';
614 $css .= '}';
615 }
616
617 // After Update Cart Button
618 if ( $is_enabled_cart_page && $cart_page_position === 'woocommerce_cart_actions' ) {
619 $css .= '
620 .shop_table .button[name="update_cart"]:not(.merchant-clear-cart-button__update-cart) {
621 display: none;
622 }
623 ';
624
625 $css .= '@media (max-width: 767px) {';
626 $css .= '
627 .button.merchant-clear-cart-button {
628 margin-top: 15px;
629 margin-left: 10px;
630 }
631 ';
632 $css .= '}';
633
634 $css .= '@media (max-width: 575px) {';
635 $css .= '
636 .button.merchant-clear-cart-button {
637 width: 100%;
638 margin-top: 15px;
639 margin-left: 0px;
640 }
641 ';
642 $css .= '}';
643 }
644 }
645
646 return $css;
647 }
648
649 /**
650 * Custom CSS.
651 *
652 * @return string
653 */
654 public function get_module_custom_css() {
655 if ( ! $this->should_load_assets() && ! is_admin() ) {
656 return '';
657 }
658
659 $css = '';
660
661 // Background Color.
662 $css .= Merchant_Custom_CSS::get_variable_css( self::MODULE_ID, 'background_color', '#212121', '.merchant-clear-cart-button', '--mrc-clear-cart-bg-color' );
663
664 // Background Color(Hover).
665 $css .= Merchant_Custom_CSS::get_variable_css( self::MODULE_ID, 'background_color_hover', '#414141', '.merchant-clear-cart-button', '--mrc-clear-cart-bg-color-hover' );
666
667 // Border Width
668 $css .= Merchant_Custom_CSS::get_variable_css( self::MODULE_ID, 'border_width', 2, '.merchant-clear-cart-button', '--mrc-clear-cart-border-width', 'px' );
669
670 // Border Color
671 $css .= Merchant_Custom_CSS::get_variable_css( self::MODULE_ID, 'border_color', '#212121', '.merchant-clear-cart-button', '--mrc-clear-cart-border-color' );
672
673 // Border Color(Hover).
674 $css .= Merchant_Custom_CSS::get_variable_css( self::MODULE_ID, 'border_color_hover', '#414141', '.merchant-clear-cart-button', '--mrc-clear-cart-border-color-hover' );
675
676 // Border radius.
677 $css .= Merchant_Custom_CSS::get_variable_css( self::MODULE_ID, 'border_radius', 0, '.merchant-clear-cart-button', '--mrc-clear-cart-border-radius', 'px' );
678
679 // Text Color.
680 $css .= Merchant_Custom_CSS::get_variable_css( self::MODULE_ID, 'text_color', '#ffffff', '.merchant-clear-cart-button', '--mrc-clear-cart-text-color' );
681
682 // Text Color(Hover).
683 $css .= Merchant_Custom_CSS::get_variable_css( self::MODULE_ID, 'text_color_hover', '#ffffff', '.merchant-clear-cart-button', '--mrc-clear-cart-text-color-hover' );
684
685 // Font Size.
686 $css .= Merchant_Custom_CSS::get_variable_css( self::MODULE_ID, 'font_size', 16, '.merchant-clear-cart-button', '--mrc-clear-cart-font-size', 'px' );
687
688 // Padding Top/Bottom.
689 $css .= Merchant_Custom_CSS::get_variable_css( self::MODULE_ID, 'padding_vertical', 15, '.merchant-clear-cart-button', '--mrc-clear-cart-padding-vertical', 'px' );
690
691 // Padding Left/Right.
692 $css .= Merchant_Custom_CSS::get_variable_css( self::MODULE_ID, 'padding_horizontal', 25, '.merchant-clear-cart-button', '--mrc-clear-cart-padding-horizontal', 'px' );
693
694 return $css;
695 }
696 }
697
698 // Initialize the module.
699 add_action( 'init', static function () {
700 Merchant_Modules::create_module( new Merchant_Clear_Cart() );
701 } );
702