PluginProbe
Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder / 3.1.4
Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder v3.1.4
3.1.4 3.0.8 3.0.9 3.1.0 3.1.2 3.1.3 3.0.7 3.0.5 3.0.4 3.0.3 3.0.2 trunk 1.5.0 1.5.1 1.5.2 1.6.1 1.6.2 1.6.3 1.6.4 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 All 93 releases
ultimate-store-kit / templates / florence-grid.php

florence-grid.php in Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder 3.1.4, at templates/florence-grid.php

163 lines 6.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Florence Grid Template Class
5 *
6 * Handles rendering of product items in the Florence Grid layout
7 */
8
9
10 namespace UltimateStoreKit\Templates;
11
12 if (! defined('ABSPATH')) {
13 exit; // Exit if accessed directly
14 }
15
16 use UltimateStoreKit\Traits\Global_Widget_Template;
17 use UltimateStoreKit\Classes\Utils;
18
19
20 class USK_Florence_Grid_Template {
21 use Global_Widget_Template;
22 /**
23 * Target widget settings
24 *
25 * @var array
26 */
27 protected $target_widget_settings = [];
28 protected $target_widget_name = '';
29 /**
30 * Constructor
31 *
32 * @param array $settings Widget settings
33 * @param string $widget_name Widget name
34 */
35 public function __construct($settings = [], $widget_name = '') {
36 $this->target_widget_settings = $settings;
37 $this->target_widget_name = $widget_name;
38 }
39
40 /**
41 * Render a single product item specifically for the Florence Grid widget
42 *
43 * @param WC_Product $product The product object to render
44 * @param array $settings The widget settings
45 */
46 public function render_florence_grid_item($product, $settings) {
47 if (!$product) {
48 return;
49 }
50 $product_id = $product->get_id();
51 $rating_count = $product->get_rating_count();
52 $average = $product->get_average_rating();
53 // Get product categories
54 $categories = wc_get_product_category_list($product_id, ' ');
55 $category_tags = isset($settings['category_tags']) ? $settings['category_tags'] : 'h5';
56 $title_tags = isset($settings['title_tags']) ? $settings['title_tags'] : 'h3';
57
58 // get the class based on the widget name
59 $show_rating = isset($settings['show_rating']) ? $settings['show_rating'] : true;
60 $classes = $this->target_widget_name === 'florence-grid' ? 'usk-item' : 'usk-item swiper-slide';
61 $classes .= $show_rating ? ' usk-have-rating' : '';
62
63
64 ?>
65 <div class="<?php echo esc_attr($classes); ?>" data-product-id="<?php echo esc_attr($product_id); ?>">
66 <div class="usk-item-box">
67 <?php $this->render_product_image($product, $settings); ?>
68 <div class="usk-content">
69 <div class="usk-content-inner">
70 <?php if ($categories && (isset($settings['show_category']) ? $settings['show_category'] : true)) : ?>
71 <div class="usk-category">
72 <?php echo wp_kses_post(wc_get_product_category_list($product->get_id(), ' ')); ?>
73 </div>
74 <?php endif; ?>
75 <?php if (isset($settings['show_title']) ? $settings['show_title'] : true) :
76 printf(
77 '<%1$s class="title"><a href="%2$s" class="usk-title" aria-label="%4$s">%3$s</a></%1$s>',
78 esc_attr(Utils::get_valid_html_tag($title_tags)),
79 esc_url($product->get_permalink()),
80 esc_html($product->get_title()),
81 esc_attr(sprintf('View details for %s', $product->get_title()))
82 );
83 endif; ?>
84 <?php if (isset($settings['show_price']) ? $settings['show_price'] : true && $product->get_price_html()) : ?>
85 <div class="usk-price">
86 <?php $this->print_price_output($product->get_price_html()); ?>
87 </div>
88 <?php endif; ?>
89 <?php if (isset($settings['show_rating']) ? $settings['show_rating'] : true) : ?>
90 <div class="usk-rating">
91 <span><?php echo wp_kses_post($this->register_global_template_wc_rating($average, $rating_count)); ?></span>
92 </div>
93 <?php endif; ?>
94 </div>
95 </div>
96 </div>
97 </div>
98 <?php
99 }
100 /**
101 * Render product image with hover effect and action buttons
102 *
103 * @param WC_Product $product The product object
104 */
105 public function render_product_image($product, $settings) {
106 if (!$product) {
107 return;
108 }
109
110 $tooltip_position = 'left';
111 $gallery_thumbs = $product->get_gallery_image_ids();
112 $product_image = wp_get_attachment_image_url(get_post_thumbnail_id(), isset($settings['image_size']) ? $settings['image_size'] : 'full');
113
114 // if product image is empty, use placeholder
115 if (empty($product_image)) {
116 $product_image = wc_placeholder_img_src('full');
117 }
118 if ($gallery_thumbs) {
119 foreach ($gallery_thumbs as $key => $gallery_thumb) {
120 if ($key == 0) :
121 $gallery_image_link = wp_get_attachment_image_url($gallery_thumb, isset($settings['image_size']) ? $settings['image_size'] : 'full');
122 endif;
123 }
124 } else {
125 $gallery_image_link = wp_get_attachment_image_url(get_post_thumbnail_id(), isset($settings['image_size']) ? $settings['image_size'] : 'full');
126 }
127 ?>
128 <div class="usk-image">
129 <a href="<?php echo esc_url(get_permalink()); ?>">
130 <img class="img image-default" src="<?php echo esc_url($product_image); ?>" alt="<?php echo esc_attr(get_the_title()); ?>">
131 <img class="img image-hover" src="<?php echo esc_url($gallery_image_link); ?>" alt="<?php echo esc_attr(get_the_title()); ?>">
132 </a>
133 <div class="usk-shoping">
134 <?php
135 $this->register_global_template_add_to_wishlist($tooltip_position, $settings);
136 $this->register_global_template_add_to_compare($tooltip_position, $settings);
137 $this->register_global_template_quick_view($product->get_id(), $tooltip_position, $settings);
138 $this->register_global_template_add_to_cart($tooltip_position, $settings);
139 ?>
140 </div>
141 <div class="usk-badge-label-wrapper">
142 <div class="usk-badge-label-content usk-flex usk-flex-column">
143 <?php $this->register_global_template_badge_label($settings); ?>
144 </div>
145 </div>
146 </div>
147 <?php
148 }
149
150 public function print_price_output($output) {
151 $tags = [
152 'del' => ['aria-hidden' => []],
153 'span' => ['class' => []],
154 'bdi' => [],
155 'ins' => [],
156 ];
157
158 if (isset($output)) {
159 echo wp_kses($output, $tags);
160 }
161 }
162 }
163