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 / glossy-grid.php

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

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