| 1 |
<?php |
| 2 |
|
| 3 |
namespace UltimateStoreKit\Traits; |
| 4 |
|
| 5 |
use Elementor\Plugin; |
| 6 |
|
| 7 |
// use WP_Query; |
| 8 |
|
| 9 |
|
| 10 |
defined('ABSPATH') || die(); |
| 11 |
|
| 12 |
trait Global_Widget_Template { |
| 13 |
|
| 14 |
protected function register_global_template_wc_rating($rating, $count = 0) { |
| 15 |
$html = ''; |
| 16 |
if ( |
| 17 |
0 <= $rating |
| 18 |
) { |
| 19 |
/* translators: %s: rating */ |
| 20 |
// $label = sprintf(__('Rated %s out of 5', 'woocommerce'), $rating); |
| 21 |
$html = '<div class="star-rating" role="img">' . wc_get_star_rating_html($rating, $count) . '</div>'; |
| 22 |
} |
| 23 |
|
| 24 |
return apply_filters('woocommerce_product_get_rating_html', $html, $rating, $count); |
| 25 |
} |
| 26 |
public function register_global_template_add_to_wishlist($tooltip_position) { |
| 27 |
$settings = $this->get_settings_for_display(); |
| 28 |
global $product; |
| 29 |
$user_id = get_current_user_id(); |
| 30 |
$product_id = $product->get_ID(); |
| 31 |
$wishlist = ultimate_store_kit_get_wishlist($user_id); |
| 32 |
$is_wishlisted = in_array($product_id, $wishlist); |
| 33 |
if (!empty($is_wishlisted)) { |
| 34 |
$selected = ' usk-active'; |
| 35 |
$tooltip = esc_html__('Wishlist item Added!', 'ultimate-store-kit'); |
| 36 |
} else { |
| 37 |
$selected = ''; |
| 38 |
$tooltip = esc_html__('Add to Wishlist', 'ultimate-store-kit'); |
| 39 |
} ?> |
| 40 |
<?php if ($settings['show_wishlist'] == 'yes') : ?> |
| 41 |
<a href="javascript:void(0);" class="usk-action-btn ajax_add_to_wishlist usk-shoping-icon-wishlist usk-btn usk-wishlist<?php echo esc_attr($selected); ?>" data-product_id="<?php echo absint($product_id); ?>" aria-label="<?php echo esc_html__($tooltip); ?>" data-microtip-position="<?php echo esc_attr($tooltip_position); ?>" role="tooltip"> |
| 42 |
<i class="icon eicon-heart"></i> |
| 43 |
</a> |
| 44 |
<?php endif; ?> |
| 45 |
<?php |
| 46 |
} |
| 47 |
|
| 48 |
function register_global_template_add_to_compare($tooltip_position) { |
| 49 |
global $product; |
| 50 |
$settings = $this->get_settings_for_display(); |
| 51 |
$user_id = get_current_user_id(); |
| 52 |
$product_id = $product->get_ID(); |
| 53 |
$compare_products = usk_get_compare_products($user_id); |
| 54 |
$is_compared = in_array($product_id, $compare_products); |
| 55 |
|
| 56 |
if (!empty($is_compared)) { |
| 57 |
$tooltip = esc_html__('Added', 'ultimate-store-kit'); |
| 58 |
$selected = 'usk-active'; |
| 59 |
} else { |
| 60 |
$tooltip = esc_html__('Compare', 'ultimate-store-kit'); |
| 61 |
$selected = ''; |
| 62 |
} ?> |
| 63 |
<?php if ($settings['show_compare'] == 'yes') : ?> |
| 64 |
<a href="javascript:void(0)" class="usk-action-btn ajax_add_to_compare usk-compare <?php echo esc_attr($selected); ?>" data-product_id="<?php echo $product_id; ?>" aria-label="<?php echo esc_html__($tooltip); ?>" data-microtip-position="<?php echo esc_attr($tooltip_position); ?>" role="tooltip"> |
| 65 |
<i class="icon eicon-flow"></i> |
| 66 |
</a> |
| 67 |
<?php |
| 68 |
?> |
| 69 |
<?php endif; ?> |
| 70 |
<?php |
| 71 |
|
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
protected function register_global_template_quick_view($product_id, $tooltip_position) { |
| 76 |
$settings = $this->get_settings_for_display(); |
| 77 |
if ('yes' == $settings['show_quick_view']) : ?> |
| 78 |
<?php wp_nonce_field('ajax-usk-quick-view-nonce', 'usk-quick-view-modal-sc'); |
| 79 |
?> |
| 80 |
<a class="usk-action-btn usk-shoping-icon-quickview quick_view usk-view usk-btn" href="javascript:void(0)" data-id="<?php echo absint($product_id); ?>" aria-label="<?php echo esc_html__('Quick View'); ?>" data-microtip-position="<?php echo esc_attr($tooltip_position); ?>" role="tooltip"> |
| 81 |
<i class="icon eicon-preview-medium"></i> |
| 82 |
</a> |
| 83 |
<?php endif; |
| 84 |
} |
| 85 |
protected function register_global_template_add_to_cart($tooltip_position) { |
| 86 |
global $product; |
| 87 |
$settings = $this->get_settings_for_display(); |
| 88 |
if ('yes' == $settings['show_cart']) : ?> |
| 89 |
<?php if ($product) { |
| 90 |
$defaults = [ |
| 91 |
'quantity' => 1, |
| 92 |
'class' => implode( |
| 93 |
' ', |
| 94 |
array_filter( |
| 95 |
[ |
| 96 |
'usk-cart', |
| 97 |
'usk-action-btn', |
| 98 |
'product_type_' . $product->get_type(), |
| 99 |
$product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '', |
| 100 |
$product->supports('ajax_add_to_cart') && $product->is_purchasable() && $product->is_in_stock() ? 'ajax_add_to_cart' : '', |
| 101 |
] |
| 102 |
) |
| 103 |
), |
| 104 |
'attributes' => [ |
| 105 |
'data-product_id' => $product->get_id(), |
| 106 |
'data-product_sku' => $product->get_sku(), |
| 107 |
'data-microtip-position' => $tooltip_position, |
| 108 |
'aria-label' => $product->add_to_cart_text(), |
| 109 |
'rel' => 'nofollow', |
| 110 |
'role' => 'tooltip', |
| 111 |
], |
| 112 |
]; |
| 113 |
$args = apply_filters('woocommerce_loop_add_to_cart_args', wp_parse_args($defaults), $product); |
| 114 |
if (isset($args['attributes']['aria-label'])) { |
| 115 |
$args['attributes']['aria-label'] = wp_strip_all_tags($args['attributes']['aria-label']); |
| 116 |
} |
| 117 |
echo apply_filters( |
| 118 |
'woocommerce_loop_add_to_cart_link', // WPCS: XSS ok. |
| 119 |
sprintf( |
| 120 |
'<a href="%s" data-quantity="%s" class="%s" %s><i class="icon eicon-cart-light"></i></a>', |
| 121 |
esc_url($product->add_to_cart_url()), |
| 122 |
esc_attr(isset($args['quantity']) ? $args['quantity'] : 1), |
| 123 |
esc_attr(isset($args['class']) ? $args['class'] : 'button'), |
| 124 |
isset($args['attributes']) ? wc_implode_html_attributes($args['attributes']) : '' |
| 125 |
), |
| 126 |
$product, |
| 127 |
$args |
| 128 |
); |
| 129 |
}; ?> |
| 130 |
<?php endif; |
| 131 |
} |
| 132 |
protected function register_global_template_badge_label() { |
| 133 |
$settings = $this->get_settings_for_display(); |
| 134 |
global $product; |
| 135 |
if ($product->is_on_sale() && $settings['show_sale_badge']) : |
| 136 |
printf('<div class="usk-badge-wrap usk-sale-badge"><span class="usk-badge">%1$s</span></div>', esc_html__('Sale', 'ultimate-store-kit')); |
| 137 |
endif; |
| 138 |
if ($settings['show_discount_badge']) : |
| 139 |
$this->usk_get_badge_label_percentage(); |
| 140 |
endif; |
| 141 |
if (($settings['show_stock_status'] === 'yes')) : |
| 142 |
if ($product->get_stock_status() === 'instock') { |
| 143 |
$stock_status = esc_html__('In Stock', 'ultimate-store-kit'); |
| 144 |
} else { |
| 145 |
$stock_status = esc_html__('Out of Stock', 'ultimate-store-kit'); |
| 146 |
} |
| 147 |
|
| 148 |
printf('<div class="usk-badge-wrap usk-stock-status-badge"><span class="usk-badge">%1$s</span></div>', $stock_status); |
| 149 |
endif; |
| 150 |
if ($product->is_featured() && $settings['show_trending_badge']) : |
| 151 |
printf('<div class="usk-badge-wrap usk-trending-badge"><span class="usk-badge">%1$s</span></div>', esc_html__('Trending', 'ultimate-store-kit')); |
| 152 |
endif; |
| 153 |
if ($settings['show_new_badge']) : |
| 154 |
$newness_days = $settings['newness_days']; |
| 155 |
$created_date = strtotime($product->get_date_created()); |
| 156 |
$valid_date = time() - (60 * 60 * 24 * $newness_days); |
| 157 |
if ($valid_date < $created_date) { |
| 158 |
printf('<div class="usk-badge-wrap usk-new-badge"><span class="usk-badge">%s</span></div>', esc_html__('New', 'ultimate-store-kit')); |
| 159 |
} |
| 160 |
endif; |
| 161 |
} |
| 162 |
protected function register_global_template_navigation() { |
| 163 |
$settings = $this->get_settings_for_display(); |
| 164 |
$hide_arrow_on_mobile = $settings['hide_arrow_on_mobile'] ? ' usk-visible@m' : ''; |
| 165 |
|
| 166 |
if ('arrows' == $settings['navigation']) : ?> |
| 167 |
<div style="direction: ltr;" class="usk-position-z-index usk-position-<?php echo esc_html($settings['arrows_position'] . $hide_arrow_on_mobile); ?>"> |
| 168 |
<div class="usk-arrows-container usk-slidenav-container"> |
| 169 |
<a href="" class="usk-navigation-prev usk-slidenav-previous usk-icon usk-slidenav"> |
| 170 |
<i class="usk-icon-arrow-left-<?php echo esc_html($settings['nav_arrows_icon']); ?>" aria-hidden="true"></i> |
| 171 |
</a> |
| 172 |
<a href="" class="usk-navigation-next usk-slidenav-next usk-icon usk-slidenav"> |
| 173 |
<i class="usk-icon-arrow-right-<?php echo esc_html($settings['nav_arrows_icon']); ?>" aria-hidden="true"></i> |
| 174 |
</a> |
| 175 |
</div> |
| 176 |
</div> |
| 177 |
<?php endif; |
| 178 |
} |
| 179 |
protected function register_global_template_pagination() { |
| 180 |
$settings = $this->get_settings_for_display(); |
| 181 |
|
| 182 |
if ('dots' == $settings['navigation'] or 'arrows-fraction' == $settings['navigation']) : ?> |
| 183 |
<div class="usk-position-z-index usk-position-<?php echo esc_html($settings['dots_position']); ?>"> |
| 184 |
<div class="usk-dots-container"> |
| 185 |
<div class="swiper-pagination"></div> |
| 186 |
</div> |
| 187 |
</div> |
| 188 |
|
| 189 |
<?php elseif ('progressbar' == $settings['navigation']) : ?> |
| 190 |
<div class="swiper-pagination usk-position-z-index usk-position-<?php echo esc_html($settings['progress_position']); ?>"></div> |
| 191 |
<?php endif; |
| 192 |
} |
| 193 |
protected function register_global_template_both_navigation() { |
| 194 |
$settings = $this->get_settings_for_display(); |
| 195 |
$hide_arrow_on_mobile = $settings['hide_arrow_on_mobile'] ? 'usk-visible@m usk-flex' : 'usk-flex'; |
| 196 |
|
| 197 |
?> |
| 198 |
<div class="usk-position-z-index usk-position-<?php echo esc_html($settings['both_position']); ?>"> |
| 199 |
<div class="usk-arrows-dots-container usk-slidenav-container "> |
| 200 |
|
| 201 |
<div class="usk-flex usk-flex-middle"> |
| 202 |
<div class="<?php echo esc_html($hide_arrow_on_mobile); ?>"> |
| 203 |
<a href="" class="usk-navigation-prev usk-slidenav-previous usk-icon usk-slidenav"> |
| 204 |
<i class="usk-icon-arrow-left-<?php echo esc_html($settings['nav_arrows_icon']); ?>" aria-hidden="true"></i> |
| 205 |
</a> |
| 206 |
</div> |
| 207 |
|
| 208 |
<?php if ('center' !== $settings['both_position']) : ?> |
| 209 |
<div class="swiper-pagination"></div> |
| 210 |
<?php endif; ?> |
| 211 |
|
| 212 |
<div class="<?php echo esc_html($hide_arrow_on_mobile); ?>"> |
| 213 |
<a href="" class="usk-navigation-next usk-slidenav-next usk-icon usk-slidenav"> |
| 214 |
<i class="usk-icon-arrow-right-<?php echo esc_html($settings['nav_arrows_icon']); ?>" aria-hidden="true"></i> |
| 215 |
</a> |
| 216 |
</div> |
| 217 |
|
| 218 |
</div> |
| 219 |
</div> |
| 220 |
</div> |
| 221 |
<?php |
| 222 |
} |
| 223 |
protected function register_global_template_arrows_fraction() { |
| 224 |
$settings = $this->get_settings_for_display(); |
| 225 |
$hide_arrow_on_mobile = $settings['hide_arrow_on_mobile'] ? 'usk-visible@m' : ''; ?> |
| 226 |
<div class="usk-position-z-index usk-position-<?php echo esc_html($settings['arrows_fraction_position']); ?>"> |
| 227 |
<div class="usk-arrows-fraction-container usk-slidenav-container "> |
| 228 |
|
| 229 |
<div class="usk-flex usk-flex-middle"> |
| 230 |
<div class="<?php echo esc_html($hide_arrow_on_mobile); ?>"> |
| 231 |
<a href="" class="usk-navigation-prev usk-slidenav-previous usk-icon usk-slidenav"> |
| 232 |
<i class="usk-icon-arrow-left-<?php echo esc_html($settings['nav_arrows_icon']); ?>" aria-hidden="true"></i> |
| 233 |
</a> |
| 234 |
</div> |
| 235 |
|
| 236 |
<?php if ('center' !== $settings['arrows_fraction_position']) : ?> |
| 237 |
<div class="swiper-pagination"></div> |
| 238 |
<?php endif; ?> |
| 239 |
|
| 240 |
<div class="<?php echo esc_html($hide_arrow_on_mobile); ?>"> |
| 241 |
<a href="" class="usk-navigation-next usk-slidenav-next usk-icon usk-slidenav"> |
| 242 |
<i class="usk-icon-arrow-right-<?php echo esc_html($settings['nav_arrows_icon']); ?>" aria-hidden="true"></i> |
| 243 |
</a> |
| 244 |
</div> |
| 245 |
|
| 246 |
</div> |
| 247 |
</div> |
| 248 |
</div> |
| 249 |
<?php |
| 250 |
} |
| 251 |
protected function usk_register_global_template_carousel_footer() { |
| 252 |
$settings = $this->get_settings_for_display(); ?> |
| 253 |
</div> |
| 254 |
<?php if ('yes' === $settings['show_scrollbar']) : ?> |
| 255 |
<div class="swiper-scrollbar"></div> |
| 256 |
<?php endif; ?> |
| 257 |
</div> |
| 258 |
<?php if ('both' == $settings['navigation']) : ?> |
| 259 |
<?php $this->register_global_template_both_navigation(); ?> |
| 260 |
<?php if ('center' === $settings['both_position']) : ?> |
| 261 |
<div class="usk-position-z-index usk-position-bottom"> |
| 262 |
<div class="usk-dots-container"> |
| 263 |
<div class="swiper-pagination"></div> |
| 264 |
</div> |
| 265 |
</div> |
| 266 |
<?php endif; ?> |
| 267 |
<?php elseif ('arrows-fraction' == $settings['navigation']) : ?> |
| 268 |
<?php $this->register_global_template_arrows_fraction(); ?> |
| 269 |
<?php if ('center' === $settings['arrows_fraction_position']) : ?> |
| 270 |
<div class="usk-dots-container"> |
| 271 |
<div class="swiper-pagination"></div> |
| 272 |
</div> |
| 273 |
<?php endif; ?> |
| 274 |
<?php else : ?> |
| 275 |
<?php $this->register_global_template_pagination() ?> |
| 276 |
<?php $this->register_global_template_navigation() ?> |
| 277 |
<?php endif; ?> |
| 278 |
</div> |
| 279 |
</div> |
| 280 |
</div> |
| 281 |
|
| 282 |
<?php |
| 283 |
} |
| 284 |
protected function register_global_template_carousel_header() { |
| 285 |
$settings = $this->get_settings_for_display(); |
| 286 |
$this->add_render_attribute('usk-carousel-wrapper', 'class', ['' . $this->get_name() . '', 'usk-content-position-' . $settings['alignment'] . '']); |
| 287 |
$id = 'ultimate-store-kit-' . $this->get_id(); |
| 288 |
$elementor_vp_lg = get_option('elementor_viewport_lg'); |
| 289 |
$elementor_vp_md = get_option('elementor_viewport_md'); |
| 290 |
$viewport_lg = !empty($elementor_vp_lg) ? $elementor_vp_lg - 1 : 1023; |
| 291 |
$viewport_md = !empty($elementor_vp_md) ? $elementor_vp_md - 1 : 767; |
| 292 |
$this->add_render_attribute('carousel', 'id', $id); |
| 293 |
$this->add_render_attribute('carousel', 'class', ['usk-carousel', 'usk-carousel-layout', 'elementor-swiper']); |
| 294 |
if ('arrows' == $settings['navigation']) { |
| 295 |
$this->add_render_attribute('carousel', 'class', 'usk-arrows-align-' . $settings['arrows_position']); |
| 296 |
} elseif ('dots' == $settings['navigation']) { |
| 297 |
$this->add_render_attribute('carousel', 'class', 'usk-dots-align-' . $settings['dots_position']); |
| 298 |
} elseif ('both' == $settings['navigation']) { |
| 299 |
$this->add_render_attribute('carousel', 'class', 'usk-arrows-dots-align-' . $settings['both_position']); |
| 300 |
} elseif ('arrows-fraction' == $settings['navigation']) { |
| 301 |
$this->add_render_attribute('carousel', 'class', 'usk-arrows-dots-align-' . $settings['arrows_fraction_position']); |
| 302 |
} |
| 303 |
|
| 304 |
if ('arrows-fraction' == $settings['navigation']) { |
| 305 |
$pagination_type = 'fraction'; |
| 306 |
} elseif ('both' == $settings['navigation'] or 'dots' == $settings['navigation']) { |
| 307 |
$pagination_type = 'bullets'; |
| 308 |
} elseif ('progressbar' == $settings['navigation']) { |
| 309 |
$pagination_type = 'progressbar'; |
| 310 |
} else { |
| 311 |
$pagination_type = ''; |
| 312 |
} |
| 313 |
|
| 314 |
$this->add_render_attribute( |
| 315 |
[ |
| 316 |
'carousel' => [ |
| 317 |
'data-settings' => [ |
| 318 |
wp_json_encode(array_filter([ |
| 319 |
"autoplay" => ("yes" == $settings["autoplay"]) ? ["delay" => $settings["autoplay_speed"]] : false, |
| 320 |
"loop" => ($settings["loop"] == "yes") ? true : false, |
| 321 |
"speed" => $settings["speed"]["size"], |
| 322 |
"pauseOnHover" => ("yes" == $settings["pauseonhover"]) ? true : false, |
| 323 |
"slidesPerView" => isset($settings["columns_mobile"]) ? (int)$settings["columns_mobile"] : 1, |
| 324 |
"slidesPerGroup" => isset($settings["slides_to_scroll_mobile"]) ? (int)$settings["slides_to_scroll_mobile"] : 1, |
| 325 |
"spaceBetween" => $settings["items_gap"]["size"], |
| 326 |
"centeredSlides" => ($settings["centered_slides"] === "yes") ? true : false, |
| 327 |
"grabCursor" => ($settings["grab_cursor"] === "yes") ? true : false, |
| 328 |
"effect" => $settings["skin"], |
| 329 |
"observer" => ($settings["observer"]) ? true : false, |
| 330 |
"observeParents" => ($settings["observer"]) ? true : false, |
| 331 |
// "direction" => $settings['direction'], |
| 332 |
"watchSlidesVisibility" => true, |
| 333 |
"watchSlidesProgress" => true, |
| 334 |
"breakpoints" => [ |
| 335 |
(int) $viewport_md => [ |
| 336 |
"slidesPerView" => isset($settings["columns_tablet"]) ? (int)$settings["columns_tablet"] : 2, |
| 337 |
"spaceBetween" => $settings["items_gap"]["size"], |
| 338 |
"slidesPerGroup" => isset($settings["slides_to_scroll_tablet"]) ? (int)$settings["slides_to_scroll_tablet"] : 1, |
| 339 |
], |
| 340 |
(int) $viewport_lg => [ |
| 341 |
"slidesPerView" => isset($settings["columns"]) ? (int)$settings["columns"] : 3, |
| 342 |
"spaceBetween" => $settings["items_gap"]["size"], |
| 343 |
"slidesPerGroup" => isset($settings["slides_to_scroll"]) ? (int)$settings["slides_to_scroll"] : 1, |
| 344 |
] |
| 345 |
], |
| 346 |
"navigation" => [ |
| 347 |
"nextEl" => "#" . $id . " .usk-navigation-next", |
| 348 |
"prevEl" => "#" . $id . " .usk-navigation-prev", |
| 349 |
], |
| 350 |
"pagination" => [ |
| 351 |
"el" => "#" . $id . " .swiper-pagination", |
| 352 |
"type" => $pagination_type, |
| 353 |
"clickable" => "true", |
| 354 |
'dynamicBullets' => ("yes" == $settings["dynamic_bullets"]) ? true : false, |
| 355 |
], |
| 356 |
"scrollbar" => [ |
| 357 |
"el" => "#" . $id . " .swiper-scrollbar", |
| 358 |
"hide" => "true", |
| 359 |
], |
| 360 |
'coverflowEffect' => [ |
| 361 |
'rotate' => ("yes" == $settings["coverflow_toggle"]) ? $settings["coverflow_rotate"]["size"] : 50, |
| 362 |
'stretch' => ("yes" == $settings["coverflow_toggle"]) ? $settings["coverflow_stretch"]["size"] : 0, |
| 363 |
'depth' => ("yes" == $settings["coverflow_toggle"]) ? $settings["coverflow_depth"]["size"] : 100, |
| 364 |
'modifier' => ("yes" == $settings["coverflow_toggle"]) ? $settings["coverflow_modifier"]["size"] : 1, |
| 365 |
'slideShadows' => true, |
| 366 |
], |
| 367 |
|
| 368 |
])) |
| 369 |
] |
| 370 |
] |
| 371 |
] |
| 372 |
); |
| 373 |
|
| 374 |
$swiper_class = Plugin::$instance->experiments->is_feature_active( 'e_swiper_latest' ) ? 'swiper' : 'swiper-container'; |
| 375 |
$this->add_render_attribute('swiper', 'class', 'swiper-carousel ' . $swiper_class); |
| 376 |
|
| 377 |
?> |
| 378 |
|
| 379 |
<div class="ultimate-store-kit"> |
| 380 |
<div <?php $this->print_render_attribute_string('usk-carousel-wrapper'); ?>> |
| 381 |
<div <?php $this->print_render_attribute_string('carousel'); ?>> |
| 382 |
<div <?php echo $this->get_render_attribute_string('swiper'); ?>> |
| 383 |
<div class="swiper-wrapper"> |
| 384 |
<?php |
| 385 |
} |
| 386 |
protected function usk_get_badge_label_percentage() { |
| 387 |
global $product; |
| 388 |
if ($product->is_on_sale()) { |
| 389 |
$percentage = ''; |
| 390 |
if ($product->get_type() == 'variable') { |
| 391 |
$available_variations = $product->get_variation_prices(); |
| 392 |
$max_percentage = 0; |
| 393 |
foreach ($available_variations['regular_price'] as $key => $regular_price) { |
| 394 |
$sale_price = $available_variations['sale_price'][$key]; |
| 395 |
if ($sale_price < $regular_price) { |
| 396 |
$percentage = round((($regular_price - $sale_price) / $regular_price) * 100); |
| 397 |
if ($percentage > $max_percentage) { |
| 398 |
$max_percentage = $percentage; |
| 399 |
} |
| 400 |
} |
| 401 |
} |
| 402 |
$percentage = $max_percentage; |
| 403 |
} elseif (($product->get_type() == 'simple' || $product->get_type() == 'external')) { |
| 404 |
$percentage = round((($product->get_regular_price() - $product->get_sale_price()) / $product->get_regular_price()) * 100); |
| 405 |
} |
| 406 |
if ($percentage) { |
| 407 |
printf('<div class="usk-badge-wrap usk-percantage-badge"><span class="usk-badge">%1$s%2$s</span></div>', $percentage, __('% off', 'ultimate-store-kit')); |
| 408 |
} |
| 409 |
} |
| 410 |
} |
| 411 |
protected function render_navigation() { |
| 412 |
$settings = $this->get_settings_for_display(); |
| 413 |
$hide_arrow_on_mobile = $settings['hide_arrow_on_mobile'] ? ' bdt-visible@m' : ''; |
| 414 |
|
| 415 |
if ('arrows' == $settings['navigation']) : ?> |
| 416 |
<div class="bdt-position-z-index bdt-position-<?php echo esc_attr($settings['arrows_position'] . $hide_arrow_on_mobile); ?>"> |
| 417 |
<div class="bdt-arrows-container bdt-slidenav-container"> |
| 418 |
<a href="" class="bdt-navigation-prev bdt-slidenav-previous bdt-icon bdt-slidenav"> |
| 419 |
<i class="ep-icon-arrow-left-<?php echo esc_attr($settings['nav_arrows_icon']); ?>" aria-hidden="true"></i> |
| 420 |
</a> |
| 421 |
<a href="" class="bdt-navigation-next bdt-slidenav-next bdt-icon bdt-slidenav"> |
| 422 |
<i class="ep-icon-arrow-right-<?php echo esc_attr($settings['nav_arrows_icon']); ?>" aria-hidden="true"></i> |
| 423 |
</a> |
| 424 |
</div> |
| 425 |
</div> |
| 426 |
<?php |
| 427 |
endif; |
| 428 |
} |
| 429 |
|
| 430 |
protected function render_pagination() { |
| 431 |
$settings = $this->get_settings_for_display(); |
| 432 |
|
| 433 |
if ('dots' == $settings['navigation'] or 'arrows-fraction' == $settings['navigation']) : ?> |
| 434 |
<div class="bdt-position-z-index bdt-position-<?php echo esc_attr($settings['dots_position']); ?>"> |
| 435 |
<div class="bdt-dots-container"> |
| 436 |
<div class="swiper-pagination"></div> |
| 437 |
</div> |
| 438 |
</div> |
| 439 |
|
| 440 |
<?php |
| 441 |
elseif ('progressbar' == $settings['navigation']) : ?> |
| 442 |
<div class="swiper-pagination bdt-position-z-index bdt-position-<?php echo esc_attr($settings['progress_position']); ?>"></div> |
| 443 |
<?php |
| 444 |
endif; |
| 445 |
} |
| 446 |
|
| 447 |
protected function render_both_navigation() { |
| 448 |
$settings = $this->get_settings_for_display(); |
| 449 |
$hide_arrow_on_mobile = $settings['hide_arrow_on_mobile'] ? 'bdt-visible@m' : ''; |
| 450 |
|
| 451 |
?> |
| 452 |
<div class="bdt-position-z-index bdt-position-<?php echo esc_attr($settings['both_position']); ?>"> |
| 453 |
<div class="bdt-arrows-dots-container bdt-slidenav-container "> |
| 454 |
|
| 455 |
<div class="bdt-flex bdt-flex-middle"> |
| 456 |
<div class="<?php |
| 457 |
echo esc_attr($hide_arrow_on_mobile); ?>"> |
| 458 |
<a href="" class="bdt-navigation-prev bdt-slidenav-previous bdt-icon bdt-slidenav"> |
| 459 |
<i class="ep-icon-arrow-left-<?php echo esc_attr($settings['nav_arrows_icon']); ?>" aria-hidden="true"></i> |
| 460 |
</a> |
| 461 |
</div> |
| 462 |
|
| 463 |
<?php |
| 464 |
if ('center' !== $settings['both_position']) : ?> |
| 465 |
<div class="swiper-pagination"></div> |
| 466 |
<?php |
| 467 |
endif; ?> |
| 468 |
|
| 469 |
<div class="<?php |
| 470 |
echo esc_attr($hide_arrow_on_mobile); ?>"> |
| 471 |
<a href="" class="bdt-navigation-next bdt-slidenav-next bdt-icon bdt-slidenav"> |
| 472 |
<i class="ep-icon-arrow-right-<?php echo esc_attr($settings['nav_arrows_icon']); ?>" aria-hidden="true"></i> |
| 473 |
</a> |
| 474 |
</div> |
| 475 |
|
| 476 |
</div> |
| 477 |
</div> |
| 478 |
</div> |
| 479 |
<?php |
| 480 |
} |
| 481 |
protected function render_arrows_fraction() { |
| 482 |
$settings = $this->get_settings_for_display(); |
| 483 |
$hide_arrow_on_mobile = $settings['hide_arrow_on_mobile'] ? 'bdt-visible@m' : ''; ?> |
| 484 |
<div class="bdt-position-z-index bdt-position-<?php echo esc_attr($settings['arrows_fraction_position']); ?>"> |
| 485 |
<div class="bdt-arrows-fraction-container bdt-slidenav-container "> |
| 486 |
|
| 487 |
<div class="bdt-flex bdt-flex-middle"> |
| 488 |
<div class="<?php |
| 489 |
echo esc_attr($hide_arrow_on_mobile); ?>"> |
| 490 |
<a href="" class="bdt-navigation-prev bdt-slidenav-previous bdt-icon bdt-slidenav"> |
| 491 |
<i class="ep-icon-arrow-left-<?php echo esc_attr($settings['nav_arrows_icon']); ?>" aria-hidden="true"></i> |
| 492 |
</a> |
| 493 |
</div> |
| 494 |
|
| 495 |
<?php |
| 496 |
if ('center' !== $settings['arrows_fraction_position']) : ?> |
| 497 |
<div class="swiper-pagination"></div> |
| 498 |
<?php |
| 499 |
endif; ?> |
| 500 |
|
| 501 |
<div class="<?php |
| 502 |
echo esc_attr($hide_arrow_on_mobile); ?>"> |
| 503 |
<a href="" class="bdt-navigation-next bdt-slidenav-next bdt-icon bdt-slidenav"> |
| 504 |
<i class="ep-icon-arrow-right-<?php echo esc_attr($settings['nav_arrows_icon']); ?>" aria-hidden="true"></i> |
| 505 |
</a> |
| 506 |
</div> |
| 507 |
|
| 508 |
</div> |
| 509 |
</div> |
| 510 |
</div> |
| 511 |
<?php |
| 512 |
} |
| 513 |
protected function render_footer() { |
| 514 |
$settings = $this->get_settings_for_display(); ?> |
| 515 |
</div> |
| 516 |
<?php |
| 517 |
if ('yes' === $settings['show_scrollbar']) : ?> |
| 518 |
<div class="swiper-scrollbar"></div> |
| 519 |
<?php |
| 520 |
endif; ?> |
| 521 |
</div> |
| 522 |
|
| 523 |
<?php |
| 524 |
if ('both' == $settings['navigation']) : ?> |
| 525 |
<?php $this->render_both_navigation(); ?> |
| 526 |
<?php |
| 527 |
if ('center' === $settings['both_position']) : ?> |
| 528 |
<div class="bdt-position-z-index bdt-position-bottom"> |
| 529 |
<div class="bdt-dots-container"> |
| 530 |
<div class="swiper-pagination"></div> |
| 531 |
</div> |
| 532 |
</div> |
| 533 |
<?php |
| 534 |
endif; ?> |
| 535 |
<?php |
| 536 |
elseif ('arrows-fraction' == $settings['navigation']) : ?> |
| 537 |
<?php $this->render_arrows_fraction(); ?> |
| 538 |
<?php |
| 539 |
if ('center' === $settings['arrows_fraction_position']) : ?> |
| 540 |
<div class="bdt-dots-container"> |
| 541 |
<div class="swiper-pagination"></div> |
| 542 |
</div> |
| 543 |
<?php |
| 544 |
endif; ?> |
| 545 |
<?php |
| 546 |
else : ?> |
| 547 |
<?php $this->render_pagination(); ?> |
| 548 |
<?php $this->render_navigation(); ?> |
| 549 |
<?php |
| 550 |
endif; ?> |
| 551 |
|
| 552 |
</div> |
| 553 |
</div> |
| 554 |
|
| 555 |
<?php |
| 556 |
} |
| 557 |
} |
| 558 |
|