HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: /var/www/html/TBbargain/wp-content/themes/Tbbargain/index.php
<?php /* Template Name: Home Page */
get_header();
?>
  <section class="banner">
        <div class="container custom-container">
            <div class="bannerSlider">
                <!-- slider starts -->
                <div>
                    <div class="row slider-inner">
                        <div class="col-lg-6 banner-middle">
                            <div class="txt">
                                <img src="<?php echo get_template_directory_uri(); ?>/img/amazon.png" alt="" class="logo">
                                <h2 class="title">Buy More, Save More! Deals You’ll Love!</h2>
                                <p class="para">Limited Time, Unlimited Savings!</p>
                                
                                <a href="<?php echo esc_url(home_url('/product-category/electronics/?all=all')); ?>" class="btn"><button class="button"> View Deals
                                        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24"
                                            viewBox="0 0 24 24">
                                            <g data-name="vuesax/linear/arrow-right">
                                                <g fill="none" stroke="#fff" stroke-linecap="round"
                                                    stroke-linejoin="round" stroke-width="1.5" data-name="Group 998">
                                                    <path d="M14.43 5.93 20.5 12l-6.07 6.07" />
                                                    <path d="M3.5 12h16.83" data-name="Vector" />
                                                </g>
                                            </g>
                                        </svg>
                                    </button></a>
                                 
                            </div>
                        </div>
                        <div class="col-lg-6 banner-right">
                            <figure class="banner-img">
                                <img src="<?php echo get_template_directory_uri(); ?>/img/banner-img.png" alt="" class="img">
                            </figure>
                        </div>
                    </div>
                </div><!--slider ends -->
                <!-- slider starts -->
                <div>
                    <div class="row slider-inner">
                        <div class="col-lg-6 banner-middle">
                            <div class="txt">
                                <img src="<?php echo get_template_directory_uri(); ?>/img/amazon.png" alt="" class="logo">
                                <h2 class="title">Buy More, Save More! Deals You’ll Love!</h2>
                                <p class="para">Limited Time, Unlimited Savings!</p>
                                <a href="<?php echo esc_url(home_url('/product-category/electronics/?all=all')); ?>" class="btn">
                                    <button class="button"> View Deals
                                        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24"
                                            viewBox="0 0 24 24">
                                            <g data-name="vuesax/linear/arrow-right">
                                                <g fill="none" stroke="#fff" stroke-linecap="round"
                                                    stroke-linejoin="round" stroke-width="1.5" data-name="Group 998">
                                                    <path d="M14.43 5.93 20.5 12l-6.07 6.07" />
                                                    <path d="M3.5 12h16.83" data-name="Vector" />
                                                </g>
                                            </g>
                                        </svg>
                                    </button>
                                </a>
                            </div>
                        </div>
                        <div class="col-lg-6 banner-right">
                            <figure class="banner-img">
                                <img src="<?php echo get_template_directory_uri(); ?>/img/banner-img.png" alt="" class="img">
                            </figure>
                        </div>
                    </div>
                </div><!--slider ends -->
            </div>

        </div>
    </section>

    <section class="logo-listing-wrap">

        <div class="logoListing">
            <div>
                <div class="logo-listing">
                    <img src="<?php echo get_template_directory_uri(); ?>/img/logo-ipsum-1.svg" alt="">
                </div>
            </div>
            <div>
                <div class="logo-listing">
                    <img src="<?php echo get_template_directory_uri(); ?>/img/logo-ipsum-2.svg" alt="">
                </div>
            </div>
            <div>
                <div class="logo-listing">
                    <img src="<?php echo get_template_directory_uri(); ?>/img/logo-ipsum-3.svg" alt="">
                </div>
            </div>
            <div>
                <div class="logo-listing">
                    <img src="<?php echo get_template_directory_uri(); ?>/img/logo-ipsum-4.svg" alt="">
                </div>
            </div>
            <div>
                <div class="logo-listing">
                    <img src="<?php echo get_template_directory_uri(); ?>/img/logo-ipsum-5.svg" alt="">
                </div>
            </div>
            <div>
                <div class="logo-listing">
                    <img src="<?php echo get_template_directory_uri(); ?>/img/logo-ipsum-6.svg" alt="">
                </div>
            </div>
            <div>
                <div class="logo-listing">
                    <img src="<?php echo get_template_directory_uri(); ?>/img/logo-ipsum-7.svg" alt="">
                </div>
            </div>
            <div>
                <div class="logo-listing">
                    <img src="<?php echo get_template_directory_uri(); ?>/img/logo-ipsum-8.svg" alt="">
                </div>
            </div>
            <div>
                <div class="logo-listing">
                    <img src="<?php echo get_template_directory_uri(); ?>/img/logo-ipsum-9.svg" alt="">
                </div>
            </div>
        </div>

    </section>


    <section class="featured-deal-wrap">
        <div class="container custom-container">
            <h2 class="title">Featured Deals</h2>

            <div class="featured-wrap">
            <?php 
                // Loop through product deals
                $args = array(
                    'post_type' => 'custom_product',
                    'posts_per_page' => -1
                );
                $query = new WP_Query($args);

                if ($query->have_posts()) : 
                    while ($query->have_posts()) : $query->the_post();
                        // Custom fields
                        $deal_badge = get_field('deal_badge');
                        $carousel_images = get_field('carousel_images');
                        $logo_image = get_field('logo_image');
                        $subtitle = get_field('title');
                        $description = get_field('description');
                        $crossprice = get_field('crossprice');
                        $discounted_price = get_field('discounted_price');
                        $discount_percent = get_field('discount_percent');
                        $deal_end_date = get_field('deal_end_date');
                        $expired = get_field('expired');
                        $expired_value = maybe_unserialize($expired);
                        $image_ids = get_post_meta(get_the_ID(), '_product_image_ids', true);
                        $image_ids = $image_ids ? explode(',', $image_ids) : [];
                        $discount_percent = 0;
                        if ($crossprice > $discounted_price && $crossprice > 0) {
                            $discount_percent = round((($crossprice - $discounted_price) / $crossprice) * 100);
                        }
                        $post_date = get_the_date('Y-m-d'); // The date the post was created
                        $post_date_timestamp = strtotime($post_date); // Convert to timestamp for calculations

                        // Get the last day of the current week (Sunday)
                        $last_day_of_week = strtotime('next Sunday'); // Get next Sunday (this will give you the last day of the current week)
                        
                        // Calculate the difference in days between the post date and the last day of the current week
                        $date_diff = floor(($last_day_of_week - $post_date_timestamp) / (60 * 60 * 24)); // Difference in days
                            ?>

                <div><!-- card starts -->
                    <div class="card-row-wrap card-col-wrap">
                        <a href="<?php echo get_permalink(); ?>" class="get-deal-btn">
                        <div class="img-carouel-wrap">
                        <?php if (is_array($expired_value) && isset($expired_value[0]) && $expired_value[0] === 'Expired') {
                                ?>
                            <div class="deal-badge hot">
                                <img src="<?php echo get_template_directory_uri(); ?>/img/deal-tag.svg" alt="" class="icon">
                                <div class="txt">Expired</div>                               
                            </div>
                            <?php  } else { 
                                if($date_diff<=7){
                                ?>
                                <div class="deal-badge new">
                                <img src="<?php echo get_template_directory_uri(); ?>/img/deal-tag.svg" alt="" class="icon">
                                <div class="txt">New Deal</div>
                            </div>
                                <?php  } } ?>
                            <?php if (!empty($image_ids)) : ?>
                            <div class="thumbImgSlider">
                                <?php foreach ($image_ids as $id) : ?>
                                    <div>
                                        <img src="<?php echo esc_url(wp_get_attachment_url($id)); ?>" alt="Product Image" style="max-width: 100%; height: auto;">
                                    </div>
                                <?php endforeach; ?>
                            </div>
                            <?php endif; ?>

                        </div>
                        </a>
                        <div class="content-wrap">
                        <?php if ($logo_image) : ?>
                            <img src="<?php echo esc_url($logo_image['url']); ?>" alt="" class="logo">
                        <?php endif; ?>
                           
                        <a href="<?php echo get_permalink(); ?>" class="sub-title-link"><h2 class="sub-title"><?php echo esc_html($subtitle); ?></h2></a>
                        <!-- <p class="sub-para"><?php echo esc_html($expired); ?></p> -->

                        <div class="price">
                            <span class="large">$<?php echo esc_html($discounted_price); ?></span>
                            <span class="cross">$<?php echo esc_html($crossprice); ?></span>
                        </div>
                        
                        <div class="offer">
                            <div class="off">
                                <img src="<?php echo get_template_directory_uri(); ?>/img/offer-white.svg" alt="">
                                <?php echo esc_html($discount_percent); ?>% Off
                            </div>
                            <div class="end"><?php echo esc_html($deal_end_date); ?></div>
                        </div>
                    </div>
                    </div><!-- card ends -->
                </div>
                <?php
                endwhile;
                wp_reset_postdata();
            else :
                echo '<p>No product deals found.</p>';
            endif;
            ?>
                

            </div>


        </div>
    </section>


    <?php 
        // Loop through product deals
        $args = array(
            'post_type' => 'custom_product',
            'posts_per_page' => -1,
            'meta_query' => array(
            array(
                'key'     => 'deal_end_date', // Meta key for deal end date
                'value'   => date('Y-m-d'),  // Today's date
                'compare' => '=',          // Compare to ensure deal_end_date is today or later
                'type'    => 'DATE'
            ),
        ),
        );
        $query = new WP_Query($args);

        if ($query->have_posts()) : 
            ?>
    <section class="all-deal-wrap deal-by-day-wrap">
        <div class="container custom-container">
            <div class="row deals-inner">
                <div class="col-lg-12 title-wrap">
                    <h2 class="title">Deals By Day</h2>
                    <div class="endtime">
                        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="ico">
                            <path
                                d="M256 0a256 256 0 1 1 0 512 256 256 0 1 1 0-512zm-24 120v136c0 8 4 15.5 10.7 20l96 64c11 7.4 25.9 4.4 33.3-6.7s4.4-25.9-6.7-33.3L280 243.2V120c0-13.3-10.7-24-24-24s-24 10.7-24 24z" />
                        </svg>
                        <div class="time" id="countdown-timer">00:00:00</div>
                    </div>
                </div>
               <?php
                    while ($query->have_posts()) : $query->the_post();
                        // Custom fields
                        $deal_badge = get_field('deal_badge');
                        $carousel_images = get_field('carousel_images');
                        $logo_image = get_field('logo_image');
                        $subtitle = get_field('title');
                        $description = get_field('description');
                        $crossprice = get_field('crossprice');
                        $discounted_price = get_field('discounted_price');
                        $discount_percent = get_field('discount_percent');
                        $deal_end_date = get_field('deal_end_date');
                        $expired = get_field('expired');
                        $expired_value = maybe_unserialize($expired);
                        $image_ids = get_post_meta(get_the_ID(), '_product_image_ids', true);
                        $image_ids = $image_ids ? explode(',', $image_ids) : [];
                        $discount_percent = 0;
                        $discount_percent = 0;
                        if ($crossprice > $discounted_price && $crossprice > 0) {
                            $discount_percent = round((($crossprice - $discounted_price) / $crossprice) * 100);
                        }
                                        ?>
                <div class="col-lg-3"><!-- card starts -->
                <div class="card-row-wrap">
                    <div class="img-carouel-wrap">
                    <?php if (is_array($expired_value) && isset($expired_value[0]) && $expired_value[0] === 'Expired') {
                                ?>
                            <div class="deal-badge hot">
                                <img src="<?php echo get_template_directory_uri(); ?>/img/deal-tag.svg" alt="" class="icon">
                                <div class="txt">Expired</div>                               
                            </div>
                            <?php  }?>
                        
                       <?php if (!empty($image_ids)) : ?>
                        <div class="thumbImgSlider">
                            <?php foreach ($image_ids as $id) : ?>
                                <div>
                                    <img src="<?php echo esc_url(wp_get_attachment_url($id)); ?>" alt="Product Image" style="max-width: 100%; height: auto;">
                                </div>
                            <?php endforeach; ?>
                        </div>
                    <?php endif; ?>
                    </div>
                    
                    <div class="content-wrap">
                        <?php if ($logo_image) : ?>
                            <img src="<?php echo esc_url($logo_image['url']); ?>" alt="" class="logo">
                        <?php endif; ?>

                        <a href="<?php echo get_permalink(); ?>" class="sub-title-link"><h2 class="sub-title"><?php echo esc_html($subtitle); ?></h2></a>
                        <!-- <p class="sub-para"><?php echo esc_html($description); ?></p> -->

                        <div class="price">
                            <span class="large">$<?php echo esc_html($discounted_price); ?></span>
                            <span class="cross">$<?php echo esc_html($crossprice); ?></span>
                        </div>
                        
                        <div class="offer">
                            <div class="off">
                                <img src="<?php echo get_template_directory_uri(); ?>/img/offer-white.svg" alt="">
                                <?php echo esc_html($discount_percent); ?>% Off
                            </div>
                            <div class="end"><?php echo esc_html($deal_end_date); ?></div>
                        </div>
                    </div>
                </div><!-- card ends -->
            </div>
            <?php
                endwhile;
                wp_reset_postdata();
     
            ?>
                
            </div>
        </div>
    </section>
