File: /var/www/html/TBbargain/wp-content/themes/Tbbargain/footer.php
<section class="footer">
<div class="container custom-container header-wrap">
<div class="row">
<div class="col-lg-5">
<div class="content-wrap">
<img src="<?php echo get_template_directory_uri(); ?>/img/ftr-logo.svg" alt="" class="logo">
<p class="para">Unbeatable offers are here! Grab exclusive discounts on our premium services and
products—only for a limited time.</p>
<ul class="contactcard">
<li class="tel">
<a href="tel:+9100000000000">+91 0000 0000 00</a>
</li>
<li class="mail">
<a href="mailto:infoanaffiliate.deal@gmail.com">infoanaffiliate.deal@gmail.com</a>
</li>
</ul>
</div>
</div>
<div class="col-lg-7">
<div class="row footer-inner">
<div class="col-4 ftr-blks">
<ul class="list-menu">
<?php
// Fetch categories
$parent_category = get_term_by('slug', 'deal-category', 'product_category');
$categories = get_terms(array(
'taxonomy' => 'product_category', // Custom taxonomy name
'hide_empty' => false, // Hide categories with no posts
'parent' => $parent_category->term_id,
));
// Check if there are categories and not an error
if (!empty($categories) && !is_wp_error($categories)) {
$count = 0; // Counter for categories
$first_column = true; // To handle the first and second column
foreach ($categories as $category) {
// Skip the category you don't want to show
if ($category->slug !== 'example-category') {
// Generate the category link
$cat_link = get_term_link($category);
// Check if the current page is the category page
$is_active = (is_tax('product_category', $category->term_id)) ? 'active' : '';
// Begin a new column after 4 categories
if ($count == 4) {
echo '</ul></div><div class="col-md-4 ftr-blks"><ul class="list-menu">';
$count = 0; // Reset count for the next set of categories
}
?>
<li class="nav-item <?php echo esc_attr($is_active); ?>">
<a class="nav-link" href="<?php echo esc_url($cat_link); ?>">
<?php echo esc_html($category->name); ?>
</a>
</li>
<?php
$count++; // Increment the counter
}
}
} else {
echo '<p>No categories found.</p>';
}
?>
</ul>
</div>
<!-- <div class="col-4">
<ul class="list-menu">
<li><a href="#">Electronics</a></li>
<li><a href="#">Home & Furniture</a></li>
<li><a href="#">Appliances</a></li>
<li><a href="#">Beauty And Toys</a></li>
</ul>
</div> -->
<div class="col-4 ftr-blks">
<ul class="list-menu">
<li><a href="#">Terms and condition</a></li>
<li><a href="#">Privacy policy</a></li>
<li><a href="#">Help</a></li>
<li><a href="#">Contact Us</a></li>
</ul>
</div>
<div class="col-12 ftr-blks">
<div class="follow-us">
<div class="txt">Follow Us : </div>
<ul class="follw-link">
<li><a href="#"><img src="<?php echo get_template_directory_uri(); ?>/img/fb.svg" alt=""></a></li>
<li><a href="#"><img src="<?php echo get_template_directory_uri(); ?>/img/insta.svg" alt=""></a></li>
<li><a href="#"><img src="<?php echo get_template_directory_uri(); ?>/img/tw.svg" alt=""></a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<div class="copy-right">
<p class="para">Copyright@anaffiliatedeal</p>
</div>
<?php
if (is_tax()) {
$term = get_queried_object(); // Get the current queried term
$term_slug = isset($term->slug) ? $term->slug : ''; // Get the term slug
} else {
$term_slug = ''; // Default value if not on a taxonomy page
}
?>
<!-- scripts -->
<script type="text/javascript" src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.3/js/bootstrap.bundle.min.js" integrity="sha512-7Pi/otdlbbCR+LnW+F7PwFcSDJOuUJB3OxtEHbg4vSMvzvJjde4Po1v4BR9Gdc9aXNUNFVUY+SK51wWT8WF0Gg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script type="text/javascript" src="//cdn.jsdelivr.net/npm/slick-carousel@1.8.1/slick/slick.min.js"></script>
<script>
$(document).ready(function () {
$('.thumbImgSlider').slick({
slidesToShow: 1,
slidesToScroll: 1,
dots: true,
autoplay: false,
arrows: false
});
$('.logoListing').slick({
slidesToShow: 1,
slidesToScroll: 1,
dots: false,
autoplay: true,
arrows: false,
variableWidth: true,
});
$('.bannerSlider').slick({
slidesToShow: 1,
slidesToScroll: 1,
dots: true,
autoplay: true,
arrows: false
});
$('.featured-wrap').slick({
slidesToShow: 3,
slidesToScroll: 1,
dots: true,
autoplay: false,
arrows: true,
prevArrow: '<button class="custom-prev"><img src="<?php echo get_template_directory_uri(); ?>/img/arw.svg"></button>',
nextArrow: '<button class="custom-next"><img src="<?php echo get_template_directory_uri(); ?>/img/arw.svg"></button>',
responsive: [
{
breakpoint: 1199, // Screen width <= 1024px
settings: {
slidesToShow: 2,
slidesToScroll: 1
}
},
{
breakpoint: 768, // Screen width <= 768px
settings: {
slidesToShow: 1,
slidesToScroll: 1,
arrows: false // Hide arrows for smaller screens if needed
}
},
{
breakpoint: 480, // Screen width <= 480px
settings: {
slidesToShow: 1,
slidesToScroll: 1,
dots: false // Hide dots for extra small screens if needed
}
}
]
});
});
document.addEventListener("DOMContentLoaded", function () {
const reportBtn = document.getElementById("report-expired-btn");
const popup = document.getElementById("report-expired-popup");
const closePopup = document.getElementById("close-popup");
// Open popup
reportBtn.addEventListener("click", function () {
popup.style.display = "flex";
});
// Close popup
closePopup.addEventListener("click", function () {
popup.style.display = "none";
});
// Close popup on outside click
window.addEventListener("click", function (event) {
if (event.target === popup) {
popup.style.display = "none";
}
});
});
var ajax_obj = {
ajax_url: "<?php echo admin_url('admin-ajax.php'); ?>"
};
document.addEventListener("DOMContentLoaded", function () {
const form = document.getElementById("report-expired-form");
const responseMessage = document.getElementById("response-message");
const submitButton = form.querySelector(".button");
form.addEventListener("submit", function (event) {
event.preventDefault();
const email = document.getElementById("email").value;
const dealId = document.getElementById("deal-id").value;
submitButton.innerHTML = "Submitting...";
submitButton.disabled = true;
jQuery.ajax({
url: ajax_obj.ajax_url, // AJAX URL localized in functions.php
type: "POST",
data: {
action: "report_expired", // Action name for the server-side handler
email: email,
deal_id: dealId,
},
success: function (response) {
if (response.success) {
responseMessage.innerHTML = `<p style="color: green;">${response.data.message}</p>`;
const modal = bootstrap.Modal.getInstance(document.getElementById('expiryModal'));
submitButton.innerHTML = "Send Now"; // Revert button text
submitButton.disabled = false; // Enable the button
setTimeout(() => {
modal.hide();
// Clear the message text after the modal is hidden
setTimeout(() => {
responseMessage.innerHTML = '';
}, 1000); // Additional 2-second delay
}, 2000);
document.getElementById("email").value='';
} else {
responseMessage.innerHTML = `<p style="color: red;">${response.data.message}</p>`;
const modal = bootstrap.Modal.getInstance(document.getElementById('expiryModal'));
submitButton.innerHTML = "Send Now"; // Revert button text
submitButton.disabled = false; // Enable the button
setTimeout(() => {
modal.hide();
// Clear the message text after the modal is hidden
setTimeout(() => {
responseMessage.innerHTML = '';
}, 1000); // Additional 2-second delay
}, 2000);
document.getElementById("email").value='';
}
},
error: function () {
responseMessage.innerHTML = `<p style="color: red;">${response.data.message}</p>`;
const modal = bootstrap.Modal.getInstance(document.getElementById('expiryModal'));
submitButton.innerHTML = "Send Now"; // Revert button text
submitButton.disabled = false; // Enable the button
setTimeout(() => {
modal.hide();
// Clear the message text after the modal is hidden
setTimeout(() => {
responseMessage.innerHTML = '';
}, 1000); // Additional 2-second delay
}, 2000);
document.getElementById("email").value='';
},
});
});
});
// document.addEventListener('DOMContentLoaded', function () {
// const crossPriceInput = document.getElementById('acf-field_67612f39cc15a'); // Replace with Cross Price ACF field ID
// const discountedPriceInput = document.getElementById('acf-field_67612f39cc15b'); // Replace with Discounted Price ACF field ID
// const discountPercentInput = document.getElementById('acf-field_67612f39cc15c'); // Replace with Discount Percent ACF field ID (if exists)
// function calculateDiscountPercent() {
// const crossPrice = parseFloat(crossPriceInput.value) || 0;
// const discountedPrice = parseFloat(discountedPriceInput.value) || 0;
// if (crossPrice > 0 && discountedPrice > 0) {
// const discountPercent = ((crossPrice - discountedPrice) / crossPrice) * 100;
// discountPercentInput.value = discountPercent.toFixed(2); // Updates the ACF field
// } else {
// discountPercentInput.value = ''; // Clear the percentage if inputs are invalid
// }
// }
// // Add event listeners to both fields
// crossPriceInput.addEventListener('input', calculateDiscountPercent);
// discountedPriceInput.addEventListener('input', calculateDiscountPercent);
// });
// Set the target end time (update to your desired end time)
// Set the target end time for today at 11:55 PM
const now = new Date();
const endTime = new Date();
endTime.setHours(23, 55, 0, 0); // 11:55 PM today
// Function to update the countdown
function updateCountdown() {
const now = new Date().getTime();
const timeRemaining = endTime - now;
if (timeRemaining > 0) {
const hours = Math.floor((timeRemaining / (1000 * 60 * 60)) % 24);
const minutes = Math.floor((timeRemaining / (1000 * 60)) % 60);
const seconds = Math.floor((timeRemaining / 1000) % 60);
// Format the time with leading zeros
const formattedTime = `${hours.toString().padStart(2, '0')}:${minutes
.toString()
.padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
document.getElementById("countdown-timer").textContent = formattedTime;
} else {
// Countdown has ended
document.getElementById("countdown-timer").textContent = "Deal Expired";
}
}
// Update the countdown every second
setInterval(updateCountdown, 1000);
var ajax_obj = {
ajax_url: "<?php echo admin_url('admin-ajax.php'); ?>"
};
jQuery(document).ready(function ($) {
$('#subscribe-button').on('click', function (e) {
e.preventDefault();
// if ($('#subscribe-form').parsley().isValid()) {
// Get the email value from the form
const email = $('input[name="email_id"]').val();
$('#subscribe-button').prop('disabled', true).text('Submitting...');
// Send the AJAX request
$.ajax({
url: ajax_obj.ajax_url, // AJAX handler URL
type: 'POST',
dataType: 'json',
data: {
action: 'send_form', // Matches the action in the PHP function
email: email,
nonce: '<?php echo wp_create_nonce("ajax_nonce"); ?>' // Pass the nonce for security
},
beforeSend: function () {
// Disable the button to prevent multiple submissions
$('#subscribe-button').prop('disabled', true).text('Submitting...');
$('#response-message').hide(); // Hide any previous messages
},
success: function (response) {
if (response.success) {
$('#response-message')
.css('color', '#42ff42')
.text(response.data.message || 'Subscribed successfully!')
.fadeIn();
$('#subscribe-form')[0].reset(); // Reset the form
} else {
$('#response-message')
.css('color', 'red')
.text(response.data.message || 'An error occurred. Please try again.')
.fadeIn();
}
setTimeout(function () {
$('#response-message').fadeOut(); // Fade out the message after 10 seconds
}, 10000);
},
error: function () {
$('#response-message')
.css('color', 'red')
.text('An unexpected error occurred. Please try again later.')
.fadeIn();
},
complete: function () {
// Re-enable the button regardless of the outcome
$('#subscribe-button').prop('disabled', false).text('Subscribe');
},
});
});
});
var ajax_obj = {
ajax_url: "<?php echo admin_url('admin-ajax.php'); ?>"
};
jQuery(document).ready(function ($) {
$('#subscribe-button1').on('click', function (e) {
e.preventDefault();
// if ($('#subscribe-form').parsley().isValid()) {
// Get the email value from the form
const email = $('input[name="emailid"]').val();
$('#subscribe-button1').prop('disabled', true).text('Submitting...');
// Send the AJAX request
$.ajax({
url: ajax_obj.ajax_url, // AJAX handler URL
type: 'POST',
dataType: 'json',
data: {
action: 'send_form', // Matches the action in the PHP function
email: email,
nonce: '<?php echo wp_create_nonce("ajax_nonce"); ?>' // Pass the nonce for security
},
beforeSend: function () {
// Disable the button to prevent multiple submissions
$('#subscribe-button1').prop('disabled', true).text('Submitting...');
$('#response-message1').hide(); // Hide any previous messages
},
success: function (response) {
if (response.success) {
$('#response-message1')
.css('color', '#42ff42')
.text(response.data.message || 'Subscribed successfully!')
.fadeIn();
$('#subscribe-form1')[0].reset(); // Reset the form
} else {
$('#response-message1')
.css('color', 'red')
.text(response.data.message || 'An error occurred. Please try again.')
.fadeIn();
}
setTimeout(function () {
$('#response-message1').fadeOut(); // Fade out the message after 10 seconds
}, 10000);
},
error: function () {
$('#response-message1')
.css('color', 'red')
.text('An unexpected error occurred. Please try again later.')
.fadeIn();
},
complete: function () {
// Re-enable the button regardless of the outcome
$('#subscribe-button1').prop('disabled', false).text('Subscribe ');
},
});
});
});
var ajax_obj = {
ajax_url: '<?php echo admin_url('admin-ajax.php'); ?>',
term_slug: '<?php echo esc_js($term_slug); ?>' // Pass the term slug to JS
};
jQuery(document).ready(function ($) {
let page = 1; // Starting page
const loadMoreBtn = $('#load-more'); // The Load More button
let displayedPosts = []; // Track displayed post IDs
// Store IDs of posts already rendered on page load
$('.card-row-wrap').each(function () {
const postId = $(this).data('post-id'); // Add a data attribute for post ID
if (postId) displayedPosts.push(postId);
});
console.log(displayedPosts);
loadMoreBtn.on('click', function () {
loadMoreBtn.text('Loading...'); // Show loading text
page++; // Increment the page number
$.ajax({
url: ajax_obj.ajax_url, // AJAX URL from localized script
type: 'POST',
data: {
action: 'load_more_posts',
term_slug: ajax_obj.term_slug, // Current taxonomy term slug
page: page,
displayed_posts: displayedPosts // Send displayed post IDs
},
success: function (response) {
// Check if "No product deals found." is in the response
// alert(response);
if (response.trim() === 'No product deals found') {
loadMoreBtn.text('No More Posts').hide(); // Hide button if no deals
} else {
// Append new posts
$('.card-wrp').append(response);
// Convert response string to jQuery object to find new posts
const newPosts = $(response).filter('.card-row-wrap');
// Add newly rendered post IDs to the displayedPosts array
newPosts.each(function () {
const postId = $(this).data('post-id');
if (postId) displayedPosts.push(postId);
});
console.log('Displayed Posts:', displayedPosts);
loadMoreBtn.text('Load More'); // Reset button text
}
},
error: function () {
loadMoreBtn.text('Error Loading Posts'); // Handle errors
},
});
});
});
var ajax_obj = {
ajax_url: '<?php echo admin_url('admin-ajax.php'); ?>',
term_slug: '<?php echo esc_js($term_slug); ?>' // Pass the term slug to JS
};
jQuery(document).ready(function ($) {
// Listen for input in the search field
$('form').on('submit', function (e) {
var searchTerm = $(this).val(); // Get the current search term
if (searchTerm.length > 2) { // Start searching after 3 characters are typed
$.ajax({
url: ajax_obj.ajax_url, // Use the localized AJAX URL
type: 'GET',
data: {
action: 'search_ajax',
s: searchTerm // Send the search term to the server
},
success: function (response) {
// Insert the results into the container
$('.search-results').html(response);
},
error: function () {
console.log('AJAX request failed');
}
});
}
});
});
</script>
<?php wp_footer(); ?>
</body>
</html>