PluginProbe
Caddy – WooCommerce Side Cart & Free Shipping Bar / 3.0.2
Caddy – WooCommerce Side Cart & Free Shipping Bar v3.0.2
3.2.0 3.1.1 trunk 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8 1.7.9 1.8 1.8.1 1.8.2 1.9 1.9.2 1.9.3 All 46 releases
caddy / render.php

render.php in Caddy – WooCommerce Side Cart & Free Shipping Bar 3.0.2, at render.php

85 lines 4.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Caddy Cart Block Render Template
4 *
5 * This template renders the interactive cart block using WordPress Interactivity API
6 * with the original Caddy template structure.
7 *
8 * @package Caddy
9 * @since 2.1.3
10 */
11
12 if (!defined('ABSPATH')) {
13 exit; // Exit if accessed directly
14 }
15
16 // Get block attributes with defaults
17 $auto_open = $attributes['autoOpen'] ?? true;
18
19 // Only show free version compass if premium plugin is not active (same logic as original)
20 if (!class_exists('Caddy_Premium')) {
21 // Ensure cart session is properly initialized
22 if (function_exists('WC') && WC()->session) {
23 // Initialize WooCommerce session if not already done
24 if (!WC()->session->has_session()) {
25 WC()->session->set_customer_session_cookie(true);
26 }
27
28 // Ensure cart is loaded
29 if (WC()->cart) {
30 $cart_count = WC()->cart->get_cart_contents_count();
31 if ( $cart_count > 0 ) {
32 WC()->cart->calculate_totals();
33 }
34 } else {
35 $cart_count = 0;
36 }
37 } else {
38 $cart_count = 0;
39 }
40 ?>
41 <div data-wp-interactive="caddy/cart" data-wp-context='{"autoOpen": <?php echo json_encode($auto_open); ?>}'>
42 <!-- The floating compass icon (same as original) -->
43 <div class="cc-compass" data-wp-on--click="actions.toggleCart" data-wp-class--cc-compass-open="state.isOpen">
44 <span class="cc-compass-cart-icon" data-wp-class--cc-hidden="state.isOpen">
45 <?php
46 $allowed_svg = array(
47 'svg' => array( 'xmlns' => true, 'viewbox' => true, 'width' => true, 'height' => true, 'fill' => true, 'stroke' => true, 'stroke-linecap' => true, 'stroke-linejoin' => true, 'style' => true, 'class' => true, 'aria-hidden' => true ),
48 'path' => array( 'd' => true, 'stroke-width' => true, 'fill' => true, 'stroke' => true ),
49 'circle' => array( 'cx' => true, 'cy' => true, 'r' => true, 'fill' => true, 'stroke' => true, 'stroke-width' => true ),
50 'rect' => array( 'x' => true, 'y' => true, 'width' => true, 'height' => true, 'rx' => true, 'ry' => true, 'fill' => true, 'stroke' => true, 'stroke-width' => true ),
51 'line' => array( 'x1' => true, 'y1' => true, 'x2' => true, 'y2' => true, 'stroke' => true, 'stroke-width' => true ),
52 'polyline' => array( 'points' => true, 'fill' => true, 'stroke' => true, 'stroke-width' => true ),
53 'polygon' => array( 'points' => true, 'fill' => true, 'stroke' => true, 'stroke-width' => true ),
54 'g' => array( 'fill' => true, 'stroke' => true, 'transform' => true ),
55 );
56 echo wp_kses( apply_filters('caddy_cart_bubble_icon', '<svg xmlns="http://www.w3.org/2000/svg" viewBox="-0.5 -0.5 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" style="display:inline-block;vertical-align:middle;"><path d="M5.75 1.9166666666666667 2.875 5.75v13.416666666666668a1.9166666666666667 1.9166666666666667 0 0 0 1.9166666666666667 1.9166666666666667h13.416666666666668a1.9166666666666667 1.9166666666666667 0 0 0 1.9166666666666667 -1.9166666666666667V5.75l-2.875 -3.8333333333333335z" stroke-width="1.2"></path><path d="m2.875 5.75 17.25 0" stroke-width="1.2"></path><path d="M15.333333333333334 9.583333333333334a3.8333333333333335 3.8333333333333335 0 0 1 -7.666666666666667 0" stroke-width="1.2"></path></svg>'), $allowed_svg );
57 ?>
58 </span>
59 <span class="cc-compass-close-icon cc-hidden" data-wp-class--cc-hidden="!state.isOpen">
60 <i class="ccicon-close"></i>
61 </span>
62 <div class="cc-loader" style="display: none;"></div>
63 <span class="cc-compass-count"
64 data-wp-class--cc-cart-zero="state.cartCount === 0"
65 data-wp-text="state.cartCount">
66 <?php echo esc_html($cart_count); ?>
67 </span>
68 </div>
69
70 <!-- The expanded modal (using original structure) -->
71 <div class="cc-window disable-scrollbars" data-wp-class--cc-show="state.isOpen">
72 <div class="cc-window-wrapper">
73 <?php
74 // Use the original window screen content
75 include(plugin_dir_path(__FILE__) . 'public/partials/caddy-public-window.php');
76 ?>
77 </div>
78 </div>
79
80 <!-- Overlay (same as original) -->
81 <div class="cc-overlay" data-wp-class--cc-show="state.isOpen" data-wp-on--click="actions.closeCart"></div>
82 </div>
83 <?php
84 }
85 ?>