/** * @snippet Remove Zoom, Gallery @ Single Product Page * @how-to Get CustomizeWoo.com FREE * @author Rodolfo Melogli * @testedwith WooCommerce 5 * @community https://businessbloomer.com/club/ */ //add_action( 'wp', 'bbloomer_remove_zoom_lightbox_theme_support', 99 ); function bbloomer_remove_zoom_lightbox_theme_support() { //remove_theme_support( 'wc-product-gallery-zoom' ); //remove_theme_support( 'wc-product-gallery-lightbox' ); remove_theme_support( 'wc-product-gallery-slider' ); } ////Remove actions for single product remove_action('woocommerce_before_main_content','woocommerce_breadcrumb',20); remove_action('woocommerce_single_product_summary','woocommerce_template_single_meta',40); remove_action('woocommerce_single_product_summary','woocommerce_template_single_excerpt',20); remove_action('woocommerce_after_single_product_summary','woocommerce_output_product_data_tabs',10); remove_action('woocommerce_after_single_product_summary','woocommerce_upsell_display',15); remove_action('woocommerce_after_single_product_summary','woocommerce_output_related_products',20); //Add actions for single product add_action('woocommerce_single_product_summary','woocommerce_template_single_excerpt',35); function addTHCForSingleProduct(){ $thc = get_field('thc'); if(!empty($thc)) echo '<h4 class="single-product-thc">'.$thc.'</h4>'; } add_action('woocommerce_single_product_summary','addTHCForSingleProduct',6); function customTabForSingleProduct(){ ?> <div class="rst-accordion-description"> <?php if($ingredient = get_field('ingredient_field_name')):?> <div class="rst-item-accordion-description"> <h3 class="rst-heading-item-accordion-description rst-heading-item-toggle"> Ingredients <span> <img src="https://sweedies.co/wp-content/uploads/2024/05/arrows-down.png" /> </span> </h3> <div class="rst-content-item-accordion-description"> <?php echo $ingredient; ?> </div> </div> <?php endif;?> <?php $lab_test_report = get_field('lab_test_report');if(!empty($lab_test_report)):?> <div class="rst-item-accordion-description"> <a class="rst-heading-item-accordion-description" href="<?php echo $lab_test_report['url']; ?>" download> Lab test report <span> <img src="https://sweedies.co/wp-content/uploads/2024/05/PDF-Print-Icon.png" /> </span> </a> </div> <?php endif;?> </div> <script> (function($){ $('.rst-heading-item-toggle').click(function(){ if($(this).hasClass('active')){ $(this).parent().find('.rst-content-item-accordion-description').slideUp(); $(this).removeClass('active'); }else{ $('.rst-content-item-accordion-description').slideUp(); $(this).parent().find('.rst-content-item-accordion-description').slideDown(); $('.rst-heading-item-toggle').removeClass('active'); $(this).addClass('active'); } return false; }); })(jQuery) </script> <?php } add_action('woocommerce_single_product_summary','customTabForSingleProduct',45); function customBestSellerForShop(){ ?> <?php $args = [ 'post_type' => 'product', 'posts_per_page' => 15, 'meta_key' => 'total_sales', 'orderby' => 'meta_value_num', 'order' => 'DESC', ]; $the_query = new WP_Query($args); if($the_query->have_posts()): ?> <div class="customBestSellerForSingleProduct" style="clear: both;"> <div class="customBestSellerForSingleProduct-head"> <h2 class="nt-heading"> Best Sellers </h2> </div> <div class="customBestSellerForSingleProduct-list"> <div class="slider-product custom-slider-product-bestSellers"> <div class="swiper-wrapper"> <?php while ($the_query->have_posts()): $the_query->the_post(); $product = wc_get_product(get_the_ID()); $categories = wp_get_post_terms(get_the_ID(), 'product_cat'); $category_name = !empty($categories) ? $categories[0]->name : ''; $rating_count = $product->get_rating_count(); $average = $product->get_average_rating(); $regular_price = $product->get_regular_price(); $sale_price = $product->get_sale_price(); ?> <div class="swiper-slide"> <div class="slider-product-item"> <a class="product-link" href="<?php the_permalink(); ?>"> <div class="slider-product-image"> <?php echo woocommerce_get_product_thumbnail('shop_catalog'); ?> <div class="add-to-cart-btn"> <?php //echo $this->get_add_to_cart_button(get_the_ID()); ?> </div> </div> </a> <div class="slider-product-details"> <div class="product-category"><?php echo esc_html($category_name); ?></div> <a href="<?php the_permalink(); ?>"> <h2 class="slider-product-title"> <?php the_title(); ?> </h2> </a> <div class="slider-product-description"><?php echo wp_trim_words(get_the_excerpt(), 15); ?></div> <div class="product-rating"> <?php $rating = $average; $full_stars = floor($rating); $half_star = ($rating - $full_stars >= 0.5) ? 1 : 0; $empty_stars = 5 - $full_stars - $half_star; for ($i = 0; $i < $full_stars; $i++) { echo '<i class="fa-solid fa-star"></i>'; } if ($half_star) { echo '<i class="fa-solid fa-star-half-alt"></i>'; } for ($i = 0; $i < $empty_stars; $i++) { echo '<i class="fa-regular fa-star"></i>'; } ?> <span class="rating-count">(<?php echo $rating_count; ?>)</span> </div> <div class="slider-product-prices"> <?php if ($sale_price): ?> <span class="slider-product-new-price"><?php echo wc_price($sale_price); ?></span> <span class="slider-product-old-price"><?php echo wc_price($regular_price); ?></span> <?php else: ?> <span class="slider-product-new-price"><?php echo wc_price($regular_price); ?></span> <?php endif; ?> </div> </div> </div> </div> <?php endwhile; ?> </div> <div class="swiper-pagination"></div> </div> <div class="swiper-button-prev"></div> <div class="swiper-button-next"></div> </div> </div> <script> jQuery(document).ready(function ($) { var swiper_bestSellers = new Swiper(".custom-slider-product-bestSellers", { slidesPerView: 3, slidesPerGroup: 1, centeredSlides: true, loop: true, autoplay: { delay: 5000, }, spaceBetween: 24, // pagination: { // el: ".swiper-pagination", // clickable: true, // }, navigation: { nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev', }, breakpoints: { 1025: { slidesPerView: 3, centeredSlides: true, }, 768: { slidesPerView: 2, centeredSlides: true, }, 320: { slidesPerView: 1.5, centeredSlides: true, }, } }); }); jQuery(document).ready(function($) { $('.slider-product .slider-product-item ').matchHeight(); }); </script> <?php endif; wp_reset_postdata(); } add_action('woocommerce_after_single_product','customBestSellerForSingleProduct',25); function customReviewForSingleProduct(){ ?> <div class="customReviewForSingleProduct"> <div class="customReviewForSingleProduct-head"> <h2 class="nt-heading"> Customer reviews </h2> </div> <div class="customReviewForSingleProduct-content"> <?php echo do_shortcode('[Woo_stamped_io type="widget"]');?> </div> </div> <?php } add_action('woocommerce_after_single_product','customBestSellerForShop',30);
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter