PluginProbe
Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder / 3.0.3
Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder v3.0.3
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 / glossy-grid.php

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

153 lines 6.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Glossy Grid Template Class
5 *
6 * Handles rendering of product items in the Glossy 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_Glossy_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 Glossy 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_glossy_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 $tooltip_position = isset($settings['tooltip_position']) ? $settings['tooltip_position'] : 'right';
51 // get the class based on the widget
52 $show_rating = isset($settings['show_rating']) ? $settings['show_rating'] : true;
53 $classes = $this->target_widget_name === 'glossy-grid' ? 'usk-item' : 'usk-item swiper-slide';
54 $classes .= $show_rating ? ' usk-have-rating' : '';
55 $title_tags = isset($settings['title_tags']) ? $settings['title_tags'] : 'h3';
56
57 ?>
58 <div class="<?php echo esc_attr($classes); ?>" data-product-id="<?php echo esc_attr($product_id); ?>">
59 <div class="usk-item-box">
60 <?php $this->render_product_image($product, $settings); ?>
61 <div class="usk-content">
62 <div class="usk-content-inner">
63 <?php if (isset($settings['show_title']) ? $settings['show_title'] : true):
64 printf(
65 '<%1$s class="title"><a href="%2$s" class="usk-title" aria-label="%4$s">%3$s</a></%1$s>',
66 esc_attr(Utils::get_valid_html_tag($title_tags)),
67 esc_url($product->get_permalink()),
68 esc_html($product->get_title()),
69 esc_attr(sprintf('View details for %s', $product->get_title()))
70 );
71 endif; ?>
72 <?php if (isset($settings['show_price']) ? $settings['show_price'] : true && $product->get_price_html()): ?>
73 <div class="usk-price">
74 <?php $this->print_price_output($product->get_price_html()); ?>
75 </div>
76 <?php endif; ?>
77 <?php if (isset($settings['show_rating']) ? $settings['show_rating'] : true): ?>
78 <div class="usk-rating">
79 <?php echo wp_kses_post($this->register_global_template_wc_rating($average, $rating_count)); ?></span>
80 </div>
81 <?php endif; ?>
82 </div>
83 </div>
84 <div class="usk-shoping">
85 <?php
86 $this->register_global_template_add_to_wishlist($tooltip_position, $settings);
87 $this->register_global_template_add_to_compare($tooltip_position, $settings);
88 $this->register_global_template_quick_view($product->get_id(), $tooltip_position, $settings);
89 $this->register_global_template_add_to_cart($tooltip_position, $settings);
90
91 ?>
92 </div>
93 </div>
94 </div>
95 <?php
96 }
97 /**
98 * Render product image with hover effect and action buttons
99 *
100 * @param WC_Product $product The product object
101 */
102 public function render_product_image($product, $settings) {
103 if (!$product) {
104 return;
105 }
106 $gallery_thumbs = $product->get_gallery_image_ids();
107 $product_image = wp_get_attachment_image_url(get_post_thumbnail_id(), isset($settings['image_size']) ? $settings['image_size'] : 'full');
108
109 // if product image is empty, use placeholder
110 if (empty($product_image)) {
111 $product_image = wc_placeholder_img_src('full');
112 }
113
114 if ($gallery_thumbs) {
115 foreach ($gallery_thumbs as $key => $gallery_thumb) {
116 if ($key == 0):
117 $gallery_image_link = wp_get_attachment_image_url($gallery_thumb, isset($settings['image_size']) ? $settings['image_size'] : 'full');
118 endif;
119 }
120 } else {
121 $gallery_image_link = wp_get_attachment_image_url(get_post_thumbnail_id(), isset($settings['image_size']) ? $settings['image_size'] : 'full');
122 }
123 ?>
124 <div class="usk-image">
125 <a href="<?php echo esc_url(get_permalink()); ?>">
126 <img class="img image-default" src="<?php echo esc_url($product_image); ?>"
127 alt="<?php echo esc_html(get_the_title()); ?>">
128 <img class="img image-hover" src="<?php echo esc_url($gallery_image_link); ?>"
129 alt="<?php echo esc_html(get_the_title()); ?>">
130 </a>
131 <div class="usk-badge-label-wrapper">
132 <div class="usk-badge-label-content usk-flex usk-flex-column usk-flex-bottom">
133 <?php $this->register_global_template_badge_label($settings); ?>
134 </div>
135 </div>
136 </div>
137 <?php
138 }
139
140 public function print_price_output($output) {
141 $tags = [
142 'del' => ['aria-hidden' => []],
143 'span' => ['class' => []],
144 'bdi' => [],
145 'ins' => [],
146 ];
147
148 if (isset($output)) {
149 echo wp_kses($output, $tags);
150 }
151 }
152 }
153