<?php  endif;
            ?>
    <section class="adv-banner">
        <div class="container custom-container">
            <div class="col-md-6">
                <div class="txt">
                    <h2 class="title">Big Deal On Flipkart 60% Off</h2>
                    <div class="offer">
                        <img src="<?php echo get_template_directory_uri(); ?>/img/deal-tag.svg" alt="" class="img"> <span class="para">Limited Deal offers
                            applyed</span>
                    </div>
                    <a href="<?php echo esc_url(home_url('/product-category/electronics/?all=all')); ?>" class="btn">
                        <button class="button">
                            View Deals <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24"
                                viewBox="0 0 24 24">
                                <g data-name="vuesax/linear/arrow-right">
                                    <g fill="none" stroke="#fff" stroke-linecap="round" stroke-linejoin="round"
                                        stroke-width="1.5" data-name="Group 998">
                                        <path d="M14.43 5.93 20.5 12l-6.07 6.07" />
                                        <path d="M3.5 12h16.83" data-name="Vector" />
                                    </g>
                                </g>
                            </svg>
                        </button>
                    </a>
                </div>
            </div>
            <img src="<?php echo get_template_directory_uri(); ?>/img/adv-banner.png" alt="" class="main-img">
        </div>
    </section>


    <section class="all-deal-wrap">
        <div class="container custom-container">
            <div class="row deals-inner">
                <div class="col-lg-12">
                    <h2 class="title">Explore All Deals</h2>
                </div>
                <?php 
                // Loop through product deals
                $args = array(
                    'post_type' => 'custom_product',
                    'posts_per_page' => 8
                );
                $query = new WP_Query($args);

                if ($query->have_posts()) : 
                    while ($query->have_posts()) : $query->the_post();
                        // Custom fields
                        $deal_badge = get_field('deal_badge');
                        $carousel_images = get_field('carousel_images');
                        $logo_image = get_field('logo_image');
                        $subtitle = get_field('title');
                        $description = get_field('description');
                        $crossprice = get_field('crossprice');
                        $discounted_price = get_field('discounted_price');
                        $discount_percent = get_field('discount_percent');
                        $deal_end_date = get_field('deal_end_date');
                        $expired = get_field('expired');
                        $expired_value = maybe_unserialize($expired);
                        $image_ids = get_post_meta(get_the_ID(), '_product_image_ids', true);
                        $image_ids = $image_ids ? explode(',', $image_ids) : [];
                        $discount_percent = 0;
                        $discount_percent = 0;
                        if ($crossprice > $discounted_price && $crossprice > 0) {
                            $discount_percent = round((($crossprice - $discounted_price) / $crossprice) * 100);
                        }
                        $post_date = get_the_date('Y-m-d'); // The date the post was created
                        $post_date_timestamp = strtotime($post_date); // Convert to timestamp for calculations

                        // Get the last day of the current week (Sunday)
                        $last_day_of_week = strtotime('next Sunday'); // Get next Sunday (this will give you the last day of the current week)
                        
                        // Calculate the difference in days between the post date and the last day of the current week
                        $date_diff = floor(($last_day_of_week - $post_date_timestamp) / (60 * 60 * 24)); // Difference in days
                                        ?>
                <div class="col-lg-3"><!-- card starts -->
                <div class="card-row-wrap">
                    <div class="img-carouel-wrap">
                    <?php if (is_array($expired_value) && isset($expired_value[0]) && $expired_value[0] === 'Expired') {
                                ?>
                            <div class="deal-badge hot">
                                <img src="<?php echo get_template_directory_uri(); ?>/img/deal-tag.svg" alt="" class="icon">
                                <div class="txt">Expired</div>                               
                            </div>
                            <?php  }?>
                        
                       <?php if (!empty($image_ids)) : ?>
                        <div class="thumbImgSlider">
                            <?php foreach ($image_ids as $id) : ?>
                                <div>
                                    <img src="<?php echo esc_url(wp_get_attachment_url($id)); ?>" alt="Product Image" style="max-width: 100%; height: auto;">
                                </div>
                            <?php endforeach; ?>
                        </div>
                    <?php endif; ?>
                    </div>
                    
                    <div class="content-wrap">
                        <?php if ($logo_image) : ?>
                            <img src="<?php echo esc_url($logo_image['url']); ?>" alt="" class="logo">
                        <?php endif; ?>

                        <a href="<?php echo get_permalink(); ?>" class="sub-title-link"><h2 class="sub-title"><?php echo esc_html($subtitle); ?></h2></a>
                        <!-- <p class="sub-para"><?php echo esc_html($description); ?></p> -->

                        <div class="price">
                            <span class="large">$<?php echo esc_html($discounted_price); ?></span>
                            <span class="cross">$<?php echo esc_html($crossprice); ?></span>
                        </div>
                        
                        <div class="offer">
                            <div class="off">
                                <img src="<?php echo get_template_directory_uri(); ?>/img/offer-white.svg" alt="">
                                <?php echo esc_html($discount_percent); ?>% Off
                            </div>
                            <div class="end"><?php echo esc_html($deal_end_date); ?></div>
                        </div>
                    </div>
                </div><!-- card ends -->
            </div>
            <?php
                endwhile;
                wp_reset_postdata();
            else :
                echo '<p>No product deals found.</p>';
            endif;
            ?>
            </div>
        </div>
        <div class="btn-wrap">
           <a href="<?php echo esc_url(home_url('/product-category/electronics/?all=all')); ?>"> <button class="button">View All <svg xmlns="http://www.w3.org/2000/svg" width="8.153" height="14.806"
                    viewBox="0 0 8.153 14.806">
                    <path fill="none" stroke="#223158" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"
                        d="m1.061 1.061 6.342 6.342-6.342 6.342" data-name="Path 69" />
                </svg></button></a>
        </div>
    </section>



    <section class="signup-wrap">
        <div class="container custom-container">
            <div class="bg-wrap align-items-cente d-flex">
                <div class="row align-items-center signup-inner">
                    <div class="col-lg-6">
                        <div class="content">
                            <h2 class="title">
                                Sign Up For Exclusive Offers And Updates!
                            </h2>
                            <p class="para">Stay ahead of the curve with our exclusive newsletter!</p>
                        </div>
                    </div>
                    <div class="col-lg-6">
                        <div class="email-wrap">
                        <form class="footer-form" id="subscribe-form" >
                            <input type="email" name="email_id" class="txt" placeholder="Enter your email" required autocomplete="off">
                            <button class="button" id="subscribe-button">
                                Subscribe <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24"
                                    data-name="vuesax/linear/arrow-right" viewBox="0 0 24 24">
                                    <g fill="none" stroke="#223158" stroke-linecap="round" stroke-linejoin="round"
                                        stroke-width="1.5" data-name="Group 998">
                                        <path d="M14.43 5.93 20.5 12l-6.07 6.07" />
                                        <path d="M3.5 12h16.83" data-name="Vector" />
                                    </g>
                                </svg>
                            </button>
                            
                            </form>
                        </div>
                        <div id="response-message" style="margin-top: 10px; display: none;"></div>
                    </div>
                </div>
            </div>
        </div>
    </section>



<?php get_footer(); ?>