PluginProbe
Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder / 3.0.2
Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder v3.0.2
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.0.2, at templates/florence-grid.php

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