// ****************************************************************** // PRODUCT GALLERY Variable Configuration // ****************************************************************** // Check to make sure that we are on a product gallery page var approve_product_gallery_page_check = '.product.product--large '; // Wrapper for each item var approve_product_gallery_item_ele = ' .product__info-wrapper'; // Price for each item var approve_product_model_ele_name = ' .product__title h1'; // Price for each item var approve_product_gallery_item_price_ele = ' span.price-item.price-item--regular'; // Insert button after var approve_product_gallery_insert_btn_after_ele = ' .product-form__buttons'; // PRODUCT GALLERY if (approve_product_gallery_page_check){ var approve_product_page_check = document.querySelector(approve_product_gallery_page_check); } if (approve_product_page_check){ var approve_gallery_product_array = document.querySelectorAll(approve_product_gallery_item_ele); approve_gallery_product_array.forEach(function(item) { var approve_gallery_price_wrapper = item.querySelector(approve_product_gallery_item_price_ele); var approve_gallery_price = 0; if (approve_gallery_price_wrapper){ approve_gallery_price = approve_gallery_price_wrapper.innerHTML; approve_gallery_price = approve_gallery_price.replace(/[^0-9-.]/g, ''); approve_price = parseFloat(approve_gallery_price); approve_teaser = approve_price/60; } if (approve_product_model_ele_name) { approve_model = document.querySelector(approve_product_model_ele_name); } var insert_ele = item.querySelector(approve_product_gallery_insert_btn_after_ele); let approve_button_wrapper = document.createElement("div"); approve_button_wrapper.className = "btn-container"; approve_button_wrapper.style.marginTop = "25px"; approve_button_wrapper.style.marginLeft = "60px"; var approve_item = '[{"model":"'+encodeURIComponent(approve_model.textContent)+'","price":'+approve_price+',"subtotal":'+approve_price+',"quantity":1,"type":"new_product"}]'; var encoded = btoa(approve_item); approve_button_wrapper.innerHTML = /*html*/`
Finance with
As low as
$`+Math.floor(approve_teaser)+`/mo
Apply in 60 seconds | Lenders compete
`; //button wrapper approve_button_wrapper.style.width = "auto"; approve_button_wrapper.style.display = "inline-block"; //button var approve_gallery_button = approve_button_wrapper.querySelector('.approve-button'); approve_gallery_button.style.textAlign = "center"; approve_gallery_button.style.borderRadius = "12px"; approve_gallery_button.style.fontFamily = "verdana,sans-serif"; approve_gallery_button.style.fontSize = "14px"; //button teaser var approve_gallery_teaser = approve_button_wrapper.querySelector('.teaser'); approve_gallery_teaser.style.fontSize = "1.5em"; approve_gallery_teaser.style.fontWeight = "700"; // sm text var approve_gallery_teaser = approve_button_wrapper.querySelector('.sm-txt'); approve_gallery_teaser.style.fontSize = ".8em"; // button teaser rate var approve_gallery_teaser_rate = approve_button_wrapper.querySelector('.teaser'); approve_gallery_teaser_rate.setAttribute('approve-total',approve_gallery_price); if (approve_gallery_price >= 1500){ insert_ele.after(approve_button_wrapper); } }); window.kwipped_approve.core.activate_approve_teaser_rates(); } // IF YOU WANT TO USE A LOG WITH COLORS YOU CAN USE function approve_debug_log(log, warn, err) { warn = warn || false; err = err || false; let css = "padding: 5px 20px; "; if (err) { css += "background:#8B0000; color:#fff; "; } else if(warn) { css += "background:#FFBF00; color:#000; "; } else { css += "background:#418AC9; color:#fff; "; } if (approve_debug_mode) console.log("%c"+log,css); }