plugins – WordPress WooCommerce Custom Slider

Question

                <h2 class="slide-head blue-head">Lorem Ipsum Dolor Sit Amet, Consetetur Dolor</h2>
                <p class="slide-content">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy 
                eirmod tempor invidunt ut labore et dolore magna aliquyam erat, 
                sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum.</p>

        </div>
        <hr class="hr-line">
    </div>
    
    <div class="row custom-carosole-row">
        
        <div class="col-12">


            <div class="carousel-wrap">
              <h2 class="slide-head blue-head">Featured</h2>
              <div class="owl-carousel latest-work-carousel">
                <!--<div class="item"><img src="http://placehold.it/150x150"></div>-->
              
            
                <?php  
                    $args = array(
                        'post_type'      => 'product',
                        'posts_per_page' => 5

                    );

                    $loop = new WP_Query( $args );

                    while ( $loop->have_posts() ) : $loop->the_post();
                        global $product;
                        //$product = wc_get_product();
                        //setup_postdata($post);
                        $product_price = $product->get_price();
                        $sale_price = $product->get_sale_price();
                        $regular_price = $product->get_regular_price();

                        echo '<div class="item">
                              <a href="https://wordpress.stackexchange.com/questions/395987/.get_permalink().">
                                  <div class="inner-prod-deti">
                                  <a class="pro-btn" href="https://wordpress.stackexchange.com/questions/395987/.get_permalink().">View</a>
                                  <h3 class="pro-title">'.get_the_title().'</h3>
                                  <p class="pro-price"> <span class="reg-price">$'.$regular_price.'</span> <span class="pro-sale-price"> $'.$sale_price.'</span></p>
                                  </div>
                                  <div class="pro-img">'.woocommerce_get_product_thumbnail().'</div>
                              </a>
                              </div>';
                    endwhile;
                
                    wp_reset_query();
                ?>
                
                
                
                </div>
                </div>
                
                
        </div>


        <script>
            var owl = jQuery('.owl-carousel.latest-work-carousel').owlCarousel({
              loop: false,
              margin: 10,
              items: 1,
              nav: true,
              autoWidth:false,
              rewind: true,
              navText: [
                    '<i class="fa fa-angle-left" aria-hidden="true"></i><span>←</span>',
                    '<i class="fa fa-angle-right" aria-hidden="true"></i><span>→</span>'
                ],
              autoplay: true,
              autoplayHoverPause: true,
              responsive: {
                0: {
                  items: 1
                },
                600: {
                  items: 3
                },
                1000: {
                  items: 4
                }
              }
            })
            
        checkClasses();
        owl.on('translated.owl.carousel', function(event) {
            checkClasses();
        })
        
            function checkClasses(){
                var total = jQuery('.latest-work-carousel .owl-stage .owl-item.active').length;
        
                jQuery('.latest-work-carousel .owl-stage .owl-item').removeClass('firstActiveItem');
        
                jQuery('.latest-work-carousel .owl-stage .owl-item.active').each(function(index){
                    if (index === 0) {
                        // this is the first one
                        jQuery(this).addClass('firstActiveItem');
                    }
                });
            }
        </script>
    </div>
</div>

0
Sharjeel Khan 2 months 2021-09-22T07:18:34-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse