Buy as a gift
');
$(".cpr_voucher_badge").html($(".offer_voucher_badge").html());
$('.fast_selling_badge span').html("Fast Selling");
$(".cpr_voucher_logo").hide();
$(".cpr_voucher_add_to_cart button").html("Select Offer");
$(".cpr_voucher_add_to_cart button").attr("data-id","11384");
$(".cpr_voucher_add_to_cart button").attr("onclick","pick_ad(this)");
$(".cpr_voucher_buy_btn button").attr("data-id","11384");
$(".cpr_voucher_buy_btn button").attr("onclick","buy_sa_voucher(this)");
$(".cpr_voucher_buy_btn").append($(".offer_voucher_buy_btn").html());
// Voucher / Event Expired
// hide buy btn and quantity section for vouchers of directory voucher campaigns
$(".sales_count_div").show();
$(".sales_count_badge").show();
$(".fast_selling_badge").hide();
$(".fake_social_heading, .fake_social_heading, .fake_v_facebook, .fake_v_twitter, .fake_v_instagram, .fake_v_linkedin, .fake_voucher_summary").remove();
$(".cpr_voucher_social_links").html($(".offer_voucher_social_links").html());
$(".cpr_voucher_phone_number").html("
Phone: ");
$(".cpr_voucher_website").html("
Website: ");
$(".cpr_voucher_expense").html("
Expense: ");
$(".cpr_voucher_hours_operation").html($(".offer_voucher_hours_operation").html());
$(".cpr_voucher_hours_operation").next().remove("");
$(".cpr_voucher_additional_details").html($(".offer_voucher_additional_details").html());
$(".cpr_voucher_give_as_gift").html($(".offer_voucher_give_as_gift").html());
$(".cpr_voucher_directory_voucher").html($(".offer_voucher_directory_voucher").html());
$(".cpr_voucher_directory_voucher").hide();
$(".cpr_voucher_phone_number").hide();
$(".cpr_voucher_website").hide();
$(".cpr_voucher_expense").hide();
$(".cpr_voucher_social_links").hide();
//$(".cpr_voucher_give_as_gift a").attr("onclick","buy_sa_voucher(this)");
//$(".cpr_voucher_give_as_gift a").attr("data-id","11384");
$(".cpr_voucher_logo, .cpr_voucher_image_video, .cpr_voucher_price, .cpr_discount_percentage, .cpr_voucher_name, .cpr_voucher_footer, .cpr_voucher_address_line, .cpr_voucher_description, .cpr_voucher_rating, .cpr_voucher_summary, .cpr_voucher_reviews, .cpr_voucher_reviews, .cpr_voucher_slideshow, .cpr_voucher_address, .cpr_voucher_buy_btn, .cpr_voucher_add_to_cart, .cpr_voucher_quantity, .cpr_voucher_hours_operation, .cpr_voucher_additional_details, .cpr_voucher_phone_number, .cpr_voucher_website, .cpr_voucher_expense, .cpr_voucher_social_links, .cpr_voucher_give_as_gift, .cpr_voucher_directory_voucher, .cpr_voucher_badge").parent().css("border","none");
let totalSales = 0;
$( document ).ready(function() {
$('.cpr_discount_percentage .sales_count_div').each(function() {
let salesCount = parseInt($(this).html().match(/\d+/), 10);
if (!isNaN(salesCount)) {
totalSales += salesCount;
}
});
$('.sales_count_badge span').html(totalSales+"+ Sales");
});
/*const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
if (isMobile) {*/
//console.log(screen.width);
//if(screen.width<=450){
var iframeWidth = window.innerWidth || document.documentElement.clientWidth;
console.log(iframeWidth);
if(iframeWidth<=450){
$(".hide-on-mobile").remove();
}else{
$(".hide-on-web").remove();
}
$("input[name='additional_voucher_selection']").first().click();
function pick_ad(obj){
var off_id = $(obj).attr('data-id');
var add_id = '4433';
var checkbox = $(".cart_checkbox");
if(checkbox.is(":checked")) //unchecking
{
checkbox.prop("checked",false);
// remove from cart
$.get('https://smartcouponz.wi-local.com/add_to_cart',{action:'remove_from_cart',ad_id:add_id,offer_id:off_id},function(res){
var text = "Select Offer";
$(obj).html(text);
history.back();
});
// end remove from cart
}else{ //checking
checkbox.prop("checked",true);
// add to cart
$.get('https://smartcouponz.wi-local.com/add_to_cart',{action:'add_to_cart',ad_id:add_id,offer_id:off_id},function(res){
var text = "Selected";
$(obj).html("
"+text);
history.back();
});
// end add to cart
}
}
function update_multi_voucher(id){
$("#multi_voucher_id").val(id);
}
var openedWindow;
function buy_sa_voucher(obj){
console.log("clicked buy now button");
var is_gift=0;
/*var type = $(obj).attr('data-type');
if(type=="gift"){
is_gift=1;
}*/
if($("#buy_as_gift").is(":checked")){
is_gift=1;
}
var off_id = $(obj).attr('data-id');
var add_id = '4433';
var quantity = $("#quantity").val();
var multi_voucher_id = $("#multi_voucher_id").val();
//var total_amount = $('#new_voucher_price').text().replace(/[^a-zA-Z0-9-. ]/g, '');
var total_amount = $('#new_voucher_price').text().replace(/[^\d.]/g, '');
console.log(total_amount)
//window.location = ;
var url = "https://smartcouponz.wi-local.com/sa-shoping-cart?off_id="+off_id+"&directory_id="+add_id+"&quantity="+quantity+"&total="+total_amount+"&is_gift="+is_gift+"&multi_voucher_id="+multi_voucher_id;
openedWindow = window.open(url,"_blank","width=700,height=750");
/*openedWindow.addEventListener('unload', function(event) {
// Call your custom function when the new window is about to close
customCloseFunction();
});*/
/*openedWindow.onunload = function() {
// Call your custom function when the new window is closed
customCloseFunction();
};*/
}
function customCloseFunction() {
// Add your custom logic here
//alert('New window is closing. Custom function called!');
if($("#svoid").val()==""){
$("#exit-popup-modal").modal('show');
}
}
function submit_form(order_id,first_name,last_name,phone_number,email_address,agree_to_receive_offer,from_name){
//alert(order_id);
$("#svoid").val(order_id);
$("#first_name").val(first_name);
$("#last_name").val(last_name);
$("#phone_number").val(phone_number);
$("#email_address").val(email_address);
$("#from_name").val(from_name);
if(agree_to_receive_offer==1){
$("#save_subscriber_form").append("
");
}
$("#save_subscriber_form").submit();
}
function console_log(str){
console.log(str);
}
function update_price(obj){
console.log("Quantity Changed");
var allowed_sales_per_sub = Number("0");
var quantity = $(obj).val();
if(allowed_sales_per_sub!=0 && allowed_sales_per_sub!=""){
if(quantity>allowed_sales_per_sub){
quantity = allowed_sales_per_sub;
$(obj).val(quantity);
swal("Limit Reached","You are permitted to acquire only "+allowed_sales_per_sub+" vouchers.","warning");
}
}
var single_price = $("#voucher_price").val();
var final_price = single_price*quantity;
final_price = final_price.toFixed(2);
$("#new_voucher_price").html("$"+final_price);
}
function show_large_img(obj,id){
var img_src = $(obj).attr('src');
$("#show_offer_img").attr('src',img_src);
$("#offer-img-modal").modal('show');
$("#offer-img-modal").find(".offer-btn").attr('data-id',id);
$("#offer-img-modal").find(".offer-btn").addClass('modal-giveaway-'+id);
$("#offer-img-modal").find("input").val(id);
}
function showLoader(){
$(".loader").show();
$(".overlay").show();
}
function showHideCat(cat_id){
if($("#checkbox_cat_"+cat_id).is(":checked")){
$(".cat_"+cat_id).show();
$(".btn_cat_"+cat_id+" i").addClass("la-check");
$(".btn_cat_"+cat_id+" i").removeClass("la-close");
}else{
$(".cat_"+cat_id).hide();
$(".btn_cat_"+cat_id+" i").addClass("la-close");
$(".btn_cat_"+cat_id+" i").removeClass("la-check");
}
$('.cat_check:checked').each(function() {
var temp_elem = $(this).attr('id');
temp_elem = temp_elem.replace("checkbox_","");
$("."+temp_elem).show();
})
}
function max_offers_to_claim(){
var allowed_giveaways = $("#no_of_give_away").val();
var ole_title = "Offer limit Exceeded!";
var ole_description = "You cannot choose more than %limit% Offers";
ole_description = ole_description.replace("%limit%", allowed_giveaways);
var ole_btn_txt = "OK";
swal({
title: ole_title,
text: ole_description,
icon: "error",
showCancelButton: false,
buttons: {
confirm: {
text: ole_btn_txt,
value: true,
visible: true,
className: "ole_btn",
closeModal: true
}
}
})
}
function claim_ads(){
var all_claimed_offers = $("#all_claimed_offers").val();
var allowed_giveaways = $("#no_of_give_away").val();
var giveaways = $(".grid-item").find("input:checked").length;
var nosp_title = "No Offer!";
var nosp_description = "Please pick upto %limit% Offers to claim";
nosp_description = nosp_description.replace("%limit%", allowed_giveaways);
var nosp_btn_txt = "OK";
var ole_title = "Offer limit Exceeded!";
var ole_description = "You cannot choose more than %limit% Offers";
ole_description = ole_description.replace("%limit%", allowed_giveaways);
var ole_btn_txt = "OK";
var total_claimed_offers = Number(all_claimed_offers) + Number(giveaways);
if(giveaways==0){
swal({
title: nosp_title,
text: nosp_description,
icon: "error",
showCancelButton: false,
buttons: {
confirm: {
text: nosp_btn_txt,
value: true,
visible: true,
className: "nosp_btn",
closeModal: true
}
}
})
return false;
}
if(total_claimed_offers>allowed_giveaways){
swal({
title: ole_title,
text: ole_description,
icon: "error",
showCancelButton: false,
buttons: {
confirm: {
text: ole_btn_txt,
value: true,
visible: true,
className: "ole_btn",
closeModal: true
}
}
})
return false;
}
}
function choose_ad(obj){
$(obj).prev().click();
}