PageRenderTime 52ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/essential-addons-for-elementor-lite/includes/Template/Woo-Product-Gallery/default.php

https://gitlab.com/campus-academy/krowkaramel
PHP | 220 lines | 196 code | 17 blank | 7 comment | 51 complexity | 5fd53e7e42e81709e0913cd4922a14d1 MD5 | raw file
  1. <?php
  2. /**
  3. * Template Name: Default
  4. */
  5. use \Essential_Addons_Elementor\Classes\Helper;
  6. use Essential_Addons_Elementor\Elements\Woo_Product_Gallery;
  7. use \Elementor\Group_Control_Image_Size;
  8. if ( ! defined( 'ABSPATH' ) ) {
  9. exit;
  10. } // Exit if accessed directly
  11. $product = wc_get_product( get_the_ID() );
  12. if ( ! $product ) {
  13. error_log( '$product not found in ' . __FILE__ );
  14. return;
  15. }
  16. if ( has_post_thumbnail() ) {
  17. $settings[ 'eael_image_size_customize' ] = [
  18. 'id' => get_post_thumbnail_id(),
  19. ];
  20. $settings['eael_image_size_customize_size'] = $settings['eael_product_gallery_image_size_size'];
  21. $thumbnail_html = Group_Control_Image_Size::get_attachment_image_html( $settings,'eael_image_size_customize' );
  22. }
  23. $title_tag = isset( $settings['eael_product_gallery_title_html_tag'] ) ? Helper::eael_validate_html_tag($settings['eael_product_gallery_title_html_tag']) : 'h2';
  24. // Improvement
  25. $gallery_style_preset = isset($settings['eael_product_gallery_style_preset']) ? $settings['eael_product_gallery_style_preset'] : '';
  26. $sale_badge_align = isset( $settings['eael_product_sale_badge_alignment'] ) ? $settings['eael_product_sale_badge_alignment'] : '';
  27. $sale_badge_preset = isset($settings['eael_product_sale_badge_preset']) ? $settings['eael_product_sale_badge_preset'] : '';
  28. // should print vars
  29. $sale_text = !empty($settings['eael_product_gallery_sale_text']) ? $settings['eael_product_gallery_sale_text'] : 'Sale!';
  30. $stockout_text = !empty($settings['eael_product_gallery_stockout_text']) ? $settings['eael_product_gallery_stockout_text'] : 'Stock <br/> Out';
  31. $should_print_rating = isset( $settings['eael_product_gallery_rating'] ) && 'yes' === $settings['eael_product_gallery_rating'];
  32. $should_print_quick_view = isset( $settings['eael_product_gallery_quick_view'] ) && 'yes' === $settings['eael_product_gallery_quick_view'];
  33. $should_print_addtocart = isset( $settings['eael_product_gallery_addtocart_show'] ) && 'yes' === $settings['eael_product_gallery_addtocart_show'];
  34. $should_print_link = isset( $settings['eael_product_gallery_link_show'] ) && 'yes' === $settings['eael_product_gallery_link_show'];
  35. $should_print_image_clickable = isset( $settings['eael_product_gallery_image_clickable'] ) && 'yes' === $settings['eael_product_gallery_image_clickable'];
  36. $should_print_price = isset( $settings['eael_product_gallery_price'] ) && 'yes' === $settings['eael_product_gallery_price'];
  37. $widget_id = isset($settings['eael_widget_id']) ? $settings['eael_widget_id'] : null;
  38. $quick_view_setting = [
  39. 'widget_id' => $widget_id,
  40. 'product_id' => $product->get_id(),
  41. 'page_id' => $settings['eael_page_id'],
  42. ];
  43. //if ( true === wc_get_loop_product_visibility( $product->get_id() ) || $product->is_visible() ) {
  44. if ( $gallery_style_preset == 'eael-product-preset-4' ) { ?>
  45. <li class="product">
  46. <div class="eael-product-wrap">
  47. <?php
  48. echo ( ! $product->managing_stock() && ! $product->is_in_stock() ? '<span class="eael-onsale outofstock '.$sale_badge_preset.' '.$sale_badge_align.'">'. $stockout_text .'</span>' : ($product->is_on_sale() ? '<span class="eael-onsale '.$sale_badge_preset.' '.$sale_badge_align.'">' . $sale_text . '</span>' : '') );
  49. if( $should_print_image_clickable ) {
  50. echo '<a href="' . $product->get_permalink() . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
  51. }?>
  52. <?php echo wp_kses_post( $product->get_image( 'woocommerce_thumbnail', ['loading' => 'eager'] ) );
  53. if ( $should_print_image_clickable ) {
  54. echo '</a>';
  55. }
  56. printf('<%1$s class="woocommerce-loop-product__title">%2$s</%1$s>', $title_tag, $product->get_title());
  57. if ( $should_print_rating ) {
  58. echo wp_kses_post( wc_get_rating_html( $product->get_average_rating(), $product->get_rating_count() ) );
  59. }
  60. if ( $should_print_price ) {
  61. echo '<div class="eael-product-price">'.$product->get_price_html().'</div>';
  62. }
  63. ?>
  64. <?php
  65. if ( $should_print_addtocart ) {
  66. woocommerce_template_loop_add_to_cart();
  67. } ?>
  68. </div>
  69. </li>
  70. <?php
  71. } else if (($gallery_style_preset == 'eael-product-preset-3') || ($gallery_style_preset == 'eael-product-preset-2')) {
  72. ?>
  73. <li <?php post_class( 'product' ); ?>>
  74. <div class="eael-product-wrap">
  75. <div class="product-image-wrap">
  76. <div class="image-wrap">
  77. <?php if( $should_print_image_clickable ) {
  78. echo '<a href="' . $product->get_permalink() . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
  79. }?>
  80. <?php
  81. echo ( ! $product->managing_stock() && ! $product->is_in_stock() ? '<span class="eael-onsale outofstock '.$sale_badge_preset.' '.$sale_badge_align.'">'. $stockout_text .'</span>' : ($product->is_on_sale() ? '<span class="eael-onsale '.$sale_badge_preset.' '.$sale_badge_align.'">' . $sale_text . '</span>' : '') );
  82. echo $product->get_image($settings['eael_product_gallery_image_size_size'], ['loading' => 'eager']);
  83. ?>
  84. <?php if( $should_print_image_clickable ) {
  85. echo '</a>';
  86. }?>
  87. </div>
  88. <div class="image-hover-wrap">
  89. <?php if ($gallery_style_preset == 'eael-product-preset-2') { ?>
  90. <ul class="icons-wrap block-box-style">
  91. <?php if( $should_print_addtocart ){?>
  92. <li class="add-to-cart"><?php woocommerce_template_loop_add_to_cart(); ?></li>
  93. <?php } ?>
  94. <?php if( $should_print_quick_view ){?>
  95. <li class="eael-product-quick-view">
  96. <a id="eael_quick_view_<?php echo uniqid(); ?>" data-quickview-setting="<?php echo htmlspecialchars(json_encode($quick_view_setting),ENT_QUOTES); ?>"
  97. class="eael-product-gallery-open-popup open-popup-link">
  98. <i class="fas fa-eye"></i>
  99. </a>
  100. </li>
  101. <?php } ?>
  102. <?php if( $should_print_link ){?>
  103. <li class="view-details"><?php echo '<a href="' . $product->get_permalink
  104. () . '"><i class="fas fa-link"></i></a>'; ?></li>
  105. <?php } ?>
  106. </ul>
  107. <?php } else { ?>
  108. <ul class="icons-wrap box-style">
  109. <?php if( $should_print_addtocart ){?>
  110. <li class="add-to-cart"><?php woocommerce_template_loop_add_to_cart(); ?></li>
  111. <?php } ?>
  112. <?php if( $should_print_quick_view ){?>
  113. <li class="eael-product-quick-view">
  114. <a id="eael_quick_view_<?php echo uniqid(); ?>" data-quickview-setting="<?php echo htmlspecialchars(json_encode($quick_view_setting),ENT_QUOTES); ?>"
  115. class="eael-product-gallery-open-popup open-popup-link">
  116. <i class="fas fa-eye"></i>
  117. </a>
  118. </li>
  119. <?php } ?>
  120. <?php if( $should_print_link ){?>
  121. <li class="view-details" title="Details"><?php echo '<a href="' . $product->get_permalink() . '"><i class="fas fa-link"></i></a>'; ?></li>
  122. <?php } ?>
  123. </ul>
  124. <?php }
  125. ?>
  126. </div>
  127. </div>
  128. <div class="product-details-wrap">
  129. <?php
  130. if(($gallery_style_preset == 'eael-product-preset-2') && $should_print_price ){
  131. echo '<div class="eael-product-price">'.$product->get_price_html().'</div>';
  132. }
  133. if ($should_print_rating) {
  134. echo wc_get_rating_html
  135. ($product->get_average_rating(), $product->get_rating_count());
  136. }
  137. ?>
  138. <div class="eael-product-title">
  139. <?php printf('<%1$s>%2$s</%1$s>', $title_tag, $product->get_title()); ?>
  140. </div>
  141. <?php if(($gallery_style_preset != 'eael-product-preset-2') && $should_print_price ){
  142. echo '<div class="eael-product-price">'.$product->get_price_html().'</div>';
  143. }?>
  144. </div>
  145. </div>
  146. </li>
  147. <?php
  148. } else if ($gallery_style_preset == 'eael-product-preset-1') {
  149. ?>
  150. <li <?php post_class( 'product' ); ?>>
  151. <div class="eael-product-wrap">
  152. <div class="product-image-wrap">
  153. <div class="image-wrap">
  154. <?php if( $should_print_image_clickable ) {
  155. echo '<a href="' . $product->get_permalink() . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
  156. }?>
  157. <?php
  158. echo ( ! $product->managing_stock() && ! $product->is_in_stock() ? '<span class="eael-onsale outofstock '.$sale_badge_preset.' '.$sale_badge_align.'">'. $stockout_text .'</span>' : ($product->is_on_sale() ? '<span class="eael-onsale '.$sale_badge_preset.' '.$sale_badge_align.'">' . $sale_text . '</span>' : '') );
  159. echo $product->get_image($settings['eael_product_gallery_image_size_size'], ['loading' => 'eager']);
  160. ?>
  161. <?php if( $should_print_image_clickable ) {
  162. echo '</a>';
  163. }?>
  164. </div>
  165. <div class="image-hover-wrap">
  166. <ul class="icons-wrap over-box-style">
  167. <?php if( $should_print_addtocart ){?>
  168. <li class="add-to-cart"><?php woocommerce_template_loop_add_to_cart(); ?></li>
  169. <?php } ?>
  170. <?php if( $should_print_quick_view ){?>
  171. <li class="eael-product-quick-view">
  172. <a id="eael_quick_view_<?php echo uniqid(); ?>" data-quickview-setting="<?php echo htmlspecialchars(json_encode($quick_view_setting),ENT_QUOTES); ?>"
  173. class="eael-product-gallery-open-popup open-popup-link">
  174. <i class="fas fa-eye"></i>
  175. </a>
  176. </li>
  177. <?php } ?>
  178. <?php if( $should_print_link ){?>
  179. <li class="view-details"><?php echo '<a href="' . $product->get_permalink
  180. () . '"><i class="fas fa-link"></i></a>'; ?></li>
  181. <?php } ?>
  182. </ul>
  183. </div>
  184. </div>
  185. <div class="product-details-wrap">
  186. <?php
  187. if ( $should_print_price ) {
  188. echo '<div class="eael-product-price">'.$product->get_price_html().'</div>';
  189. }
  190. ?>
  191. <div class="eael-product-title">
  192. <?php
  193. echo '<a href="' . $product->get_permalink() . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
  194. printf('<%1$s>%2$s</%1$s>', $title_tag, $product->get_title());
  195. echo '</a>';
  196. ?>
  197. </div>
  198. </div>
  199. </div>
  200. </li>
  201. <?php
  202. }
  203. //}