wideBundle.updateDiv = function(element, valuesToTest, divElement) {
console.log("updating the div");
divs = element.querySelectorAll(divElement);
for (const valueToTest of valuesToTest) {
for (let i = 0; i < divs.length; i++) {
if (divs[i].innerHTML.toLowerCase().trim() == valueToTest.replace(/&/g, "&").trim()) {
divs[i].click();
divs[i].click(); // Double click for some themes with troubles
dispatchClick(divs[i]);
return;
}
else if (divs[i].innerText.toLowerCase().trim() == valueToTest.replace(/&/g, "&").trim()) {
divs[i].click();
divs[i].click(); // Double click for some themes with troubles
dispatchClick(divs[i]);
return;
}
else if (divs[i].innerText.toLowerCase().replace(/&/g, "&").trim() == valueToTest.replace(/&/g, "&").trim()) {
divs[i].click();
divs[i].click(); // Double click for some themes with troubles
dispatchClick(divs[i]);
return;
}
else if(divs[i].hasAttribute('data-replo-set-active-variant') && divs[i].getAttribute('data-replo-set-active-variant').toLowerCase() == valueToTest){
divs[i].click();
divs[i].click(); // Double click for some themes with troubles
dispatchClick(divs[i]);
return;
}
}
}
}
//Send change event to trigger functions on the theme
wideBundle.fireAllChangeEvent = function(){
//Elements to trigger change event with vanilla JS
var elementsToTrigger = ["variant-selects", 'div[data-pf-type="ProductVariantSwatches"]'];
//Elements to trigger all children with vanilla JS
var elementsToTriggerAll = ["variant-select", "variant-picker", "product-variants", "variant-selector", ".shg-product-variant-select"];
//Elements to trigger all in bubble with vanilla JS
var elementsToTriggerAllBubble = [".product-block-list__item.product-block-list__item--info .product-form__single-selector:checked", ".shopify-product-form .product-options .product-option-list",
".product__variants--select .styled-select select.option-selector",".single-option-selector"];
//Elements to trigger change event with jQuery
var elementsToTriggerJquery = ["#SingleOptionSelector-0", ".option-selectors .selector-wrapper select"];
//Elements to trigger with timeout
var elementsToTriggerTimeout = ["main#mainWrap #productHead #prodForm .form-select-wrapper .single-option-selector",
"#ProductSection-product-template #add-to-cart-form #product-variants select"]
//Trigger Vanilla JS
for (const elementToTrigger of elementsToTrigger) {
var element = document.querySelector(elementToTrigger);
if(element){
if('createEvent' in document){
var evt = document.createEvent('HTMLEvents');
evt.initEvent('change', false, true);
element.dispatchEvent(evt);
}
else{
element.fireEvent('onchange');
}
}
}
//Trigger Vanilla JS for all children
for (const elementToTriggerAll of elementsToTriggerAll) {
var element = document.querySelectorAll(elementToTriggerAll);
for(var i = 0; i
1) {
return priceWithCommas = matches[1];
}
return null;
}
// Function to detect if there is whitespaces between to substrings in a giving string
function spaceSubstrings(inputString, substring1, substring2) {
const index1 = inputString.indexOf(substring1);
const index2 = inputString.indexOf(substring2);
if (index1 !== -1 && index2 !== -1) {
const startIndex = Math.min(index1, index2);
const endIndex = Math.max(index1, index2);
const spaceBetween = inputString.substring(startIndex + substring1.length, endIndex);
return /\s/.test(spaceBetween);
}
return false;
}
//Function to check and remove duplicated substrings in a string
function removeDuplicate(originalString, substrings) {
const escapedSubstrings = substrings.map(substring => substring.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'));
const regexString = escapedSubstrings.map(substring => `(${substring})`).join('|');
const regex = new RegExp(regexString, 'g');
const uniqueSubstrings = [];
const result = originalString.replace(regex, (match, ...groups) => {
const substring = groups.find(group => group !== undefined);
if (!uniqueSubstrings.includes(substring)) {
uniqueSubstrings.push(substring);
return substring;
}
return '';
});
return result;
}
// Function to remove all texts from a string and keep only the provided substrings
function keepSubstrings(price, ...substrings) {
priceNew = removeDuplicate(price, substrings);
const escapedCurrencySymbols = substrings.map(symbol => symbol.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'));
const regex = new RegExp([...substrings, ...escapedCurrencySymbols].join('|'), 'g');
const matchedSubstrings = priceNew.match(regex) || [];
const filteredResult = matchedSubstrings.filter(str => str !== '');
for(var i=0; i<(filteredResult.length)-1; i++){
if(spaceSubstrings(priceNew, filteredResult[i], filteredResult[i+1])){
filteredResult[i] = filteredResult[i] + ' ';
}
}
return filteredResult.join('');
}
// Function to check if a string has a currency code and return it
function extractCurrencyCode(inputString) {
const currencyCodeRegex = /[A-Z]{3}/;
const matches = inputString.match(currencyCodeRegex);
return matches ? matches[0] : null;
}
//If the user uses Market and another currency is selected we have to replace the symbol
wideBundle.replaceCurrencyForMarket = function(price){
//Exit if the currency is the same as the default
if(typeof Shopify.currency != "undefined" && Shopify.currency.active == wideBundle.settings.currency_code){
return price;
}
symbols = ["MXN $", "US$", "$", "€", "£", "kr", "Kr", "CHF", 'USD', 'PLN', 'zł', 'QAR', 'AED', 'SFr'];
symbols.every(symbol => {
if(price.includes(symbol)){
rawPrice = extractPrice(price);
if(wideBundle.settings.currency_format === 'symbol'){
price = keepSubstrings(price, rawPrice, symbol)
price = price.replace(symbol, wideBundle.currencySymbols[Shopify.currency.active])
}
else if(wideBundle.settings.currency_format === 'both'){
currencyCode = extractCurrencyCode(price);
if(currencyCode == null){
price = keepSubstrings(price, rawPrice, symbol)
price = price.replace(symbol, wideBundle.currencySymbols[Shopify.currency.active]) + ' ' + Shopify.currency.active;
}
else{
price = keepSubstrings(price, rawPrice, symbol, currencyCode)
price = price.replace(symbol, wideBundle.currencySymbols[Shopify.currency.active]);
price = price.replace(currencyCode, Shopify.currency.active);
}
}
else {
price = keepSubstrings(price, rawPrice, symbol)
price = price.replace(symbol, wideBundle.currencyCodes[Shopify.currency.active])
}
return false;
}
return true;
});
return price;
}
//Replace hidden prices with prices from Ajax if we couldn't get them from the theme JSON
wideBundle.addPricesFromAjax = function(){
if(typeof Shopify != "undefined" && typeof Shopify.currency != "undefined"){
//Check if we can't get prices from json
if(!wideBundle.getPricesFromJson(document.querySelector('.wb_hidden_prices .wb_hidden_price').getAttribute('variant-id'))){
console.log('doing ajax');
const url = `${window.Shopify.routes.root}products/${wideBundle.currentHandle}.js`;
fetch(url)
.then(response => response.json())
.then(product => {
console.log(product.variants);
console.log("PriceJson Script not available");
product.variants.forEach(variant => { //Format prices we received
priceStructured = wideBundle.formatPriceFromJson(variant.price);
priceStructured = wideBundle.updatePriceSeparator(priceStructured.toString());
if(variant.compare_at_price){
compareAtPriceStructured = wideBundle.formatPriceFromJson(variant.compare_at_price)
compareAtPriceStructured = wideBundle.updatePriceSeparator(compareAtPriceStructured.toString());
compareAtPriceStructured = parseFloat(wideBundle.getAmountFromPrice(priceStructured)) >= parseFloat(wideBundle.getAmountFromPrice(compareAtPriceStructured)) ? "" : compareAtPriceStructured
}
else{
compareAtPriceStructured = "";
}
//Replace the prices in hidden prices and after creating the widget we will use them
document.querySelector('.wb_hidden_prices .wb_hidden_price[variant-id="'+variant.id+'"]').innerHTML = wideBundle.removeDecimal(priceStructured);
document.querySelector('.wb_hidden_prices .wb_hidden_compared_price[variant-id="'+variant.id+'"]').innerHTML = wideBundle.removeDecimal(compareAtPriceStructured);
});
wideBundle.updatePriceOnAllOffers(); //Update the offers with the new prices
})
.catch(error => console.error(error));
}
}
}
//Remove currency from a price
wideBundle.getAmountFromPrice = function(price) {
// Count occurrences of dots and commas surrounded by two numbers
/*var dotsCount = (price.match(/\d\.\d/g) || []).length;
var commasCount = (price.match(/\d,\d/g) || []).length;
if (dotsCount > 2 || commasCount > 2 || (dotsCount === 1 && commasCount === 1)) {
// Remove the first occurrence of dot or comma surrounded by numbers
price = price.replace(/(\d)([.,])(\d)/, '$1$3');
}*/
var regp = /[^0-9.,]*(\d+(?:[.,]\d+)?)(?:[^0-9.,]|$)/;
match = price.match(regp);
if (match) {
return match[1];
} else {
return price;
}
}
//Get only the current currency format
wideBundle.getCurrentCurrencyOnly = function(price){
if(price != "" && price != null){
return price.replace(/\d+.\d+/g,'{{amount}}').replace(/\d+/g,'{{amount}}');
}
}
//Get the difference between two prices
function getAmountDifference(price, compareAtPrice){
numberForPrice = parseFloat(wideBundle.getAmountFromPrice(price).replace(',', '.')); //Get the amount only for the price
numberForCompareAtPrice = parseFloat(wideBundle.getAmountFromPrice(compareAtPrice).replace(',', '.')); //compare at price
var amountDifference = numberForCompareAtPrice - numberForPrice;
percentDifference = 100 * parseFloat(amountDifference) / numberForCompareAtPrice;
percentDifference = Math.round(percentDifference);
amountDifference = amountDifference.toFixed(2); //We round the price so we can have "34.00" or "34.99"
return {
"amount": amountDifference,
"percent": percentDifference
};
}
//Send observer to change the main price
function observePriceChanges(target) {
const config = {
childList: true,
subtree: true,
characterData: true,
};
const callback = function (mutationsList, observer) {
if (!window.pricesWB) return;
for (let mutation of mutationsList) {
for (let selector of pricesWB) {
let targetMatch = false;
let addedMatch = false;
let removedMatch = false;
if (mutation.target.matches !== undefined && mutation.target.matches(selector)) {
targetMatch = true;
}
Array.from(mutation.addedNodes).forEach(node => {
if (node.matches !== undefined && node.matches(selector)) {
addedMatch = true;
}
});
Array.from(mutation.removedNodes).forEach(node => {
if (node.matches !== undefined && node.matches(selector)) {
removedMatch = true;
}
});
if (mutation.target.nodeType != 3 && mutation.target.nodeType != 8) {
if (mutation.target.querySelector('.first-price-WB') || mutation.target.querySelector('.second-price-WB')) continue;
}
if (targetMatch || addedMatch || removedMatch) {
if (formWB.style.height == '0px' || formWB.style.display === 'none' || wideBundle.manualWidget) {
wideBundle.updateMainPrice();
}
}
}
}
};
const observer = new MutationObserver(callback);
observer.observe(target, config);
}
observePriceChanges(document);
wideBundle.updatePriceOnAllOffers = function(){
offers = document.querySelectorAll('.new-form-option');
offers.forEach(offer => {
if(offer.classList.contains('selectedWB')){
offerID = wideBundle.getSelectedVariantId();
}
else{
offerID = offer.getAttribute('data-id');
}
price = offer.querySelector('.first-price-WB');
compareAtPrice = offer.querySelector('.second-price-WB');
if(price){
price.innerHTML = document.querySelector(`.wb_hidden_prices .wb_hidden_price[variant-id="${offerID}"]`).innerHTML;
handleTranscyPrice(document.querySelector(`.wb_hidden_prices .wb_hidden_price[variant-id="${offerID}"]`).innerHTML, price);
}
if(compareAtPrice){
compareAtPrice.innerHTML = document.querySelector(`.wb_hidden_prices .wb_hidden_compared_price[variant-id="${offerID}"]`).innerHTML;
handleTranscyPrice(document.querySelector(`.wb_hidden_prices .wb_hidden_compared_price[variant-id="${offerID}"]`).innerHTML, compareAtPrice);
}
const priceParent = price.parentNode;
if(priceParent.classList.contains("hidden-unit")){
const variantUnitPrice = parseFloat(wideBundle.getAmountFromPrice(price.innerHTML).replace(',', '.')) * priceParent.getAttribute('data_offer_cr');
priceParent.parentNode.querySelector('.wb_unit_price').innerHTML = (wideBundle.removeDecimal(wideBundle.updatePriceSeparator(wideBundle.formatPriceForUnit(variantUnitPrice))));
}
//For "you save" text
if(compareAtPrice.innerHTML != '' && wideBundle.settings.economic_display == 1){
percent = offer.querySelector('.percent-wb');
priceEconomic = offer.querySelector('.span-economic-wb');
var priceDifference = getAmountDifference(price.innerHTML, compareAtPrice.innerHTML)
priceDifferenceFormatted = wideBundle.updatePriceSeparator(wideBundle.removeDecimal(wideBundle.getCurrentCurrencyOnly(price.innerHTML).replace('{{amount}}', priceDifference.amount)));
if(percent){
percent.innerHTML = priceDifference.percent;
}
if(priceEconomic){
priceEconomic.innerHTML = priceDifferenceFormatted;
}
}
else{
var savingsText = offer.querySelector('.economic-wb');
if(savingsText){ //Hide the savings text if we have it
savingsText.style.display = "none";
}
}
});
wideBundle.updateMainPrice();
}
//Add the main style of the widget
wideBundle.addMainStyle = function (attribute = '') {
var mainStyle = `
#new-form shopify-buy-it-now-button:nth-of-type(2){ /* Fix a bug where buy now button appears twice */
display: none;
}
#checkout-xx-aa {
color: white;
font-size: 1px;
margin-top: 0px;
margin-bottom: 0px;
display: none;
}
#new-form *, #new-form::before, #new-form::after {
box-sizing: border-box;
}
#new-form, .new-wb-form {
max-width: 700px;
margin: auto;
position: relative;
${wideBundle.settings.rtl == 1 ? 'direction: rtl;' : ''};
}
.product--no-media product-form.product-form{
display: block !important;
}
#new-form .jumpstart-selector .arrow{
display: none !important;
}
#new-form .jumpstart-selector select{
-webkit-appearance: auto;
appearance: auto;
}
.product-detail .product-form.theme-init .option-selectors{
display: none !important;
}
.p-title-WB {
overflow: hidden;
position: relative;
display: flex;
text-align: ${wideBundle.settings.preview_heading_position};
justify-content: center;
}
.p-title-WB__content {
position: relative;
color: ${wideBundle.settings.preview_heading_color};
font-size: ${wideBundle.settings.preview_heading_font_size};
${wideBundle.settings.preview_heading_font_style == 'none' ? 'font-style: normal !important;font-weight: normal !important;' : ''};
${wideBundle.settings.preview_heading_font_style == 'bold' ? 'font-style: normal !important;font-weight: bold !important;' : ''};
${wideBundle.settings.preview_heading_font_style == 'italic' ? 'font-style: italic !important;font-weight: normal !important;' : ''};
${wideBundle.settings.preview_heading_font_style == 'bold-italic' ? 'font-style: italic !important;font-weight: bold !important;' : ''};
${wideBundle.settings.preview_heading_position == 'left' ? 'margin: 0 auto 0 0;' : ''};
${wideBundle.settings.preview_heading_position == 'center' ? 'margin: 0 auto;' : ''};
${wideBundle.settings.preview_heading_position == 'right' ? 'margin: 0 0 0 auto;' : ''};
${wideBundle.settings.preview_heading_position == 'left' && wideBundle.settings.heading_line_display == 1 ? 'padding: 0px 8px 0px 0px;max-width: 90%;' : ''};
${wideBundle.settings.preview_heading_position == 'center' && wideBundle.settings.heading_line_display == 1 ? 'padding: 0px 8px 0px 8px;max-width: 90%;' : ''};
${wideBundle.settings.preview_heading_position == 'right' && wideBundle.settings.heading_line_display == 1 ? 'padding: 0px 0px 0px 8px;max-width: 90%;' : ''};
}
.p-title-WB::before {
display: ${wideBundle.settings.heading_line_display == 1 && (wideBundle.settings.preview_heading_position == 'center' || wideBundle.settings.preview_heading_position == 'right') ? 'block' : 'none'};
content: '';
flex-grow: 1;
//top: calc(50% - ${wideBundle.settings.heading_line_size} / 2);
height: ${wideBundle.settings.heading_line_size};
background-color: ${wideBundle.settings.heading_line_color};
margin: auto;
}
.p-title-WB::after {
display: ${wideBundle.settings.heading_line_display == 1 && (wideBundle.settings.preview_heading_position == 'left' || wideBundle.settings.preview_heading_position == 'center') ? 'block' : 'none'};
content: '';
flex-grow: 1;
//top: calc(50% - ${wideBundle.settings.heading_line_size} / 2);
height: ${wideBundle.settings.heading_line_size};
background-color: ${wideBundle.settings.heading_line_color};
margin: auto;
}
.new-form-option{
display:flex;
align-items:center;
${wideBundle.settings.rtl == 1 ? 'padding: 10px 0px 10px 10px;' : 'padding: 10px 10px 10px 0px;'}
cursor:pointer;
border-radius:5px;
margin-bottom:15px;
border:2px solid #c6c6c6;
transition: background-color: 0.1s ease, border 0.1 ease;
}
.new-form-option .value-left{
display: flex;
justify-content: center;
align-items: center;
text-align: center;
}
.diagonal-offer{
--d: 10px;
position: relative;
--message: 'special offer';
${wideBundle.settings.display_quantity == 1 && wideBundle.settings.design_code !== '1' && wideBundle.settings.design_code !== '5' ? 'padding-right: 40px !important;' : ''};
}
.diagonal-offer::before {
content: var(--message);
position: absolute;
font-family: sans-serif;
top: 0;
right: 0;
transform: translate(29.29%, -100%) rotate(45deg);
text-align: center;
border: 1px solid transparent;
border-bottom: 0;
transform-origin: bottom left;
padding: 5px 35px calc(var(--d) + 5px);
background: linear-gradient(rgba(0, 0, 0, 0.5) 0 0) bottom/100% var(--d)
no-repeat var(--c);
background-clip: padding-box;
clip-path: polygon(0 0,100% 0,100% 100%,calc(100% - var(--d)) calc(100% - var(--d)),var(--d) calc(100% - var(--d)),0 100%);
-webkit-mask: linear-gradient(135deg,transparent calc(50% - var(--d) * 0.707),#fff 0) bottom left,
linear-gradient(-135deg, transparent calc(50% - var(--d) * 0.707), #fff 0)bottom right;
-webkit-mask-size: 300vmax 300vmax;
-webkit-mask-composite: destination-in, xor;
mask-composite: intersect;
max-width: 195px;
overflow: hidden;
text-overflow: ellipsis;
line-height: 1;
z-index: 2;
}
.corner-offer{
--f: 14px;
--r: 20px;
position: absolute;
top: -17px;
padding: .1em .5em;
background: #FA6900;
border-bottom: var(--f) solid #0005;
border-left: var(--r) solid #0000;
clip-path: polygon(0 0,100% 0,100% calc(100% - var(--f)),calc(100% - var(--f)) 100%,
calc(100% - var(--f)) calc(100% - var(--f)),0 calc(100% - var(--f)),
var(--r) calc(50% - var(--f)/2));
right: calc(-1*var(--f));
height: 45px;
display: flex;
align-items: center;
z-index: 1;
}
.corner-offer-container{
position: relative;
padding: 20px 10px 20px 0px !important;
margin-top: 20px;
}
.selectable .corner-offer {
background: ${wideBundle.settings.unselected_message_background_transparency !== '00' ? wideBundle.settings.unselected_message_background_color : wideBundle.settings.border_color};
color: ${wideBundle.settings.color_best_banner};
font-size: ${wideBundle.settings.unselected_custom_fontsize};
${wideBundle.settings.font_unselected_custom_sentence != 'auto' ? 'font-family: ' + wideBundle.settings.font_unselected_custom_sentence + ', Arial, sans-serif;' : ''}
${wideBundle.settings.style_blinking == 'none' ? 'font-style: normal !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_blinking == 'bold' ? 'font-style: normal !important;font-weight: bold !important;' : ''};
${wideBundle.settings.style_blinking == 'italic' ? 'font-style: italic !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_blinking == 'bold-italic' ? 'font-style: italic !important;font-weight: bold !important;' : ''};
}
.selectable.diagonal-offer{
--c: ${wideBundle.settings.unselected_message_background_transparency !== '00' ? wideBundle.settings.unselected_message_background_color : wideBundle.settings.border_color};
color: ${wideBundle.settings.color_best_banner};
}
.selectable.diagonal-offer::before{
font-size: ${wideBundle.settings.unselected_custom_fontsize};
${wideBundle.settings.font_unselected_custom_sentence != 'auto' ? 'font-family: ' + wideBundle.settings.font_unselected_custom_sentence + ', Arial, sans-serif;' : ''}
${wideBundle.settings.style_blinking == 'none' ? 'font-style: normal !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_blinking == 'bold' ? 'font-style: normal !important;font-weight: bold !important;' : ''};
${wideBundle.settings.style_blinking == 'italic' ? 'font-style: italic !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_blinking == 'bold-italic' ? 'font-style: italic !important;font-weight: bold !important;' : ''};
}
.selectedWB .corner-offer {
background: ${wideBundle.settings.message_background_transparency !== '00' ? wideBundle.settings.message_background_color : wideBundle.settings.border_color};
color: ${wideBundle.settings.best_selected_color_banner};
font-size: ${wideBundle.settings.selected_custom_fontsize};
${wideBundle.settings.font_selected_custom_sentence != 'auto' ? 'font-family: ' + wideBundle.settings.font_selected_custom_sentence + ', Arial, sans-serif;' : ''}
${wideBundle.settings.style_blinking_selected == 'none' ? 'font-style: normal !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_blinking_selected == 'bold' ? 'font-style: normal !important;font-weight: bold !important;' : ''};
${wideBundle.settings.style_blinking_selected == 'italic' ? 'font-style: italic !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_blinking_selected == 'bold-italic' ? 'font-style: italic !important;font-weight: bold !important;' : ''};
}
.selectedWB.diagonal-offer{
--c: ${wideBundle.settings.message_background_transparency !== '00' ? wideBundle.settings.message_background_color : wideBundle.settings.border_color};
color: ${wideBundle.settings.best_selected_color_banner};
}
.selectedWB.diagonal-offer::before{
font-size: ${wideBundle.settings.selected_custom_fontsize};
${wideBundle.settings.font_selected_custom_sentence != 'auto' ? 'font-family: ' + wideBundle.settings.font_selected_custom_sentence + ', Arial, sans-serif;' : ''}
${wideBundle.settings.style_blinking_selected == 'none' ? 'font-style: normal !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_blinking_selected == 'bold' ? 'font-style: normal !important;font-weight: bold !important;' : ''};
${wideBundle.settings.style_blinking_selected == 'italic' ? 'font-style: italic !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_blinking_selected == 'bold-italic' ? 'font-style: italic !important;font-weight: bold !important;' : ''};
}
.checkedWB{
display: block;
width: 17px;
height: 17px;
border: 3px solid #f4f4f4;
background-color: #f4f4f4;
border-radius: 50%;
margin-left: 10px;
margin-right: 10px;
}
.thumbnailWB{
width: ${wideBundle.settings.unselected_thumbnail_size == "s" ? "40px" : (wideBundle.settings.unselected_thumbnail_size == "m" ? "60px" : "80px")};
border: 1px solid ${wideBundle.settings.unselected_thumbnail_color};
border-radius: 5px;
${wideBundle.settings.rtl == 1 ? 'margin-left: 10px;' : 'margin-right: 10px;'};
}
.selectedWB .thumbnailWB{
width: ${wideBundle.settings.thumbnail_size == "s" ? "40px" : (wideBundle.settings.thumbnail_size == "m" ? "60px" : "80px")};
border: 1px solid ${wideBundle.settings.thumbnail_color};
}
.value-left{
min-width: 40px;
}
.offer-image{
min-width: ${wideBundle.settings.unselected_thumbnail_size == "s" ? "88px" : (wideBundle.settings.unselected_thumbnail_size == "m" ? "108px" : "128px")};
}
.selectedWB .offer-image{
min-width: ${wideBundle.settings.thumbnail_size == "s" ? "88px" : (wideBundle.settings.thumbnail_size == "m" ? "108px" : "128px")};
}
.value-right{
${wideBundle.settings.rtl == 0 ? 'text-align: left;' : ''};
}
.title-variant{
text-transform: none;
${wideBundle.settings.rtl == 0 ? 'text-align: left;' : ''};
margin: 0;
color: ${wideBundle.settings.offer_color};
}
.best-title-new{
line-height: 1;
color: ${wideBundle.settings.color_best};
transition: opacity 0.5s ease;
font-weight: bold;
}
.price-new-form{
${wideBundle.settings.rtl == 0 ? 'text-align: left;' : ''};
width: auto;
margin: 0px;
margin-bottom: 0px;
}
.hidden-unit{
display: none !important;
}
.first-unit-WB {
margin-right: 5px;
text-align: left;
width: auto;
margin: 0px;
margin-bottom: 0px;
}
.selectedWB .first-unit-WB {
font-size: ${wideBundle.settings.selected_price_fontsize};
color: ${wideBundle.settings.price_selected_color} !important;
${wideBundle.settings.style_price_selected == 'none' ? 'font-style: normal !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_price_selected == 'bold' ? 'font-style: normal !important;font-weight: bold !important;' : ''};
${wideBundle.settings.style_price_selected == 'italic' ? 'font-style: italic !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_price_selected == 'bold-italic' ? 'font-style: italic !important;font-weight: bold !important;' : ''};
}
.selectable .first-unit-WB {
font-size: ${wideBundle.settings.unselected_price_fontsize};
color: ${wideBundle.settings.price_color} !important;
${wideBundle.settings.style_price == 'none' ? 'font-style: normal !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_price == 'bold' ? 'font-style: normal !important;font-weight: bold !important;' : ''};
${wideBundle.settings.style_price == 'italic' ? 'font-style: italic !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_price == 'bold-italic' ? 'font-style: italic !important;font-weight: bold !important;' : ''};
}
.wb_unit_text{
font-size: 0.85em;
}
.selectedWB .first-price-WB {
font-size: ${wideBundle.settings.selected_price_fontsize};
}
.selectedWB .second-price-WB {
font-size: ${wideBundle.settings.selected_compare_price_fontsize};
}
.selectable .first-price-WB {
font-size: ${wideBundle.settings.unselected_price_fontsize};
}
.selectable .second-price-WB {
font-size: ${wideBundle.settings.unselected_compare_price_fontsize};
}
span.money.first-price-WB, .first-price-WB{
color: ${wideBundle.settings.price_color} !important;
${wideBundle.settings.rtl == 1 ? 'margin-left: 5px;' : 'margin-right: 5px;'}
}
span.money.second-price-WB, .second-price-WB{
color: ${wideBundle.settings.price_compared_color} !important;
text-decoration: line-through !important;
}
.crossed-price-WB{
color: inherit;
text-decoration: line-through !important;
}
.doubly.second-price-WB, .money.second-price-WB{
color: ${wideBundle.settings.price_compared_color};
text-decoration: line-through !important;
}
.spinWB{
display: flex;
width: 80px;
margin-top: 20px;
display: none;
margin-bottom: 20px;
flex: 0 0 80px;
margin-left: auto;
}
.quantity-wb-less{
border-radius: 4px 0px 0px 4px;
background-color: ${wideBundle.settings.bg_button_quantity};
color: ${wideBundle.settings.color_button_quantity};
border: 1px solid #dadada;
display: inline-block;
width: 33%;
padding-top:0px;
padding-bottom:0px;
text-align: center;
cursor: pointer;
vertical-align: 1.5px;
}
.quantity-wb-more{
border-radius:0px 4px 4px 0px;
background-color: ${wideBundle.settings.bg_button_quantity};
color: ${wideBundle.settings.color_button_quantity};
border: 1px solid #dadada;
display: inline-block;
width: 33%;
padding-top:0px;
padding-bottom:0px;
text-align: center;
cursor: pointer;
vertical-align: 1.5px;
}
#new-form .quantity-wb-input, .new-wb-form .quantity-wb-input{
-webkit-appearance: none;
-moz-appearance: none;
background-color: ${wideBundle.settings.bg_input_quantity};
color: ${wideBundle.settings.color_input_quantity};
appearance: none;
width: 34%;
text-align: center;
font-weight: bold;
border: 1px solid #dadada;
border-left: 0;
border-right: 0;
padding-left:0px;
padding-right:0px;
padding-top: 0px;
padding-bottom: 0px;
align-self: stretch;
box-sizing: border-box;
}
.div-select2:first-of-type{
margin-top: 10px;
}
#new-form .select-option-third, .new-wb-form .select-option-third{
margin:0;
line-height:23px;
position:static;
opacity:1;
display:block;
background-position: right 10px center !important;
border-radius:3px;
border: 1px solid ${wideBundle.settings.border_color};
font-size:16px;
${wideBundle.settings.rtl == 1 ? 'float:right;' : 'float:left;'}
min-width:100px;
max-width:auto;
width:auto;
min-height:25px;
height:25px;
padding:0;
padding-left:3px;
${wideBundle.settings.rtl == 1 ? 'padding-right:3px;' : 'padding-right:25px;'}
${wideBundle.settings.rtl == 1 ? 'margin-right:5px;' : 'margin-left:5px;'}
color:black;
}
#new-form .select-option-second, .new-wb-form .select-option-second{
line-height:23px;
position:static;
opacity:1;
display:block;
background-position: right 10px center !important;
border-radius:3px;
border: 1px solid ${wideBundle.settings.border_color};
font-size:16px;
${wideBundle.settings.rtl == 1 ? 'float:right;' : 'float:left;'}
min-width:100px;
max-width:auto;
width:auto;
min-height:25px;
height:25px;
padding:0;
padding-left:3px;
${wideBundle.settings.rtl == 1 ? 'padding-right:3px;' : 'padding-right:25px;'}
margin:0;
${wideBundle.settings.rtl == 1 ? 'padding-right:3px;' : 'padding-right:25px;'}
color:black;
}
#new-form .wb-swatch-container .select-option-third, .new-wb-form .wb-swatch-container .select-option-third{
margin-left: 0px;
}
#new-form .pretty-select, .new-wb-form .pretty-select{
padding: 0px 0px 0px 0px;
}
#new-form .disclosure .disclosure__toggle svg, .pretty-select svg, .new-wb-form .disclosure .disclosure__togle svg{
display: none;
}
.title-option-wb{
color: ${wideBundle.settings.option_color};
font-size: ${wideBundle.settings.option_fontsize};
margin:0;
margin-top:3px;
${wideBundle.settings.rtl == 1 ? 'margin-left:5px;' : 'margin-right:5px;'}
margin-bottom:10px;
${wideBundle.settings.rtl == 1 ? 'float:right;' : 'float:left;'}
}
.clear{
margin:0;
clear:both;
margin-top: 0px !important;
margin-bottom: 0px !important;
}
.economic-wb{
margin-top: 0px;
margin-bottom: 0px;
color: ${wideBundle.settings.economic_color};
}
#new-form-atc, .new-form-atc{
width: 100%;
cursor: pointer;
background-color: ${wideBundle.settings.atc_background};
color: ${wideBundle.settings.atc_color};
border-radius: ${wideBundle.settings.atc_radius};
text-align: center;
font-size: ${wideBundle.settings.atc_font_size};
margin-top: 10px;
margin-bottom: 15px;
${wideBundle.settings.atc_size == 'small' ? 'padding: 10px 0 10px 0;' : ''}
${wideBundle.settings.atc_size == 'medium' ? 'padding: 20px 0 20px 0;' : ''}
${wideBundle.settings.atc_size == 'large' ? 'padding: 30px 0 30px 0;' : ''}
font-weight: bold;
display: flex;
align-items: center;
justify-content: center;
${wideBundle.settings.atc_font != 'auto' ? 'font-family: ' + wideBundle.settings.atc_font : ''}
}
#new-form-atc:hover, .new-form-atc:hover{
background-color: ${wideBundle.settings.hover_color};
}
.before-code-wb{
margin-top: 10px;
}
#new-form .selectable, .new-wb-form .selectable{
background-color: ${wideBundle.settings.unselected_background_color + wideBundle.settings.unselected_background_transparency};
border: ${wideBundle.settings.unselected_border_size} solid ${wideBundle.settings.unselected_border_color};
font-weight: normal;
}
.selectable span.money.first-price-WB, .selectable .first-price-WB{
color: ${wideBundle.settings.price_color} !important;
}
.selectable span.money.second-price-WB, .selectable .second-price-WB{
color: ${wideBundle.settings.price_compared_color} !important
}
.selectable .best-title{
color: ${wideBundle.settings.color_best};
border: ${wideBundle.settings.unselected_message_border_size} solid ${wideBundle.settings.unselected_message_border_color};
border-radius: ${wideBundle.settings.unselected_message_border_radius};
background-color: ${wideBundle.settings.unselected_message_background_color + wideBundle.settings.unselected_message_background_transparency};
${wideBundle.settings.unselected_message_background_transparency !== '00' || wideBundle.settings.unselected_message_border_size !== '0px' ? 'margin: 3px 0px; padding: 3px 5px;' : ''};
display: inline-block;
width: 100%;
${wideBundle.settings.unselected_message_background_transparency !== '00' || wideBundle.settings.unselected_message_border_size !== '0px' ? 'width: auto;' : ''};
font-size: ${wideBundle.settings.unselected_custom_fontsize};
${wideBundle.settings.font_unselected_custom_sentence != 'auto' ? 'font-family: ' + wideBundle.settings.font_unselected_custom_sentence + ', Arial, sans-serif;' : ''}
}
.selectable .checkedWB{
background-color: #f4f4f4;
}
.selectable .div-select2{
display: none;
visibility: hidden;
}
.selectable .spinWB{
display: none;
}
.selectable .money{
font-weight: normal !important;
}
#new-form .selectedWB, .new-wb-form .selectedWB{
background-color: ${wideBundle.settings.background_color};
border: ${wideBundle.settings.border_size} solid ${wideBundle.settings.border_color};
font-weight: bold;
}
.selectedWB .title-variant{
color: ${wideBundle.settings.offer_selected_color};
font-size: ${wideBundle.settings.selected_title_fontsize};
${wideBundle.settings.style_title_selected == 'none' ? 'font-style: normal !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_title_selected == 'bold' ? 'font-style: normal !important;font-weight: bold !important;' : ''};
${wideBundle.settings.style_title_selected == 'italic' ? 'font-style: italic !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_title_selected == 'bold-italic' ? 'font-style: italic !important;font-weight: bold !important;' : ''};
}
.selectedWB span.money.first-price-WB, .selectedWB .first-price-WB{
color: ${wideBundle.settings.price_selected_color} !important;
${wideBundle.settings.style_price_selected == 'none' ? 'font-style: normal !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_price_selected == 'bold' ? 'font-style: normal !important;font-weight: bold !important;' : ''};
${wideBundle.settings.style_price_selected == 'italic' ? 'font-style: italic !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_price_selected == 'bold-italic' ? 'font-style: italic !important;font-weight: bold !important;' : ''};
}
.selectedWB span.money.second-price-WB, .selectedWB .second-price-WB{
color: ${wideBundle.settings.price_compared_selected_color} !important;
${wideBundle.settings.style_compared_price_selected == 'none' ? 'font-style: normal !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_compared_price_selected == 'bold' ? 'font-style: normal !important;font-weight: bold !important;' : ''};
${wideBundle.settings.style_compared_price_selected == 'italic' ? 'font-style: italic !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_compared_price_selected == 'bold-italic' ? 'font-style: italic !important;font-weight: bold !important;' : ''};
}
.selectedWB .economic-wb{
color: ${wideBundle.settings.economic_selected_color};
font-size: ${wideBundle.settings.selected_savings_fontsize};
${wideBundle.settings.style_economic_selected == 'none' ? 'font-style: normal !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_economic_selected == 'bold' ? 'font-style: normal !important;font-weight: bold !important;' : ''};
${wideBundle.settings.style_economic_selected == 'italic' ? 'font-style: italic !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_economic_selected == 'bold-italic' ? 'font-style: italic !important;font-weight: bold !important;' : ''};
}
.selectedWB .best-title{
color: ${wideBundle.settings.best_selected_color};
border: ${wideBundle.settings.message_border_size} solid ${wideBundle.settings.message_border_color};
border-radius: ${wideBundle.settings.message_border_radius};
background-color: ${wideBundle.settings.message_background_color + wideBundle.settings.message_background_transparency};
${wideBundle.settings.message_background_transparency !== '00' || wideBundle.settings.message_border_size !== '0px' ? 'margin: 3px 0px; padding: 3px 5px;' : ''};
display: inline-block;
width: 100%;
${wideBundle.settings.unselected_message_background_transparency !== '00' || wideBundle.settings.unselected_message_border_size !== '0px' ? 'width: auto;' : ''};
font-size: ${wideBundle.settings.selected_custom_fontsize};
${wideBundle.settings.font_selected_custom_sentence != 'auto' ? 'font-family: ' + wideBundle.settings.font_selected_custom_sentence + ', Arial, sans-serif;' : ''}
}
.selectedWB .checkedWB{
background-color: ${wideBundle.settings.border_color};
}
.selectedWB .best-title-new{
${wideBundle.settings.style_blinking_selected == 'none' ? 'font-style: normal !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_blinking_selected == 'bold' ? 'font-style: normal !important;font-weight: bold !important;' : ''};
${wideBundle.settings.style_blinking_selected == 'italic' ? 'font-style: italic !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_blinking_selected == 'bold-italic' ? 'font-style: italic !important;font-weight: bold !important;' : ''};
}
.selectedWB .span-economic-wb{
${wideBundle.settings.style_economic_selected == 'none' ? 'font-style: normal !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_economic_selected == 'bold' ? 'font-style: normal !important;font-weight: bold !important;' : ''};
${wideBundle.settings.style_economic_selected == 'italic' ? 'font-style: italic !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_economic_selected == 'bold-italic' ? 'font-style: italic !important;font-weight: bold !important;' : ''};
}
.selectedWB .div-select2{
${wideBundle.settings.style_variants_selected == 'none' ? 'font-style: normal !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_variants_selected == 'bold' ? 'font-style: normal !important;font-weight: bold !important;' : ''};
${wideBundle.settings.style_variants_selected == 'italic' ? 'font-style: italic !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_variants_selected == 'bold-italic' ? 'font-style: italic !important;font-weight: bold !important;' : ''};
}
.selectable .best-title-new{
${wideBundle.settings.style_blinking == 'none' ? 'font-style: normal !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_blinking == 'bold' ? 'font-style: normal !important;font-weight: bold !important;' : ''};
${wideBundle.settings.style_blinking == 'italic' ? 'font-style: italic !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_blinking == 'bold-italic' ? 'font-style: italic !important;font-weight: bold !important;' : ''};
}
.selectable .span-economic-wb{
${wideBundle.settings.style_economic == 'none' ? 'font-style: normal !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_economic == 'bold' ? 'font-style: normal !important;font-weight: bold !important;' : ''};
${wideBundle.settings.style_economic == 'italic' ? 'font-style: italic !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_economic == 'bold-italic' ? 'font-style: italic !important;font-weight: bold !important;' : ''};
}
.selectable .div-select2{
${wideBundle.settings.style_variants == 'none' ? 'font-style: normal !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_variants == 'bold' ? 'font-style: normal !important;font-weight: bold !important;' : ''};
${wideBundle.settings.style_variants == 'italic' ? 'font-style: italic !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_variants == 'bold-italic' ? 'font-style: italic !important;font-weight: bold !important;' : ''};
}
.selectable .title-variant{
color: ${wideBundle.settings.offer_color};
font-size: ${wideBundle.settings.unselected_title_fontsize};
${wideBundle.settings.style_title == 'none' ? 'font-style: normal !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_title == 'bold' ? 'font-style: normal !important;font-weight: bold !important;' : ''};
${wideBundle.settings.style_title == 'italic' ? 'font-style: italic !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_title == 'bold-italic' ? 'font-style: italic !important;font-weight: bold !important;' : ''};
}
.selectable span.money.first-price-WB, .selectable .first-price-WB{
${wideBundle.settings.style_price == 'none' ? 'font-style: normal !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_price == 'bold' ? 'font-style: normal !important;font-weight: bold !important;' : ''};
${wideBundle.settings.style_price == 'italic' ? 'font-style: italic !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_price == 'bold-italic' ? 'font-style: italic !important;font-weight: bold !important;' : ''};
}
.selectable span.money.second-price-WB, .selectable .second-price-WB{
${wideBundle.settings.style_compared_price == 'none' ? 'font-style: normal !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_compared_price == 'bold' ? 'font-style: normal !important;font-weight: bold !important;' : ''};
${wideBundle.settings.style_compared_price == 'italic' ? 'font-style: italic !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_compared_price == 'bold-italic' ? 'font-style: italic !important;font-weight: bold !important;' : ''};
}
.selectable .economic-wb{
font-size: ${wideBundle.settings.unselected_savings_fontsize};
${wideBundle.settings.style_economic == 'none' ? 'font-style: normal !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_economic == 'bold' ? 'font-style: normal !important;font-weight: bold !important;' : ''};
${wideBundle.settings.style_economic == 'italic' ? 'font-style: italic !important;font-weight: normal !important;' : ''};
${wideBundle.settings.style_economic == 'bold-italic' ? 'font-style: italic !important;font-weight: bold !important;' : ''};
}
.selectedWB .spinWB{
display: flex;
}
.selectedWB .spinWB span{
display: flex;
justify-content: center;
align-items: center;
}
.selectedWB select.select-bundle.select-class-second {
color: ${wideBundle.settings.option_select_color} !important;
${wideBundle.settings.option_select_default_settings == 1 ? '' : 'background: ' + wideBundle.settings.option_select_background + '!important'};
}
.hide-bloc-wb{
display: none !important;
}
#new-form .loading-wb, .new-wb-form .loading-wb{
width: 20px;
height: 20px;
}
#cont-trustbadge-wb, .cont-trustbadge-wb{
text-align: center;
width: 80%;
margin: auto;
}
#cont-trustbadge-wb img, .cont-trustbadge-wb img{
width: 100%;
}
#after-code-wb{
margin-top: 10px;
}
#new-form p:empty, .new-wb-form p:empty{
display: block;
}
.d-flex.form-wb-selected{
display: none !important;
}
.new-form-atc--out-of-stock,
.new-form-atc--out-of-stock[style] {
animation: none !important;
-webkit-animation: none !important;
opacity: 0.5 !important;
}
.new-form-atc--out-of-stock svg,
.new-form-atc--out-of-stock[style] svg {
display: none!important;
}
#new-form .widebundle_error, .new-wb-form .widebundle_error{
color: #cc0000;
text-align: center;
background-color: #ffecec;
padding: 10px;
border: 1px solid #cc0000;
border-radius: 5px;
opacity: 0;
transform: translateY(100%);
transition: opacity 0.5s ease-in-out, transform 0.5s ease-in-out;
font-size: 14px !important;
font-family: Helvetica !important;
width: 100%;
}
#new-form .widebundle_error.visible, .new-wb-form .widebundle_error.visible {
opacity: 1;
transform: translateY(0);
}
#new-form .widebundle_error a, .new-wb-form .widebundle_error a{
color: #cc0000 !important;
text-decoration: underline !important;
}
.widebundle_error svg{
vertical-align: -10%;
display: inline-block
}
.wb-color-swatch-box {
display: flex;
flex-wrap: wrap;
gap: 2px;
// margin: 0 20px 10px 0;
}
.wb-color-swatch > input {
visibility: hidden;
position: absolute !important;
}
.wb-color-swatch > input + .wb-color-swatch-radio {
cursor:pointer;
border: 1px solid #ffffff;
outline: 2px solid #c1c1c1;
}
.wb-color-swatch > input:checked + .wb-color-swatch-radio {
border: 1px solid #ffffff;
outline: 2px solid ${wideBundle.settings.border_color};
}
.wb-color-swatch-radio {
display: flex !important;
position: relative;
width: 22px;
height: 22px;
margin: 2px;
background: #ffffff;
border: 1px solid #ffffff;
outline: 1px solid #c1c1c1;
border-radius: 100%;
background-size: 100% 100%;
background-position: center;
box-sizing: border-box;
}
.wb-color-swatch-radio:after {
content: "";
position: absolute;
left: -3px;
top: -3px;
width: 26px;
height: 26px;
background: #e0e0e0;
border-radius: 100%;
box-sizing: border-box;
z-index: -1;
}
.wb-swatch-container .title-option-wb {
width: 100%;
margin: 0;
}
.wb-swatch-container {
display: flex;
flex-wrap: wrap;
gap:6px 15px;
margin-bottom: 10px;
}
.swatch-3-select,
.swatch-2-select {
display: none !important;
}
`;
addStyleToPage(mainStyle, attribute);
}
//Add the style based on structure used
wideBundle.addStructureStyle = function (attribute = '') {
if(document.querySelector('.block-settings') !== null){
var structure = wideBundle.settings.design_code; //Layout chosen
}
else{
var structure = wideBundle.settings.plan == "monthly" && wideBundle.settings.design_code > 3 ? 0 : wideBundle.settings.design_code; //Layout chosen
}
if (structure == 0) { //For basic and default design
if (wideBundle.settings.display_quantity == 1) { //Add style for quantity button if enabled
var style = `
.value-left .offer-image{
min-width: ${wideBundle.settings.unselected_thumbnail_size == "s" ? "90px" : (wideBundle.settings.unselected_thumbnail_size == "m" ? "110px" : "130px")} !important;;
}
.selectedWB .offer-image{
min-width: ${wideBundle.settings.thumbnail_size == "s" ? "90px" : (wideBundle.settings.thumbnail_size == "m" ? "110px" : "130px")} !important;;
}
.selectedWB{
position: relative;
padding-bottom: 10px;
}
.spinWB{
position: static;
height: 30px;
right: 5px;
bottom: 5px;
margin: 0px;
margin-left: auto;
}
.quantity-wb-input{
height: 30px;
}
.selectable{
padding-bottom: 10px;
}
@media screen and (max-width: 400px){
.selectedWB{
position: relative;
padding-bottom: 40px;
}
.spinWB{
position: absolute;
height: 25px;
right: 5px;
bottom: 5px;
margin: 0px;
}
.quantity-wb-input{
height: 25px;
}
}
`;
addStyleToPage(style, attribute);
}
}
else if (structure == 1) { //For vertical layout
var style = `
.title-variant{
text-align: center;
margin-top: 10px;
}
.selectedWB .title-variant{
font-size: ${(parseFloat(wideBundle.settings.selected_title_fontsize) -0.2) + 'em' };
}
.selectable .title-variant{
font-size: ${(parseFloat(wideBundle.settings.unselected_title_fontsize) -0.2) + 'em' };
}
.new-form-option .first-unit-WB{
margin-left: auto;
margin-bottom: 0px;
padding-left: 10px;
text-align: center;
display: flex;
flex-direction: column;
}
.price-new-form, .first-unit-WB{
//font-size: ${wideBundle.settings.price_size};
text-align: center;
}
.best-title{
width: 100%;
text-align: center;
display: block;
margin-top: 10px;
}
.economic-wb{
text-align: center;
}
.selectedWB .economic-wb{
font-size: ${(parseFloat(wideBundle.settings.selected_savings_fontsize) -0.1) + 'em' };
}
.selectable .economic-wb{
font-size: ${(parseFloat(wideBundle.settings.unselected_savings_fontsize) -0.1) + 'em' };
}
.p-title-WB{
width: 100%;
flex-basis: 100%;
}
#new-form, .new-wb-form{
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.new-form-option{
display: block;
padding: 10px 10px 10px 10px;
margin: 7px;
flex: 1;
}
.value-right{
max-width: 100%;
}
.value-left{
display: block;
}
.value-left img{
margin: 0;
}
.checkedWB{
margin: auto;
margin-top: 5px;
margin-bottom: 10px;
}
#new-form .select-class-second, .new-wb-form .select-class-second{
margin: 2px 0px 0px 0px;
}
.selectedWB .div-select2{
display: flex;
flex-direction: column;
align-items: center;
margin-bottom: 5px;
justify-content: center;
}
.selectedWB .div-select2 p{
margin-top: 7px;
margin-bottom: 3px;
}
.selectable{
border: ${wideBundle.settings.unselected_border_size} solid ${wideBundle.settings.unselected_border_color};
}
.new-form-option .value-left{
flex-direction: column;
}
.wb-swatch-container .title-option-wb {
text-align: center;
}
.wb-swatch-container .wb-color-swatch-box {
margin-right: 0;
justify-content: center;
}
`;
if (wideBundle.settings.display_quantity == 1) {
style += `
.selectedWB{
position: relative;
padding-bottom: 5px;
}
.selectedWB .spinWB{
position: static;
height: 30px;
right: 5px;
bottom: 5px;
margin: auto;
margin-top: 10px;
}
.selectedWB .quantity-wb-input{
height: 30px;
line-height: 30px;
}
.selectable{
padding-bottom: 5px;
}
`;
}
addStyleToPage(style, attribute);
}
else if (structure == 2) { //For minimalist layout
var style = `
.thumbnailWB{
width: ${wideBundle.settings.unselected_thumbnail_size == "s" ? "30px" : (wideBundle.settings.unselected_thumbnail_size == "m" ? "40px" : "50px")} !important;
}
.selectedWB .thumbnailWB{
width: ${wideBundle.settings.thumbnail_size == "s" ? "30px" : (wideBundle.settings.thumbnail_size == "m" ? "40px" : "50px")} !important;
}
.offer-image{
min-width: ${wideBundle.settings.unselected_thumbnail_size == "s" ? "78px" : (wideBundle.settings.unselected_thumbnail_size == "m" ? "88px" : "98px")} !important;
}
.selectedWB .offer-image{
min-width: ${wideBundle.settings.thumbnail_size == "s" ? "78px" : (wideBundle.settings.thumbnail_size == "m" ? "88px" : "98px")} !important;
}
.new-form-option{
position: relative;
padding: 5px 10px 5px 0px;
}
.selectedWB .title-variant{
font-size: ${(parseFloat(wideBundle.settings.selected_title_fontsize) -0.2) + 'em' };
}
.selectable .title-variant{
font-size: ${(parseFloat(wideBundle.settings.unselected_title_fontsize) -0.2) + 'em' };
}
.new-form-option .price-new-form, .new-form-option .first-unit-WB{
${wideBundle.settings.rtl == 1 ? 'margin-right: auto;' : 'margin-left: auto;'}
${wideBundle.settings.rtl == 1 ? 'text-align: left;' : 'text-align: right;'}
margin-bottom: 0px;
padding-left: 10px;
${wideBundle.settings.rtl == 1 ? 'padding-right: 10px;' : ''}
}
.new-form-option .first-unit-WB{
text-align: center;
display: flex;
flex-direction: column;
}
.economic-wb{
margin-top: 0px;
margin-bottom: 0px;
}
span.money.first-price-WB, .first-price-WB{
margin-right: 0px;
white-space: nowrap;
overflow: hidden;
}
span.money.second-price-WB, .second-price-WB{
margin-left: 5px;
white-space: nowrap;
overflow:hidden;
}
.div-select2{
margin-top: 5px;
}
.checkedWB{
width: 12px;
height: 12px;
border: 2px solid rgb(244, 244, 244);
}
.title-option-wb{
margin-bottom: 0px;
}
.diagonal-offer{
padding-right: 40px !important;
}
@media screen and (max-width: 600px){
.title-option-wb{
width: 100%;
margin-bottom: 0px;
}
.thumbnailWB{
width: ${wideBundle.settings.unselected_thumbnail_size == "s" ? "30px" : (wideBundle.settings.unselected_thumbnail_size == "m" ? "40px" : "40px")} !important;
}
.selectedWB .thumbnailWB{
width: ${wideBundle.settings.thumbnail_size == "s" ? "30px" : (wideBundle.settings.thumbnail_size == "m" ? "40px" : "40px")} !important;
}
.offer-image{
min-width: ${wideBundle.settings.unselected_thumbnail_size == "s" ? "78px" : (wideBundle.settings.unselected_thumbnail_size == "m" ? "88px" : "88px")} !important;
}
.selectedWB .offer-image{
min-width: ${wideBundle.settings.thumbnail_size == "s" ? "78px" : (wideBundle.settings.thumbnail_size == "m" ? "88px" : "88px")} !important;
}
}
@media screen and (max-width: 400px){
#new-form .select-option-third, .new-wb-form .select-option-third{
margin-top: 2px;
margin-left: 0px;
}
#new-form .select-option-second, .new-wb-form .select-option-second{
float: none;
}
}
`;
if (wideBundle.settings.display_quantity == 1) {
style += `
.spinWB{
margin-top: 5px;
margin-bottom: 5px;
margin-left: 10px;
}
.selectedWB{
position: relative;
padding-bottom: 5px;
}
.selectedWB .spinWB{
position: static;
height: 30px;
right: 5px;
bottom: 5px;
margin: 0px;
margin-left: 5px;
}
.selectedWB .quantity-wb-input{
height: 30px;
}
.selectable{
padding-bottom: 5px;
}
@media screen and (max-width: 400px){
.selectedWB{
position: relative;
padding-bottom: 40px;
}
.selectedWB .spinWB{
position: absolute;
height: 25px;
right: 5px;
bottom: 5px;
}
.selectedWB .quantity-wb-input{
height: 25px;
}
}
`;
}
//We hve to move the price and quantity to the right of the offer for that layout
var elemsUnit = document.querySelectorAll('.new-form-option .first-unit-WB');
for (var i = 0; i < elemsUnit.length; i++) {
offerNode = elemsUnit[i].parentNode.parentNode;
offerNode.appendChild(elemsUnit[i]);
}
var elems = document.querySelectorAll('.new-form-option .price-new-form');
for (var i = 0; i < elems.length; i++) {
offerNode = elems[i].parentNode.parentNode;
offerNode.appendChild(elems[i]);
if (wideBundle.settings.display_quantity == 1) {
quantityElem = document.querySelectorAll('.spinWB')[i];
offerNode.appendChild(quantityElem);
}
}
addStyleToPage(style, attribute);
}
else if (structure == 3) { //For royal layout
var style = `
.new-form-option .price-new-form, .new-form-option .first-unit-WB{
${wideBundle.settings.rtl == 1 ? 'margin-right: auto;' : 'margin-left: auto;'}
${wideBundle.settings.rtl == 1 ? 'text-align: left;' : 'text-align: right;'}
margin-bottom: 0px;
padding-left: 10px;
${wideBundle.settings.rtl == 1 ? 'padding-right: 10px;' : ''}
}
.new-form-option .first-unit-WB{
text-align: center;
display: flex;
flex-direction: column;
}
span.money.first-price-WB, .first-price-WB{
margin-right: 0px;
white-space: nowrap;
overflow: hidden;
}
span.money.second-price-WB, .second-price-WB{
margin-left: 5px;
white-space: nowrap;
overflow: hidden;
}
.new-form-option{
position: relative;
padding: 5px 10px 5px 0px;
}
.with-message .div-select2{
margin-top: 10px;
}
.with-message .title-variant{
margin-bottom: -5px;
}
.economic-wb{
margin-top: 0px;
margin-bottom: 0px;
position: absolute;
bottom: 0;
left: 50%;
transform: translate(-50%, 50%);
background-color: ${wideBundle.settings.border_color};
padding: 3px 40px 3px 40px;
border-radius: 5px;
white-space: nowrap;
overflow: hidden;
}
.with-economic-text{
padding-bottom: 20px;
margin-bottom: 18px;
}
.value-right.with-message{
padding-bottom: 20px;
}
.diagonal-offer{
padding-right: 40px !important;
}
@media screen and (max-width: 600px){
.title-option-wb{
margin-bottom: 0px;
}
.has-double-select .title-option-wb{
width: 100%;
}
.offer-image img{
width: ${wideBundle.settings.unselected_thumbnail_size == "s" ? "30px" : (wideBundle.settings.unselected_thumbnail_size == "m" ? "40px" : "60px")};
}
.selectedWB .offer-image img{
width: ${wideBundle.settings.thumbnail_size == "s" ? "30px" : (wideBundle.settings.thumbnail_size == "m" ? "40px" : "60px")};
}
.offer-image{
min-width: ${wideBundle.settings.unselected_thumbnail_size == "s" ? "80px" : (wideBundle.settings.unselected_thumbnail_size == "m" ? "90px" : "110px")};
}
.selectedWB .offer-image{
min-width: ${wideBundle.settings.thumbnail_size == "s" ? "80px" : (wideBundle.settings.thumbnail_size == "m" ? "90px" : "110px")};
}
.selectedWB .title-variant{
font-size: ${(parseFloat(wideBundle.settings.selected_title_fontsize) -0.2) + 'em' };
}
.selectable .title-variant{
font-size: ${(parseFloat(wideBundle.settings.unselected_title_fontsize) -0.2) + 'em' };
}
}
@media screen and (max-width: 400px){
#new-form .select-option-third, .new-wb-form .select-option-third{
margin-top: 2px;
margin-left: 0px;
}
#new-form .select-option-second, .new-wb-form .select-option-second{
float: none;
}
}
`;
if (wideBundle.settings.display_quantity == 1) {
style += `
.spinWB{
margin-top: 5px;
margin-bottom: 5px;
margin-left: 10px;
}
.selectedWB{
position: relative;
padding-bottom: 5px;
}
.selectedWB.with-economic-text{
padding-bottom: 20px;
}
.selectedWB .spinWB{
position: static;
height: 30px;
right: 5px;
bottom: 5px;
margin: 0px;
margin-left: 5px;
}
.selectedWB .quantity-wb-input{
height: 30px;
}
.selectable{
padding-bottom: 5px;
}
.selectable.with-economic-text{
padding-bottom: 20px;
}
@media screen and (max-width: 400px){
.selectedWB{
position: relative;
padding-bottom: 40px;
}
.selectedWB.with-economic-text{
padding-bottom: 40px;
}
.selectedWB .spinWB{
position: absolute;
height: 25px;
right: 5px;
bottom: 20px;
}
.selectedWB .quantity-wb-input{
height: 25px;
}
}
`;
}
//We have to move the price and quantity to the right of the offer for that layout
var elemsUnit = document.querySelectorAll('.new-form-option .first-unit-WB');
for (var i = 0; i < elemsUnit.length; i++) {
offerNode = elemsUnit[i].parentNode.parentNode;
offerNode.appendChild(elemsUnit[i]);
}
var elems = document.querySelectorAll('.new-form-option .price-new-form');
for (var i = 0; i < elems.length; i++) {
offerNode = elems[i].parentNode.parentNode;
offerNode.appendChild(elems[i]);
if (wideBundle.settings.display_quantity == 1) {
quantityElem = document.querySelectorAll('.spinWB')[i];
offerNode.appendChild(quantityElem);
}
}
//We have to move the economic price
var elems = document.querySelectorAll('.new-form-option .economic-wb');
for (var i = 0; i < elems.length; i++) {
elems[i].closest('.new-form-option').appendChild(elems[i]);
}
addStyleToPage(style, attribute);
}
else if (structure == 4) { //For elegant layout
var style = `
.new-form-option .price-new-form, .new-form-option .first-unit-WB{
${wideBundle.settings.rtl == 1 ? 'margin-right: auto;' : 'margin-left: auto;'}
${wideBundle.settings.rtl == 1 ? 'text-align: left;' : 'text-align: right;'}
margin-bottom: 0px;
padding-left: 20px;
${wideBundle.settings.rtl == 1 ? 'padding-right: 10px;' : ''}
display: flex;
flex-direction: column;
}
.new-form-option .first-unit-WB{
text-align: center;
display: flex;
flex-direction: column;
}
span.money.first-price-WB, .first-price-WB{
margin-right: 0px;
white-space: nowrap;
overflow: hidden;
}
span.money.second-price-WB, .second-price-WB{
margin-left: 5px;
white-space: nowrap;
overflow: hidden;
}
.new-form-option{
position: relative;
padding: 10px 10px 10px 0px;
margin-bottom: 0px;
border-radius: 0px;
border-top: 0px !important;
border-color: ${wideBundle.settings.border_color} !important;
}
.with-message .div-select2{
margin-top: 10px;
}
.with-message .title-variant{
margin-bottom: -5px;
}
.checkedWB {
box-shadow: 0 0 0 2px ${wideBundle.settings.border_color};
border: 2px solid #f4f4f4;
border-radius: 5px;
width: 15px;
height: 15px;
}
.economic-wb{
position: absolute;
bottom: 0;
right: 0;
border-top-left-radius: 5px;
background-color: ${wideBundle.settings.border_color};
padding: 3px 40px 3px 40px;
white-space: nowrap;
overflow: hidden;
}
.selectable .economic-wb {
padding: ${parseInt(wideBundle.settings.unselected_border_size) + 3}px 8px 3px ${parseInt(wideBundle.settings.unselected_border_size) + 8}px;
}
.selectedWB .economic-wb {
padding: ${parseInt(wideBundle.settings.border_size) + 3}px 8px 3px ${parseInt(wideBundle.settings.border_size) + 8}px;
}
.selectable.with-economic-text{
padding-bottom: ${(parseInt(wideBundle.settings.unselected_border_size) / 2) + 30}px !important;
}
.selectedWB.with-economic-text{
padding-bottom: ${(parseInt(wideBundle.settings.border_size) / 2) + 30}px !important;
}
.p-title-WB{
background-color: ${wideBundle.settings.border_color};
margin: 0px;
padding: 8px 0px;
overflow: unset;
border-radius: 5px 5px 0px 0px;
}
.p-title-WB__content {
${wideBundle.settings.preview_heading_position == 'left' ? 'margin: 0 auto 0 10px;' : ''};
${wideBundle.settings.preview_heading_position == 'center' ? 'margin: 0 auto;' : ''};
${wideBundle.settings.preview_heading_position == 'right' ? 'margin: 0 10px 0 auto;' : ''};
}
.p-title-WB__arrow{
z-index: 1;
}
.p-title-WB__arrow::before{
content: '';
position: absolute;
top: 100%;
left: calc(50% - 10px);
background-color: ${wideBundle.settings.border_color};
width: 20px;
height: 10px;
clip-path: polygon(0 0, 100% 0, 50% 100%);
}
.corner-offer-container{
margin-top: 0px;
}
.diagonal-offer{
padding-right: 40px !important;
}
#new-form-atc, .new-form-atc{
border-radius: 5px;
}
.settings-preview-main-wrapper{
margin-top: 15px !important;
}
.best-title{
display: inline-block;
}
@media screen and (max-width: 600px){
.title-option-wb{
margin-bottom: 0px;
}
.has-double-select .title-option-wb{
width: 100%;
}
.offer-image img{
width: ${wideBundle.settings.unselected_thumbnail_size == "s" ? "30px" : (wideBundle.settings.unselected_thumbnail_size == "m" ? "40px" : "60px")};
}
.selectedWB .offer-image img{
width: ${wideBundle.settings.thumbnail_size == "s" ? "30px" : (wideBundle.settings.thumbnail_size == "m" ? "40px" : "60px")};
}
.offer-image{
min-width: ${wideBundle.settings.unselected_thumbnail_size == "s" ? "80px" : (wideBundle.settings.unselected_thumbnail_size == "m" ? "90px" : "110px")};
}
.selectedWB .offer-image{
min-width: ${wideBundle.settings.thumbnail_size == "s" ? "80px" : (wideBundle.settings.thumbnail_size == "m" ? "90px" : "110px")};
}
.selectedWB .title-variant{
font-size: ${(parseFloat(wideBundle.settings.selected_title_fontsize) -0.2) + 'em' };
}
.selectable .title-variant{
font-size: ${(parseFloat(wideBundle.settings.unselected_title_fontsize) -0.2) + 'em' };
}
}
@media screen and (max-width: 400px){
.select-option-third{
margin-top: 2px;
margin-left: 0px;
}
.select-option-second{
float: none;
}
}
`;
if (wideBundle.settings.display_quantity == 1) {
style += `
.spinWB{
margin-top: 5px;
margin-bottom: 5px;
margin-left: 10px;
}
.selectedWB{
position: relative;
padding-bottom: 5px;
}
.selectedWB.with-economic-text{
padding-bottom: 20px;
}
.selectedWB .spinWB{
position: static;
height: 30px;
right: 5px;
bottom: 5px;
margin: 0px;
margin-left: 5px;
}
.selectedWB .quantity-wb-input{
height: 30px;
}
.selectable{
padding-bottom: 10px;
}
.selectable.with-economic-text{
padding-bottom: 20px;
}
@media screen and (max-width: 400px){
.selectedWB{
position: relative;
padding-bottom: 40px;
}
.selectedWB.with-economic-text{
padding-bottom: 40px;
}
.selectedWB .spinWB{
position: absolute;
height: 25px;
right: 5px;
bottom: 40px;
}
.selectedWB .quantity-wb-input{
height: 25px;
}
}
`;
}
//We have to move the price and quantity to the right of the offer for that layout
var elemsUnit = document.querySelectorAll('.new-form-option .first-unit-WB');
for (var i = 0; i < elemsUnit.length; i++) {
offerNode = elemsUnit[i].parentNode.parentNode;
offerNode.appendChild(elemsUnit[i]);
}
//We have to move the price and quantity to the right of the offer for that layout
var elems = document.querySelectorAll('.new-form-option .price-new-form');
for (var i = 0; i < elems.length; i++) {
offerNode = elems[i].parentNode.parentNode;
offerNode.appendChild(elems[i]);
if (wideBundle.settings.display_quantity == 1) {
quantityElem = document.querySelectorAll('.spinWB')[i];
offerNode.appendChild(quantityElem);
}
}
//We have to add round corners to last offer for elegant design
var elems = document.querySelectorAll('#new-form, .new-wb-form ');
for (var i = 0; i < elems.length; i++) {
formOffers = elems[i].querySelectorAll(".new-form-option");
lastOffer = formOffers[formOffers.length - 1]
lastOffer.style.borderRadius = '0px 0px 5px 5px';
}
//We have to move the economic price
var elems = document.querySelectorAll('.new-form-option .economic-wb');
for (var i = 0; i < elems.length; i++) {
elems[i].closest('.new-form-option').appendChild(elems[i]);
}
addStyleToPage(style, attribute);
}
else if (structure == 5) { //For solid layout
var style = `
.selectedWB .title-variant{
margin-top: 10px;
font-size: ${(parseFloat(wideBundle.settings.selected_title_fontsize) -0.2) + 'em' };
}
.selectable .title-variant{
margin-top: 10px;
font-size: ${(parseFloat(wideBundle.settings.unselected_title_fontsize) -0.2) + 'em' };
}
.best-title{
width: auto;
display: block;
margin-top: 10px;
}
.economic-wb{
margin: 0px auto;
position: absolute;
background-color: white;
padding: 4px 8px;
overflow: hidden;
//max-width: 80%;
rotate: -3deg;
left: 50%;
transform: translateX(-50%);
white-space: nowrap;
}
.selectable .economic-wb{
bottom: ${-10 - parseInt(wideBundle.settings.unselected_border_size)}px;
border: 3px solid ${wideBundle.settings.background_color};
}
.selectedWB .economic-wb{
bottom: -18px;
border: 3px solid ${wideBundle.settings.background_color};
}
.with-economic-text{
position: relative;
padding-bottom: 20px;
margin-bottom: 18px;
}
.p-title-WB{
width: 100%;
flex-basis: 100%;
}
.selectable.corner-offer-container{
padding-top: 10px !important;
}
.selectedWB.corner-offer-container{
padding-top: 0px !important;
}
#new-form, .new-wb-form{
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.new-form-option{
display: block;
padding: 0px;
margin: 7px 1px;
flex: 1;
border-radius: 0px;
padding-bottom: 30px;
}
.selectedWB .best-title {
width: auto;
}
.value-right{
max-width: 100%;
display: flex;
flex-direction: column;
}
.value-right > *{
margin-right: 10px !important;
margin-left: 10px !important;
}
.value-right .price-new-form, .value-right .first-unit-WB{
margin: 0px !important;
padding-left: 8px;
padding-bottom: 5px;
}
.value-left{
display: block;
}
.value-left img{
margin: 5px 0px;
}
.selectedWB .price-new-form, .selectedWB .first-unit-WB{
margin: 0px 0px 10px 0px !important;
top: 10px;
position: relative;
border-bottom: 1px solid white;
}
.selectedWB .value-left{
top: 10px;
position: relative;
}
.selectable .price-new-form, .selectable .first-unit-WB{
border-bottom: 1px solid ${wideBundle.settings.unselected_border_color};
}
.checkedWB{
display: none;
}
#new-form .select-class-second, .new-wb-form .select-class-second{
margin: 2px 0px 0px 0px;
}
.selectedWB .div-select2{
display: flex;
flex-direction: column;
align-items: flex-start;
margin-bottom: 5px;
justify-content: center;
}
.selectedWB .div-select2 p{
margin-top: 7px;
margin-bottom: 3px;
}
.selectable{
border: ${wideBundle.settings.unselected_border_size} solid ${wideBundle.settings.unselected_border_color};
margin-top: 20px;
}
.selectedWB{
border: 0px !important;
border-bottom: 8px solid ${wideBundle.settings.border_color} !important;
}
.new-form-option .value-left{
flex-direction: column;
}
`;
if (wideBundle.settings.display_quantity == 1) {
style += `
.selectedWB{
position: relative;
}
.selectedWB .spinWB{
position: static;
height: 30px;
right: 5px;
bottom: 5px;
margin: auto;
margin-top: 10px;
}
.selectedWB .quantity-wb-input{
height: 30px;
line-height: 30px;
}
`;
}
//We have to move the price under thumbnail
var elems = document.querySelectorAll('.new-form-option .price-new-form');
for (var i = 0; i < elems.length; i++) {
elems[i].parentNode.insertBefore(elems[i], elems[i].parentNode.firstChild);
}
//We have to move the unit price under thumbnail
var elems = document.querySelectorAll('.new-form-option .first-unit-WB');
for (var i = 0; i < elems.length; i++) {
elems[i].parentNode.insertBefore(elems[i], elems[i].parentNode.firstChild);
}
//We have to move the economic price
var elems = document.querySelectorAll('.new-form-option .economic-wb');
for (var i = 0; i < elems.length; i++) {
elems[i].closest('.new-form-option').appendChild(elems[i]);
}
addStyleToPage(style, attribute);
//We have to add a padding at end of offer depends on economic text height
/*var elems = document.querySelectorAll('.new-form-option .economic-wb');
for (var i = 0; i < elems.length; i++) {
if(elems[i].clientHeight !== 0){
elems[i].parentNode.setAttribute('style', "padding-bottom:" + elems[i].clientHeight + "px !important");
}
if(elems[i].clientWidth !== 0){
elems[i].setAttribute('style', "margin-left: -" + elems[i].offsetWidth /2 + "px !important");
elems[i].style.left = "50%";
}
}*/
}
}
//Declare some variables needed
wideBundle.declareVariables = function(){
wideBundle.locationWebsite = encodeURI(decodeURI(window.location.href));
wideBundle.settings.currency = wideBundle.settings.currency.replace(/<\/?span.*?>/gm, '');
wideBundle.widgetContainers = [];
wideBundle.currencyCodes = {
USD: 'US$',
EUR: '€',
GBP: '£',
AUD: 'AU$',
NZD: 'NZ$',
CAD: 'CA$',
JPY: '¥',
DKK: 'DKK',
NOK: 'NOK',
SEK: 'SEK',
BAM: 'KM',
BGN: 'лв.',
CHF: 'CHF',
DKK: 'kr.',
ILS: '₪',
ISK: 'ISK',
LBP: 'ل.ل',
LRD: 'LRD $',
PLN: 'zł',
RON: 'Lei',
TRY: '₺',
MXN: '$',
HKD: '$',
KRW: '₩',
MYR: 'RM',
SGD: '$',
TWD: '$',
TND: 'د.ت',
EGP: 'ج.م',
DZD: 'دج',
MAD: 'dh',
BRL: 'R$',
CLP: 'CLP',
INR: '₹',
UAE: 'د.إ',
AED: 'د.إ',
ARS: 'ARS',
PEN: 'S/',
SAR: 'SAR',
CNY: '¥',
RUB: '₽',
ZAR: 'R',
IDR: 'Rp',
PHP: '₱',
THB: '฿',
VND: '₫',
KES: 'KSh',
PKR: 'Rs',
EGP: 'EGP',
IQD: 'IQD',
KWD: 'KWD',
OMR: 'OMR',
QAR: 'QAR',
JOD: 'JOD',
LYD: 'LYD',
SYP: 'SYP',
BHD: 'BHD',
JMD: 'JMD',
BDT: 'BDT',
NPR: 'NPR',
LKR: 'LKR',
KHR: 'KHR',
MMK: 'MMK',
LAK: 'LAK',
VEF: 'VEF',
COP: 'COP',
UYU: 'UYU',
PYG: 'PYG',
BOB: 'BOB',
TZS: 'TZS',
GTQ: 'GTQ',
NGN: 'NGN',
MUR: 'MUR',
MGA: 'MGA',
XOF: 'XOF',
RWF: 'RWF',
HUF: 'HUF',
UGX: 'UGX',
TND: 'TND',
SDG: 'SDG',
SLL: 'SLL',
SCR: 'SCR',
PGK: "PGK",
CZK: 'CZK',
UAH: 'UAH'
};
wideBundle.currencySymbols = {
USD: '$',
EUR: '€',
GBP: '£',
AUD: '$',
NZD: '$',
CAD: '$',
JPY: '¥',
DKK: 'kr.',
NOK: 'kr.',
SEK: 'kr.',
BAM: 'KM',
BGN: 'лв.',
CHF: '₣',
ILS: '₪',
ISK: 'kr',
LBP: 'ل.ل',
LRD: '$',
PLN: 'zł',
RON: 'lei',
TRY: '₺',
MXN: '$',
HKD: '$',
KRW: '₩',
MYR: 'RM',
SGD: '$',
TWD: '$',
TND: 'د.ت',
EGP: '£',
DZD: 'د.ج',
MAD: 'د.م.',
BRL: '$',
CLP: '$',
INR: '₹',
UAE: 'د.إ',
AED: 'د.إ',
ARS: '$',
PEN: 'S/.',
SAR: 'ر.س',
CNY: '¥',
RUB: '₽',
ZAR: 'R',
IDR: 'Rp',
PHP: '₱',
THB: '฿',
VND: '₫',
KES: 'KSh',
PKR: '₨',
IQD: 'ع.د',
KWD: 'د.ك',
OMR: 'ر.ع.',
QAR: 'ر.ق',
JOD: 'د.ا',
LYD: 'ل.د',
SYP: 'ل.س',
BHD: 'د.ب',
JMD: '$',
BDT: '৳',
NPR: '₨',
LKR: '₨',
KHR: '៛',
MMK: 'K',
LAK: '₭',
VEF: 'Bs',
COP: '$',
UYU: '$',
PYG: '₲',
BOB: 'Bs',
TZS: 'TSh',
GTQ: 'Q',
NGN: '₦',
MUR: '₨',
MGA: 'Ar',
XOF: 'CFA',
RWF: 'RF',
HUF: 'Ft',
UGX: 'USh',
SDG: '£',
SLL: 'Le',
SCR: '₨',
PGK: 'K',
CZK: 'Kč',
UAH: '₴'
};
}
//Function to detect and get the product form node in the page
wideBundle.getFormNode = function(){
//Don't select the form if the element is the same as one element below
formsSameElementException = [
'.checkout-x-buy-now-btn', '.price-descriptors .shopify-product-form'
];
//Unwanted forms as child/parent/form
wideBundle.formsException = [
".sticky-cart-form", "#form-sticky", ".container-sticky_addtocart", ".sticky-barre-content", "#shopify-section-header",
".product-recommendations-placeholder", ".sticky-atc-title", ".search-form", ".sticky-dropdownvar", "header.site-header", "#popUps .cart_upsell_popup",
"#popUps .cart_downsell_popup", '.product-upsell-holder', '#product-form-installment', '.sticky_addcart', '.product-upsell__holder', '#ShippingModal',
".collection .card-wrapper .card__content", '#featured-product-scroll .product--variant', 'product-sticky-form', '#rio-upsell', '.t4s-product-tabs-wrapper',
'div[data-extraclass="sticky-atc"]', '#shopify-section-pr_description', '.cu-upsell', '#CartDrawer', 'cart-drawer.cart-drawer','#product-form-main-sticky-atc',
'gp-sticky','.pupsdreams_popup_sticky-product-details-container','.product-item--has-quick-add','.related_products', 'mini-cart .minicart-content',
'.dbtfy-sticky-addtocart__bar .dbtfy-sticky-addtocart__container', '.card .dbtfy-collection-addtocart', '.tabs__recommendation quick-add-product .quick-add__holder',
"main .shopify-section > #sticky-add-to-cart", "product-recommendations motion-list .quick-add", ".swiper-wrapper div[class*='ss_shoppable_video']",
".product-recommendations .product-loop .js-product-listing", ".cart-upsell-wrapper #cart-upsell", "section#sticky-atc.fixed-bottom .container",
".product--addtocart--sticky .right-side", "div[id$='__cart-upsell'] .dbtfy-cart-upsell .dbtfy-cart-upsell-item", ".cart-flyout .cart-drawer-products", "#cart-drawer .cart-upselling",
"div[hidden] .dbtfy-upsell-bundles__form-wrapper", ".product-grid-item.carousel__item .product__media__container .product-grid-item__quick-buy"
];
//Elements we want to hide
hidingElements = [
".shg-product-selector-wrapper", ".tt-swatches-container", ".tt-option-block", ".dbtfy-color_swatches", ".pt-swatches-container",
".product-form__item--submit", ".pg__option--single", ".gt_product-swatches.gt_flex.gt_variant_product", ".button_add_to_cart.gt_product-addtocart",
".gt_flex.gt_variant_product"
];
//Forms we want to check
forms = [
".w-commerce-commerceaddtocartform.default-state-2", ".product-form", ".productForm", 'product-form form[data-type="add-to-cart-form"]', ".product-form__buy-buttons .shopify-product-form", ".shopify-product-form", "#addToCartFormId1",
".t4s-product__info-wrapper form.t4s-form__product", "#AddToCartForm--product-template", ".product-form-product-template", ".product-form.hidedropdown", ".addToCartForm", ".product-single__meta .product-single__meta-info .product-single__form", ".ProductForm",
".product-single__form", ".prod_form", "#addToCartForm-product-template-optimised", ".shg-product-atc-btn-wrapper", 'form[data-type="add-to-cart-form"].form', "form[action=\'/cart/add\']",
"#addToCartForm", ".form-vertical", "#prodForm", "form[data-product-form]", "#add-to-cart-form", "form[action$='/cart/add']", ".product-single__form:nth-child(2)"
];
allForms = 0
forms.forEach(form => {
allForms += document.querySelectorAll(form).length;
})
//To detect and get the product form node in the page
form:
for(var i=0; i < forms.length; i++){
formLength = document.querySelectorAll(forms[i]).length;
console.log("form length: " + formLength + " for: " + forms[i]);
//For all the forms found in the page
formNumber:
for(let j=0; j= 2 || childElementsWB.length == 0 || form.tagName == "BUTTON") ){
console.log('form is another exception');
continue formNumber;
}
//If form exists and has passed the exceptions then we can choose it to display the Widget
if(form !== 'undefined' && form != null){
console.log("chosen form:" + formID);
return {
element: form,
id: formID
}
}
}
}
};
console.log('form not found');
return {
element: null,
id: null
};
}
//Function to detect and get the price node below the title in the page
wideBundle.getPriceNode = function(){
updatePrice = wideBundle.settings.update_price;
//Don't do anything if the user doesn't want to update price design
if(updatePrice == 0){
var priceID = 'not checked';
var http = new XMLHttpRequest();
var url = wideBundle.domain+'AJAX/GetPrice.php';
var params = 'price='+priceID+'&shop='+wideBundle.shop;
http.open('POST', url, true);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.send(params);
return {
element: [],
id: null
};
}
//Selectors for price nodes
pricesWB = [
".product-item-caption-price", ".ProductMeta__PriceList", "#price_ppr", ".product-single__prices", ".product-featured__price-text", ".product__price",
".gf_product-prices", "#productPrice-product-template", ".productTemplatePrice", ".product-price", "div[data-product-type=price]", ".modal_price",
".featured-product-section .product-single .box .product-wrapper .product-details .product-single__meta .price-wrapper", ":not(.wb_hidden_prices_element) .price", ".product-meta h1",
".price-wrapper", ".product-single__meta .product-single__meta-list", ".product-single__price", ".tt-price", ".gt_flex.price_product", ".pt-price", ".gt-product-price", 'span[data-zp-product-discount-price]',
'.t4s-product-price', '.z-main-product__price', '.product-single__price--on-sale'
];
//We don't want the price to be updated in these selectors
pricesExceptionWB = [
".upsells .upsell-info", "#new-form", ".new-wb-form", "#mini-cart", '[id^="cross-sell-"]', "#CollectionSection", "#CartDrawer-CartItems",
".section--products-recommendations", '.featured-collections'
];
//Specific blocs to get prices
blocsToGetPricesWB = [
".featured_product_se"
];
//Get the price node from selectors list
priceWB:
for(var i=0; i < pricesWB.length; i++){
//Find the price node in specific blocs
for(var x=0; x !isDescendant(allExcepClassPrices[z], element));
}
}
if(!price.length){
continue priceWB;
}
console.log("price " + pricesWB[i] + " found:");
console.log(price);
return {
element: price,
id: pricesWB[i]
}
}
}
console.log("No price found");
return {
element: [],
id: null
};
}
//Function to hide prices that are duplicated or unwanted when we update the price design under the title
wideBundle.hideUnwantedPrices = function(){
var productSinglePriceWrapper = document.querySelector('.product-single__price--wrapper');
if (productSinglePriceWrapper) {
productSinglePriceWrapper.style.display = 'none';
}
var productPrice = document.getElementById('ProductPrice');
var comparePrice = document.getElementById('ComparePrice');
var priceNode = document.querySelector('.price');
if (productPrice && comparePrice && !priceNode) {
//wideBundle.priceInfo.element[0].style.display = "none";
var salePrice = document.querySelector('.sale_price');
var price = document.querySelector('.price');
if (price && price.innerHTML.trim() == '' && salePrice) {
productPrice.style.display = 'none';
comparePrice.style.display = 'none';
comparePrice.style.fontSize = '0px';
productPrice.style.Size = '0px';
salePrice.style.display = 'none';
}
}
if(wideBundle.priceInfo.element.length > 0){
if(wideBundle.priceInfo.id == ".product-single__price--on-sale"){
let compareAtPriceToHide = document.querySelector('.product-single__price--compare-at');
if(compareAtPriceToHide){
compareAtPriceToHide.style.display = "none";
}
}
}
var productPriceCompare = document.querySelectorAll('.product__price--compare');
for (var i = 0; i < productPriceCompare.length; i++) {
productPriceCompare[i].style.display = 'none';
}
if(wideBundle.priceInfo.id == ".gt-product-price"){
var gtProductComparePrice = document.querySelectorAll(".gt-product-compare-price");
if (gtProductComparePrice[0]) {
gtProductComparePrice[0].style.display = "none";
}
}
var productAction = document.querySelector('.product-action');
if (productAction) {
productAction.style.display = 'none';
}
var compareAtPrice = document.querySelector('div[data-product-type="compare_at_price"][data-pf-type="ProductPrice"]');
if (compareAtPrice) {
compareAtPrice.style.display = "none";
}
if(wideBundle.priceInfo.id == ".product-single__price"){
priceContainer = wideBundle.priceInfo.element[0].closest('.price-container');
if(priceContainer){
comparePrice = priceContainer.querySelector('#ComparePrice.product-single__price--compare-at');
if(comparePrice !== null && comparePrice != wideBundle.priceInfo.element[0]){
comparePrice.style.display = "none";
}
}
}
}
//For some exceptions we replace the price detected by WideBundle
wideBundle.replaceSelectedPrice = function(){
if(wideBundle.priceInfo.element[0]){
comparePrice = document.querySelector('#ComparePrice-product-template');
if(comparePrice){
priceSinglePrice = document.querySelector('.product-single__price product-single__price-product-template');
if(priceSinglePrice){
wideBundle.priceInfo = {
element: document.querySelectorAll('.product-single__price'),
id: '.product-single__price'
};
}
}
if(wideBundle.priceInfo.element[0].offsetParent === null && wideBundle.priceInfo.id == ".product__price"){
productPriceCompare = document.querySelector('.product__price--compare');
if(productPriceCompare && productPriceCompare.offsetParent === null){
productPriceSale = document.querySelector('.product__price.on-sale');
if(productPriceSale){
wideBundle.priceInfo = {
element: document.querySelectorAll('.product__price.on-sale'),
id: '.product__price on-sale'
};
}
}
}
if(wideBundle.priceInfo.id == ".product__price"){
productPriceSalePrice = document.querySelector('.product__price.sale-price');
if(wideBundle.priceInfo.element[0].classList.contains("product__price--compare") && productPriceSale){
wideBundle.priceInfo = {
element: document.querySelectorAll('.product__price.sale-price'),
id: '.product__price sale-price'
};
}
}
if(wideBundle.priceInfo.id == ".product-single__price"){
productSinglePrice = document.querySelector('.product-single__price.product-single__price--compare');
if(productSinglePrice && wideBundle.priceInfo.element[0].classList.contains('product__price--compare') == false){
productSingleMeta = document.querySelector('.product-single__meta-list');
if(productSingleMeta){
wideBundle.priceInfo.element[0].style.fontSize = '1.2em';
wideBundle.priceInfo = {
element: document.querySelectorAll('.product-single__meta-list'),
id: '.product-single__meta-list'
};
}
}
}
}
}
//Replace the price id value in the Database
wideBundle.replacePriceIdInDB = function(){
if(wideBundle.settings.price_id != wideBundle.priceInfo.id){
var http = new XMLHttpRequest();
var url = wideBundle.domain+'AJAX/GetPrice.php';
var params = 'price='+wideBundle.priceInfo.id+'&shop='+wideBundle.shop;
http.open('POST', url, true);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.send(params);
wideBundle.settings.price_id = wideBundle.priceInfo.id;
}
}
//Replace the form id value in the Database
wideBundle.replaceFormIdInDB = function(){
if(wideBundle.settings.form_id != wideBundle.formInfo.id){
var http = new XMLHttpRequest();
var url = wideBundle.domain+'AJAX/GetForm.php';
var params = 'form='+wideBundle.formInfo.id+'&shop='+wideBundle.shop;
http.open('POST', url, true);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.send(params);
wideBundle.settings.form_id = wideBundle.formInfo.id;
}
}
//Find WideBundle widget added manually (usually for page builders)
wideBundle.getManualWidget = function(){
var formWidebundle = document.querySelector("#new-form");
if(formWidebundle){
wideBundle.formInfo.id = 'page builder';
console.log("we found form for page builder");
//Hide variants from Gempages
if(formWidebundle.closest(".AddToCartForm")){
gfVariantsWrapper = formWidebundle.closest(".AddToCartForm").querySelector('gf_variants-wrapper');
if(gfVariantsWrapper){
gfVariantsWrapper.style.display = "none";
}
}
return formWidebundle;
}
else{
return null;
}
}
//Get the secondary widgets that were placed manually using .new-wb-form
wideBundle.getSecondaryWidgets = function(){
var multipleFormsWB = document.querySelectorAll('.new-wb-form');
if(multipleFormsWB.length){
console.log("using form class");
return multipleFormsWB;
}
else{
return null;
}
}
//For some exceptions we replace the form detected by WideBundle
wideBundle.replaceSelectedForm = function(){
var formWB = wideBundle.formInfo;
if(formWB.id == "form[action='/cart/add']"){
if(formWB.element.querySelector('h2[itemprop="name"]') != null &&
formWB.element.querySelector('.product__price-container') != null){
if(formWB.element.querySelector('.product-details .add-to-cart-btn') != null){
wideBundle.formInfo.element = formWB.element.querySelector('.product-details');
}
}
}
}
//Replo Page builder need special treatment
wideBundle.hideReplo = function(){
if(wideBundle.manualWidget){
if(document.querySelector('div[data-replo-variant-select]')){
document.querySelector('div[data-replo-variant-select]').style.display = "none";
document.querySelector('div[data-replo-variant-select]').classList.add('hide-unwanted-widebundle');
}
if(document.querySelector("select[data-replo-variant-select-dropdown]")){
if(wideBundle.manualWidget){
if(document.querySelector("select[data-replo-variant-select-dropdown]").parentElement.tagName == "DIV"){
document.querySelector("select[data-replo-variant-select-dropdown]").parentElement.style.display = "none";
document.querySelector("select[data-replo-variant-select-dropdown]").parentElement.classList.add('hide-unwanted-widebundle');
}
}
}
var increaseButton = document.querySelector('div[data-replo-increase-product-quantity]');
var decreaseButton = document.querySelector('div[data-replo-decrease-product-quantity]');
if(increaseButton && decreaseButton){
if(increaseButton.parentNode){
increaseButton.parentNode.style.display = "none";
increaseButton.parentNode.classList.add('hide-unwanted-widebundle');
}
}
var atcReplo = document.querySelector('button[data-replo-add-product-variant-to-cart]');
if(atcReplo){
atcReplo.style.display = "none";
atcReplo.classList.add('hide-unwanted-widebundle');
}
}
}
//Hide elements we don't want from the product form found by WideBundle
wideBundle.hideElementsOutsideProductForm = function(){
if(wideBundle.manualWidget){
getProductSwatches = document.querySelector('.gt_product-swatches.gt_flex.gt_variant_product');
if(getProductSwatches){
getProductSwatches.style.display = 'none';
getProductSwatches.classList.add('hide-unwanted-widebundle');
buttonGtProduct = document.querySelector('.button_add_to_cart.gt_product-addtocart');
if(buttonGtProduct){
buttonGtProduct.style.display = 'none';
buttonGtProduct.classList.add('hide-unwanted-widebundle');
}
gtFlexVariant = document.querySelector('.gt_flex.gt_variant_product');
if(gtFlexVariant){
gtFlexVariant.style.display = 'none';
gtFlexVariant.classList.add('hide-unwanted-widebundle');
}
}
gtProductContent = document.querySelector('.gt_product-content button[data-name="Product Button"]');
if(gtProductContent){
gtProductContent.style.display = "none";
gtProductContent.classList.add('hide-unwanted-widebundle');
style = '.gt_product-content button[data-name="Product Button"]{display:none !important;}';
addStyleToPage(style);
}
}
const firstArrayOfSelectors = [
'div[data-pf-type="ProductVariant"]',
'div[data-pf-type="ProductVariantSwatches"]',
'div[data-label="(P) Quantity"]',
'button.gt_button--product',
'.gt_product-variant.gt_product-swatches',
'div[data-pf-type="ProductQuantity"]',
'.qty_near_atc_wrapper',
'button[data-pf-type="ProductATC"]',
'button[data-pf-type="ProductATC2"]',
'div[data-label="(P) Variants"]',
'div[data-label="(P) Cart Button"]',
'div[data-label="(P) Swatches"]',
"gp-product-button button",
'gp-product-quantity',
"gp-product-variants"
];
const hideElementWithSelectorFromFirstArray = function(array) {
array.forEach(el => {
if(wideBundle.manualWidget){
if(document.querySelector(el) != null){
forms = document.querySelectorAll('form');
for(i = 0; i < forms.length; i++){
if(isDescendant(forms[i], wideBundle.manualWidget)){
variants = forms[i].querySelector(el);
if(variants != null){
variants.style.display = "none";
variants.classList.add('hide-unwanted-widebundle');
}
}
if(wideBundle.secondaryWidgets){
for(var y = 0; y {
if(wideBundle.manualWidget){
if(document.querySelector(el) != null){
if(document.querySelector(el).parentNode != null){
if(isDescendant(document.querySelector(el).parentNode, wideBundle.manualWidget)){
document.querySelector(el).style.display = "none";
document.querySelector(el).classList.add('hide-unwanted-widebundle');
}
if(wideBundle.secondaryWidgets){
for(var y = 0; y {
if(wideBundle.manualWidget){
if(document.querySelector(el) != null){
if(document.querySelector(el).parentNode != null){
if(isDescendant(document.querySelector(el).parentNode.parentNode, wideBundle.manualWidget)){
document.querySelector(el).style.display = "none";
document.querySelector(el).classList.add('hide-unwanted-widebundle');
}
}
}
}
})
};
hideElementWithParentNodeTwoLevel(arrayForHideElementWithParentNodeTwoLevel);
const thirdArrayOfSelectors = [
'.gt_product-swatches',
'.gt_product-variant',
'.gt_product-quantity',
'.gt_product-addtocart',
'.gt_button-atc',
".shg-product-selector-wrapper", //shogun variant selector to hide
".shg-product-atc-btn-wrapper", //shogun add to cart button to hide
];
const hideElementWithSelectorFromThirdArray = function (array) {
array.forEach(el => {
if(wideBundle.manualWidget){
if(document.querySelector(el) != null){
document.querySelector(el).style.display = "none";
document.querySelector(el).classList.add('hide-unwanted-widebundle');
}
}
})
};
hideElementWithSelectorFromThirdArray(thirdArrayOfSelectors);
const fourthArrayOfSelectors = [
'.dbtfy-color_swatches',
'.product-layout-grid__detail .product-detail__options',
'.product__info-wrapper variant-radios',
'div[data-variant-picker]',
'.product-detail__form__options.product-detail__gap-lg.product-detail__form__options--underlined',
'.product-block-container .product-block.product-block-variant-picker:not(.pb-card-shadow)',
'.product-block-container .product-block.product-block-quantity-selector:not(.pb-card-shadow)',
'.product-form__quantity',
'.product-block-item.atc-wrapper',
'.product__quantity',
'.product-form product-variants',
'.tt-swatches-container',
'.product__quantity',
'.product-info__quantity-selector',
'variant-picker',
'product-page product-variants',
'.product__variants-wrapper.product__block',
'.product__controls-group-quantity.product__block',
'.product-options--root',
'variant-radios',
'.quantity_selector',
'.productView-subtotal',
'.productView-options',
'f-variant-picker',
'[data-product-variants]',
'.product__controls-group-quanity',
'.yv-product-quantity',
'.product-block--buy-button .button--sold-out',
'.container .product__meta[itemscope] div div.row.gy-3',
".product__grid__item .product__content .product__selector[id^='ProductSelector-template--']"
];
const hideElementWithSelectorFromFourthArray = function (array) {
array.forEach(el => {
let element = document.querySelector(el);
if(element != null && !element.classList.contains("do-not-hide-wb")){
element.style.display = "none";
element.classList.add('hide-unwanted-widebundle');
}
})
};
hideElementWithSelectorFromFourthArray(fourthArrayOfSelectors);
const fifthArrayOfSelectors = [
'.product-block .variant-wrapper',
'.product__info-container variant-radios',
'.pt-swatches-container.pt-swatches-container-js',
'.product__info-container variant-selects',
'.product__info-wrapper variant-selects',
'.product-page-section variant-selects',
'.pg__option--single',
'.product-option-selector'
];
const hideElementWithSelectorFromFifthArray = function (array) {
let style = document.createElement('style');
style.type = 'text/css';
let css = ':root { --widebundle-element-visibility: none; }';
array.forEach((el, index) => {
if (index >= 3 && index <= 5) {
// Use CSS custom property for 4th, 5th, and 6th elements
css += `${el} { display: var(--widebundle-element-visibility) !important; } `;
}
});
style.appendChild(document.createTextNode(css));
document.head.appendChild(style);
document.documentElement.style.setProperty('--widebundle-element-visibility', 'none');
array.forEach(el => {
if(document.querySelector(el) != null){
for(var i = 0; i {
if(document.querySelector(el) != null){
if(!isDescendant(wideBundle.formInfo.element, document.querySelector(el))){
document.querySelector(el).style.display = "none";
document.querySelector(el).classList.add('hide-unwanted-widebundle');
}
}
})
}
hideElementWithSelectorFromSixthArray(sixthArrayOfSelectors);
const seventhArrayOfSelectors = [
'button[data-replo-repeated-index][role="button"]',
'select[data-replo-repeated-index][role="listbox"]'
];
const hideElementWithSelectorFromSeventhArray = function (array) {
array.forEach(el => {
elements = document.querySelectorAll(el);
if(document.querySelector(el) != null){
if(wideBundle.manualWidget){
for(var y = 0 ; y < elements.length; y++){
elements[y].style.display = "none";
elements[y].classList.add('hide-unwanted-widebundle');
}
}
}
})
}
hideElementWithSelectorFromSeventhArray(seventhArrayOfSelectors);
if(wideBundle.manualWidget){
if(document.querySelector('div[data-pf-type="ProductQuantity"]') != null){
layouts = document.querySelectorAll('div[data-pf-type="Layout"]');
for(i=0; i .point(svg)", ".product-block-item.pbi-7(div.img-w-txt)",
".wb-custom-html-2-zameer", ".wb-custom-html-1-zameer", ".wb-product-title-zameer",
".product-actions__checkout-image picture img", ".product__main .product-info h1.product-info__title", ".product-delivery-estimate.js-product-delivery-estimate(span.product-delivery-estimate__time)",
"div.button__extra(div.button__extra--rating p.button__extra--text)", "h1.title", "#product-testimonials(.description)", '.product-details--form-wrapper .marketing-badges-container(.marketing-badge)',
".prod_delivery-times(div.content p)", ".prod_shipping-text(div.content p)", "h1.product-name", "shopify-payment-terms", ".star-rating(.shopify-product-reviews-badge)", ".compare-wishlist(a.wishlist-button)",
"div.product__badges(img.lazyload)", ".accordion.product__accordion(label.accordion__item span.accordion__item--title)",
".product-option-wrapper button.btn-primary[data-bs-target='#size-chart-modal']", ".product-block-testimonial(p.product-block-testimonial-author)",
".wb-force-show-element", "#product-estimated-delivery(#livraison-estime)", ".product-collapsible-content(.no-click-highlight)",
".ProductForm__Advantages(.ProductForm__Advantage--cell .ProductForm__Advantage)", ".ProductForm--payicons(.StorePay--payicons)",
"div.stp-star[data-rating-stp](span.spt-badge-caption)", ".product-block-liquid-code(span.stock)", ".product-block-text(.description.rte)",
"[id*='product-block-animated-stories-animated_stories'](ul.stories-list)", ".product-block-rating-natif(svg)",
".product-reviews-dummy(.product-reviews-dummy-stars)", "p(span#current-date)",
".product-block-liquid-code(.choco_produit_soustitre3 .choco_produit_soustitre)", ".product-block-text(h2.title.h5)", ".choco_container_info_livraison_paiement(.choco_paiement_secure)", ".product-block-liquid-code(.choco_infos_charlideliss h4)", ".product-block-liquid-code(.choco_bandeau_icones img)"
];
var parentsToExcept = ['.cross-sell-block', '.accordion-item'];
//Show elements if we found add to cart of variants selector
if(variantsSelector || addToCartButton){
//Get position of at least one of the elements
if(variantsSelector?.element[0]?.getBoundingClientRect()?.top > 0){
elementPosition = variantsSelector.element[0].getBoundingClientRect().top;
}
else if(addToCartButton?.element?.getBoundingClientRect()?.top > 0){
elementPosition = addToCartButton.element.getBoundingClientRect().top;
}
//If the elements are visible and we have a position
if(typeof elementPosition != "undefined" && elementPosition != ""){
elementsAboveVariants = [];
elementsBelowVariants = [];
for(var y=0; y .elem(.child)
testHasChild = elementsToShow[y].split('(');
hasChild = "";
if(testHasChild.length > 1 && !elementsToShow[y].includes(":not")){
theElementToShow = testHasChild[0];
hasChild = testHasChild[1].split(')')[0];
}
else{
theElementToShow = elementsToShow[y];
}
//Search for the hidden element
var newNodeToShow = wideBundle.formInfo.element.querySelectorAll(theElementToShow);
newNodeToShowLength = newNodeToShow.length;
if(newNodeToShowLength){
checkAllElementsFound:
for(i=0; i index != i && isDescendant(element, arrOfAllElements[i]));
//if the current element is not child of any other element in the array, we add it to the result array
if(!isChild){
resultArray.push(arrOfAllElements[i])
} else {
console.log("Child, not adding in the result array: ", arrOfAllElements[i])
}
}
return resultArray
}
elementsAboveVariants = removeChildElements(elementsAboveVariants)
elementsBelowVariants = removeChildElements(elementsBelowVariants)
//Show hidden elements above or below the product form
if(elementsAboveVariants.length || elementsBelowVariants.length ){
elementsAboveVariants.sort(function(a, b) {
return a.getBoundingClientRect().top - b.getBoundingClientRect().top;
});
elementsBelowVariants.sort(function(a, b) {
return b.getBoundingClientRect().top - a.getBoundingClientRect().top;
});
var parentDiv = wideBundle.formInfo.element.parentNode;
for(i=0; i {
return `${str}${property}:${styles.getPropertyValue(property)};`;
}, '');
}
elementNode.style.cssText = cssText;
buttonWB = document.querySelector('.new-form-atc');
if(buttonWB.nextSibling){
buttonWB.parentNode.insertBefore(elementNode, buttonWB.nextSibling);
elementNode.style.display = "block";
}
else{
buttonWB.parentNode.appendChild(elementNode);
}
}
}
for(var i=0; i= 50){
clearInterval(intervalFunction);
}
}, 300);
//Elements to hide that load after WideBundle (addEventListener)
var elementsToHideWithEventListener = [
".product-detail .product-form.theme-init .option-selectors", 'variant-swatch-king'
];
//Hide element if it exists with setInterval iteration to catch it the moment it appears
loopCountHide = 0;
intervalFunctionHide = setInterval(function() {
elementsToHideWithEventListenerLength = elementsToHideWithEventListener.length;
for(var y=0; y= 50){
clearInterval(intervalFunctionHide);
}
}, 300);
}
//Manage the dynamic button to show
wideBundle.manageDynamicButton = function(){
if(wideBundle.formInfo.id != "page builder"){
elementNode = formWide.querySelector('div.shopify-payment-button[data-shopify="payment-button"] div');
if (!elementNode) {
elementNode = formWide.querySelector('div.shopify-payment-button[data-shopify="payment-button"] shopify-buy-it-now-button');
}
if(elementNode && !elementNode.classList.contains('cloned')){
elementNode.classList.add('cloned');
elementNodeParent = formWide.querySelector('div.shopify-payment-button[data-shopify="payment-button"]');
buttonWB = document.querySelector('.new-form-atc');
var newFormCreated = document.createElement('form');
if(wideBundle.formInfo.element.hasAttribute('action')){
newFormCreated.setAttribute('action', wideBundle.formInfo.element.getAttribute('action'));
}
else{
newFormCreated.setAttribute('action', '/cart/add');
}
newFormCreated.classList.add('dynamic_button_wb_form');
var originalHiddenInput = wideBundle.formInfo.element.querySelector('[name="id"]');
if (originalHiddenInput) {
idValue = originalHiddenInput.value;
}
else{
idValue = wideBundle.getSelectedVariantId();
}
// Create a new hidden input with the same value
var newHiddenInput = document.createElement('input');
newHiddenInput.setAttribute('type', 'hidden');
newHiddenInput.setAttribute('name', 'id');
newHiddenInput.value = idValue;
// Append the hidden input to the new form
newFormCreated.appendChild(newHiddenInput);
// Append the duplicated button to the new form
newFormCreated.appendChild(elementNodeParent);
if(buttonWB.nextSibling){
buttonWB.parentNode.insertBefore(newFormCreated, buttonWB.nextSibling);
elementNodeParent.style.display = "block";
}
else{
buttonWB.parentNode.appendChild(newFormCreated);
}
console.log(document.querySelector('#new-form div.shopify-payment-button[data-shopify="payment-button"] button'));
}
}
}
//To Update the variant ID selected in the form we created for the dynamic button
wideBundle.manageSelectedVariantForDynamicButton = function(){
idInput = document.querySelector('.dynamic_button_wb_form [name="id"]');
if(idInput){
var originalHiddenInput = wideBundle.formInfo.element.querySelector('[name="id"]');
if (originalHiddenInput) {
idValue = originalHiddenInput.value;
}
else{
idValue = wideBundle.getSelectedVariantId();
}
idInput.value = idValue;
}
}
//Preselect one offer so one is selected by default
wideBundle.preselectOffer = function(){
var preselectedOffer = 0; //Check if the user preselected an offer
for(var i = 0; i {
var newNode = elementToDuplicate.cloneNode();
newNode.style.display = "none";
newNode.classList.add('wb-duplicated');
form.appendChild(newNode);
});
}
//Remove all duplicated elements
function removeDuplicatedElementsFromForm() {
const duplicatedElementsInForm = form.querySelectorAll('.wb-duplicated');
duplicatedElementsInForm.forEach((duplicatedElementInForm) => duplicatedElementInForm.remove());
}
if(!wideBundle.manualWidget){
//For Some Apps
var elementsToDuplicate = [".uploadkit-injected", ".upload-container", ".gpo-container", ".upload-container", "#textfieldapp"]; //Apps for custom elements
var elementsToDuplicateSellingPlan = [".appstle_sub_widget"];
let counterDuplicationWB = 0;
let functionToUpdateInputs = {};
let functionToUpdateInputsSellingPlan = {};
var functionToCheckHiddenComplexElement = setInterval(() => {
if (typeof form !== 'undefined' && form !== null) {
var widebundle = document.querySelector('#new-form-atc');
for(var i=0; i { //Duplicate elements we want to put them in the product form
elementClass = elementsToDuplicate[i];
removeDuplicatedElementsFromForm();
cloneAndHidePropertiesElements(elementClass);
}, 200);
})(i);
}
}
}
counterDuplicationWB++;
if (counterDuplicationWB >= 50) {
clearInterval(functionToCheckHiddenComplexElement);
}
}, 300);
}
//For Subscription App Recurpay - The goal is to show the widget without removing it from the form by using CSS and place it
//before the add to cart button of WB
function getAbsolutePosition(element) {
var rect = element.getBoundingClientRect();
var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
var scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
return { top: rect.top + scrollTop, left: rect.left + scrollLeft };
}
function setButtonMargin(margin) {
// Remove previous rule if it exists
if(sheet.cssRules.length > 0) {
sheet.deleteRule(0);
}
// Add new rule
sheet.insertRule(`#new-form-atc { margin-top: ${margin}px !important; }`, 0);
}
// Variables to control the retry logic
var retryCount = 0;
var maxRetries = 20;
// Create a style sheet
var sheet = (function() {
var style = document.createElement("style");
style.appendChild(document.createTextNode("")); // WebKit hack
document.head.appendChild(style);
return style.sheet;
})();
// First setInterval to check for the existence of the form
var formCheckIntervalRecurpay = setInterval(function() {
retryCount++;
// If form exists or maxRetries reached, clear this interval
if (typeof form != "undefined" && form) {
var sealSubs = wideBundle.formInfo.element.querySelector('.recurpay-pdp-widget');
if(sealSubs){
clearInterval(formCheckIntervalRecurpay);
// If form exists, proceed to check for SealSubs element
if (typeof form != "undefined" && form) {
checkSealSubs();
}
}
}
if(retryCount >= maxRetries){
clearInterval(formCheckIntervalRecurpay);
}
}, 300);
function checkSealSubs() {
var sealSubs = wideBundle.formInfo.element.querySelector('.recurpay-pdp-widget');
if (sealSubs) {
// Get positions and dimensions
var button = document.querySelector('#new-form-atc');
// Set initial styles
sealSubs.style.display = 'block';
sealSubs.style.position = 'absolute';
sealSubs.style.top = '0';
sealSubs.style.zIndex = '1000';
var buttonPos = getAbsolutePosition(button);
var sealSubsPos = getAbsolutePosition(sealSubs);
sealSubs.style.top = buttonPos.top - sealSubsPos.top + 'px';
setButtonMargin(sealSubs.offsetHeight + 10);
// Update margin-top of the button every 100 ms
setInterval(function() {
setButtonMargin(0);
sealSubs.style.top = '0';
var buttonPos = getAbsolutePosition(button);
var sealSubsPos = getAbsolutePosition(sealSubs);
sealSubs.style.top = buttonPos.top - sealSubsPos.top + 'px';
setButtonMargin(sealSubs.offsetHeight + 10);
}, 100);
}
}
}
//Show an error if the user is using a page builder but not using manual widget placement
wideBundle.handleErrorsPageBuilders = function(){
//For GemPages
if(!wideBundle.manualWidget &&
((document.querySelector(".gf_row") && document.querySelector('body.gempage') && document.querySelector("div[data-label='Product']")) ||
(document.querySelector('div[label="Block"]') && document.querySelector('gp-product')))
){
wideBundle.createError("You have to use WideBundle's module from GemPages.", "https://help.widebundle.com/en/article/how-to-use-widebundle-with-gempages-qywl1/#2-3-add-the-widebundle-module")
}
//For PageFly
if(!wideBundle.manualWidget && document.querySelector("div[data-pf-type='Body']") && document.querySelector('[data-pf-type="ProductBox"]') && isDescendant(document.querySelector('[data-pf-type="ProductBox"]'), document.querySelector('#new-form'))){
wideBundle.createError("You have to use WideBundle's module from PageFly.", "https://help.widebundle.com/en/article/how-to-use-widebundle-with-pagefly-suqsj9/#2-add-the-widebundle-module")
}
}
//Create a main widget if we only have secondary widgets
wideBundle.transformMainElement = function(){
// Check if there's no element with the ID 'new-form'
if (!document.getElementById('new-form')) {
// Get the first '' element
let widget = document.querySelector('widebundle-module');
if (widget) {
// Set the ID to 'new-form'
widget.id = 'new-form';
}
}
// Add .new-wb-form class to all elements except the one with #new-form
let widgets = document.querySelectorAll('widebundle-module:not(#new-form)');
widgets.forEach(widget => {
widget.classList.add('new-wb-form');
});
}
//Get Variants of the product from Shopify
wideBundle.getVariantsOnShopify = function(){
//We can then check if ideBundle?.variantsOnShopify exists
var variantsFromJson = wideBundle.getVariantsFromJson(wideBundle.getSelectedVariantId());
if(variantsFromJson){
wideBundle.variantsOnShopify = variantsFromJson;
}
else{
var urlProductAPI = `${window.Shopify.routes.root}products/${wideBundle.currentHandle}.js`;
fetch(urlProductAPI)
.then(response => response.json())
.then(product => {
wideBundle.variantsOnShopify = product.variants;
})
.catch(error => console.error(error));
}
}
//Create the widget container
wideBundle.createWidgetContainer = function(){
var container = document.createElement('div');
container.id = 'new-form';
var formWB = wideBundle.formInfo.element;
formWB.parentNode.insertBefore(container, formWB.nextSibling); //We place the container after product form found
wideBundle.hideOrShowProductForm("hide"); //We hide the product form so it's not duplicated with WideBundle
setInterval(() => { //We hide the product form with delay for some themes
if (wideBundle.formVisible === 0) {
wideBundle.hideOrShowProductForm("hide");
}
}, 1000);
return container; //We return the container we created
}
//Create the offers variable to get the information we have to display
wideBundle.getOffersData = function(data) {
const offerMap = new Map();
const dataLength = data.length;
// Precompute function references
const formatPrice = wideBundle.formatPrice;
const getPricesFromJson = wideBundle.getPricesFromJson;
const getAmountFromPrice = wideBundle.getAmountFromPrice;
for (let i = 0; i < dataLength; i++) {
const variant = data[i];
const offerTitle = variant.variant_option1;
let offer = offerMap.get(offerTitle);
if (!offer) {
offer = {
offer_title: offerTitle,
variants: [],
message: variant.blinking_text,
message_effect: variant.blinking_effect,
message_position: variant.blinking_position,
unit: variant.unit,
unit_price: variant.unit_price,
unit_text: variant.unit_text,
product_id: variant.product_id,
options_number: variant.variant_option3 ? 3 : variant.variant_option2 ? 2 : 1,
offer_position: variant.position_offer,
enabled: variant.enabled,
image: variant.image,
preselected: variant.selected_offer,
heading: variant.title_option1,
options_labels: variant.title_option2,
option1_title: variant.variant_option1_title,
option2_title: variant.variant_option2_title,
option3_title: variant.variant_option3_title,
option2_is_color: variant.variant_option2_is_color,
option3_is_color: variant.variant_option3_is_color,
price_in_offer: variant.variant_price,
dropdowns_amount: variant.variant_option2 ? variant.variant_option2.split(",").length : 0,
option2_values: new Set(),
option3_values: new Set(),
options_color_values: variant.options_color_values || {}
};
offerMap.set(offerTitle, offer);
}
// Update option values
if (variant.variant_option2) {
variant.variant_option2.split(',').forEach(v => offer.option2_values.add(v.trim()));
}
if (variant.variant_option3) {
variant.variant_option3.split(',').forEach(v => offer.option3_values.add(v.trim()));
}
// Add variant
const pricesFound = getPricesFromJson(variant.variant_id);
const price = pricesFound ? pricesFound.price : formatPrice(variant.variant_price);
offer.variants.push({
id: variant.variant_id,
price: price,
compare_at_price: pricesFound ? pricesFound.compare_at_price : formatPrice(variant.variant_compared),
option1: variant.variant_option1,
option2: variant.variant_option2,
option3: variant.variant_option3 == "" ? null : variant.variant_option3,
conversion_rate: variant.variant_price / getAmountFromPrice(price)
});
console.log('finished loop offers');
}
wideBundle.offers = Array.from(offerMap.values());
// Convert Sets to Arrays
for (let offer of wideBundle.offers) {
offer.option2_values = Array.from(offer.option2_values);
offer.option3_values = Array.from(offer.option3_values);
}
wideBundle.heading = wideBundle.offers[0]?.heading || '';
console.log('finish getting all data');
};
//Hide the product form or show it (action = "hide" or action = "show")
wideBundle.hideOrShowProductForm = function(action = "hide"){
var cssProperties = {
"width": action === "hide" ? "1px" : "auto",
"height": action === "hide" ? "0px" : "auto",
"overflow": action === "hide" ? "hidden" : "visible",
"margin": action === "hide" ? "0px" : "auto",
"marginTop": action === "hide" ? "0px" : "auto",
"marginBottom": action === "hide" ? "0px" : "auto",
"paddingTop": action === "hide" ? "0px" : "auto",
"paddingBottom": action === "hide" ? "0px" : "auto"
};
//"display": action === "show" ? "block" : "none"
var formWB = wideBundle.formInfo.element;
for (var property in cssProperties) {
formWB.style[property] = cssProperties[property];
}
wideBundle.formVisible = action === "show" ? 1 : 0;
var displayValue = action === "show" ? "block" : "none";
document.querySelectorAll('.hide-unwanted-widebundle').forEach(element => element.style.display = displayValue);
document.documentElement.style.setProperty('--widebundle-element-visibility', displayValue); //For some elements using CSS where we applied a variable
}
showFormWB = function(){
wideBundle.hideOrShowProductForm("show");
}
//Create the content inside the widget container
wideBundle.createWidgetContent = function(widgetContainer){
wideBundle.createHeading(widgetContainer); //Create the heading above the widget
for(var i = 0; i= parseFloat(wideBundle.getAmountFromPrice(variant.compare_at_price)) ? "" : variant.compare_at_price;
htmlContent += `
${wideBundle.removeDecimal(wideBundle.updatePriceSeparator(variant.price))}
${wideBundle.removeDecimal(wideBundle.updatePriceSeparator(variant.compare_at_price))}
`;
}
}
divHiddenPrices.innerHTML = htmlContent;
wideBundle.widgetContainers[0].appendChild(divHiddenPrices); //Add hidden prices to first container
}
//Create the heading above the widget
wideBundle.createHeading = function(widgetContainer){
var heading = document.createElement('p');
heading.classList.add('p-title-WB');
if(widgetContainer.hasAttribute('id')) {
heading.innerHTML = ""+wideBundle.heading+"";
} else {
heading.innerHTML = ""+wideBundle.heading+"";
}
if(wideBundle.settings.design_code == 4){
heading.innerHTML += "";
}
widgetContainer.appendChild(heading);
}
//Create the offer container
wideBundle.createOfferContainer = function(widgetContainer, offer){
var offerContainer = document.createElement('div');
if(widgetContainer.hasAttribute('id')){
offerContainer.id = "id" + offer.variants[0].id
}
offerContainer.classList.add('selectable'); //Add the class for unselected offers
offerContainer.classList.add('new-form-option');
offerContainer.setAttribute('data-id', offer.variants[0].id);
offerContainer.addEventListener("click", wideBundle.changeSelectedOffer); //Add the click event to detect when we select the offer
return offerContainer;
}
//Create the content on the left of the offer
wideBundle.createOfferContentLeft = function(offerContainer, offer){
var contentLeft = document.createElement('div');
contentLeft.classList.add('value-left');
var roundCheckbox = document.createElement('span'); //Create the circle checkbox
roundCheckbox.classList.add('checkedWB');
contentLeft.append(roundCheckbox);
if(offer.image != '' && offer.image != null){ //Add thumbnail if it exists
var thumbnail = document.createElement('img');
thumbnail.classList.add('thumbnailWB');
contentLeft.classList.add('offer-image');
thumbnail.setAttribute('src', offer.image);
thumbnail.setAttribute('alt', "");
contentLeft.append(thumbnail);
}
offerContainer.appendChild(contentLeft);
}
//Create the contnet on the right of the offer
wideBundle.createOfferContentRight = function(offerContainer, offer){
var contentRight = document.createElement('div');
contentRight.classList.add('value-right');
offerContainer.appendChild(contentRight);
titleOffer = document.createElement('p'); //Create the title of the offer
titleOffer.classList.add('title-variant');
titleOffer.innerHTML = offer.offer_title;
var priceElement = document.createElement('p'); //Create the price of the offer;
priceElement.classList.add('price-new-form');
variantId = offer.variants[0].id; //We create the prices of the offer
var price = document.querySelector(`.wb_hidden_prices .wb_hidden_price[variant-id="${variantId}"]`).innerHTML;
var compareAtPrice = document.querySelector(`.wb_hidden_prices .wb_hidden_compared_price[variant-id="${variantId}"]`).innerHTML;
var priceHtml = `
${price}
${compareAtPrice}
`;
priceElement.innerHTML = priceHtml;
if(offer.unit == 1 && wideBundle.settings.plan !== "monthly") {
var crMarkets = offer.variants[0].conversion_rate
var crOffer = offer.unit_price / offer.price_in_offer ;
var unit_price_markets = offer.unit_price / crMarkets;
var unitElement = document.createElement('p'); //Create the price of the offer;
unitElement.classList.add('first-unit-WB');
var unitHtml = `
${ wideBundle.removeDecimal(wideBundle.updatePriceSeparator(wideBundle.formatPriceForUnit(unit_price_markets)))}
${offer.unit_text}
`;
priceElement.setAttribute("data_offer_cr", crOffer);
unitElement.innerHTML = unitHtml;
priceElement.classList.add('hidden-unit');
}
wideBundle.createQuantityWidget(offerContainer); //We create the quantity widget if they enabled it in the settings
if(isJsonString(offer.message) && offer.message !== null){
messageText = JSON.parse(offer.message);
}
else{
messageText = offer.message ? [offer.message] : [""];
}
messageEffect = offer.message_effect ? offer.message_effect.split(",") : [""]; //Get message effect
messagePosition = offer.message_position ? offer.message_position.split(",") : [""]; //Get message position
messagesToDisplay = wideBundle.settings.plan == 'monthly' ? 1 : messageText.length;
for(var i = 0; i 1 && wideBundle.settings.plan == 'monthly')){ //Add the message before title if it exists
wideBundle.createCustomSentence(messageText[i], messageEffect[i], contentRight, offerContainer);
}
}
contentRight.appendChild(titleOffer); //Add the title of the offer
contentRight.appendChild(priceElement); //Add the price of the offer
if(offer.unit == 1 && wideBundle.settings.plan !== "monthly") {
contentRight.appendChild(unitElement); //Add the price of the offer
}
for(var i = 0; i for this option with the options values
selectContainer.classList.add('has-double-select');
var selectForThirdOptionHtml = ``;
if(offer.option3_is_color === "1" && wideBundle.settings.plan !== "monthly") {
selectForThirdOptionHtml += ``;
}
}
else{
var selectForThirdOptionHtml = '';
}
//Add the select for the 2nd option with the options values
var selectForSecondOptionHtml = `${optionsLabels[i]}
`;
selectForSecondOptionHtml += ``;
if(offer.option2_is_color === "1" && wideBundle.settings.plan !== "monthly") {
selectForSecondOptionHtml += ``;
for (var k = 0; k < offer.option2_values.length; k++) {
var color_hex = offer.options_color_values[offer.option2_values[k]];
var style = /^#(?:[0-9a-f]{3}){1,2}$/i.test(color_hex) ? `background-color: ${color_hex}` : `background-image: url(${color_hex})`;
selectForSecondOptionHtml += `
`;
}
selectForSecondOptionHtml += `
`;
}
selectForSecondOptionHtml += `${selectForThirdOptionHtml}`;
selectContainer.innerHTML = selectForSecondOptionHtml;
//Hide the container if there is 1 option value or less for both options
if(offer.option2_values.length <= 1 && offer.option3_values.length <= 1){
selectContainer.classList.add('hide-bloc-wb');
}
contentRight.appendChild(selectContainer);
}
}
//Display the saving text if it's enabled
wideBundle.createSavingText = function(offer, contentRight, offerContainer){
if(wideBundle.settings.economic_display == 1 && offer.variants[0].compare_at_price != ""){
var price = document.querySelector(`.wb_hidden_prices .wb_hidden_price[variant-id="${offer.variants[0].id}"]`).innerHTML;
var compareAtPrice = document.querySelector(`.wb_hidden_prices .wb_hidden_compared_price[variant-id="${offer.variants[0].id}"]`).innerHTML;
difference = getAmountDifference(price, compareAtPrice);
if(wideBundle.settings.no_decimal == 1){ //If they enabled the feature to remove decimal
difference.amount = parseFloat(difference.amount);
}
var currencyAlone = price.replace(/\d+.\d+/g,'{{amount}}').replace(/\d+/g,'{{amount}}')
var priceDifference = wideBundle.updatePriceSeparator(currencyAlone.replace('{{amount}}', difference.amount));
var savingTextContent = wideBundle.settings.economic_text;
savingTextContent = savingTextContent.replace("{{percent}}", `${difference.percent}`);
savingTextContent = savingTextContent.replace("{{amount}}", `${wideBundle.updatePriceSeparator(priceDifference)}`);
var today = new Date();
var dd = String(today.getDate()).padStart(2, '0');
var mm = String(today.getMonth() + 1).padStart(2, '0');
var yyyy = today.getFullYear();
today = dd + '/' + mm + '/' + yyyy;
savingTextContent = savingTextContent.replace('{{today}}', today);
var savingText = document.createElement('p');
savingText.innerHTML = savingTextContent;
savingText.classList.add('economic-wb');
contentRight.appendChild(savingText);
offerContainer.classList.add('with-economic-text');
}
}
//Create a custom sentence if the user added one
wideBundle.createCustomSentence = function(message, effect, contentRight){
if(message){
customSentence = document.createElement('span');
customSentence.classList.add('best-title', 'best-title-new');
customSentence.innerHTML = message;
if(effect == 1){ //If blinking enabled
customSentence.classList.add('best-title-blink');
}
contentRight.classList.add('with-message');
contentRight.appendChild(customSentence);
}
}
//Add the quantity widget if it's enabled
wideBundle.createQuantityWidget = function(offerContainer){
if(wideBundle.settings.display_quantity == 1){
var quantityContainer = document.createElement('div');
quantityContainer.classList.add('spinWB');
quantityHTML = `
–
+
`;
quantityContainer.innerHTML = quantityHTML;
offerContainer.append(quantityContainer);
//Add the event listeners
quantityContainer.querySelector('.quantity-wb-less').addEventListener('click', function(){
var value = Math.max(1, document.querySelector('.selectedWB .quantity-wb-input').value -1);
wideBundle.updateQuantityInputs(value);
wideBundle.updateQuantityDisabled(value);
});
quantityContainer.querySelector('.quantity-wb-more').addEventListener('click', function(){
var value = Math.max(1, parseInt(document.querySelector('.selectedWB .quantity-wb-input').value)+1);
wideBundle.updateQuantityInputs(value);
wideBundle.updateQuantityDisabled(value);
});
offerContainer.querySelector('.quantity-wb-input').addEventListener('change', function(){
if(isNaN(this.value.replace(',', '.'))){
wideBundle.updateQuantityInputs(1);
wideBundle.updateQuantityDisabled(1);
}
else{
wideBundle.updateQuantityInputs(Math.round(this.value.replace(',', '.')));
wideBundle.updateQuantityDisabled(Math.round(this.value.replace(',', '.')));
}
});
}
}
//Update the quantity inputs values in the page
wideBundle.updateQuantityInputs = function(value){
//For quantity inputs in the offers
var quantityInputs = document.querySelectorAll('.quantity-wb-input');
for(var i = 0; i 0) {
increaseButton.click();
difference--;
if (difference > 0) {
setTimeout(adjustQuantity, 100); // Adjust the timeout as necessary
}
} else if (difference < 0) {
decreaseButton.click();
difference++;
if (difference < 0) {
setTimeout(adjustQuantity, 100); // Adjust the timeout as necessary
}
}
}
adjustQuantity();
}
}
//Update the selects in all the WideBundle widgets to change the selected values
wideBundle.updateSelectsInOffers = function(elementUpdated){
var valueOfElement = elementUpdated.value;
var classSelectors = Array.from(elementUpdated.classList);
var classOfElement = '.' + classSelectors.join('.');
for(var i=0; i= 40){
clearInterval(checkCurrentWidget);
}
}, 200);
}
}
//Add the product to the cart (function called immediately after the click on the button)
wideBundle.addToCart = function(){
//Add the loading gif
wideBundle.displayLoadingOnATC();
wideBundle.showErrorIfNonExistingVariant(); //Show error if the variant doesn't exist on Shopify
console.log('clicked on the button');
//Get currency name
currencyName = typeof window.ShopifyAnalytics !== "undefined"
? window.ShopifyAnalytics.meta.currency
: typeof window.Shopify.currency !== "undefined"
? Shopify.currency.active
: wideBundle.setting.currency_code;
//Get infos about the variant to add
var selectedVariantId = wideBundle.getSelectedVariantId();
var quantityVariant = document.querySelector('.selectedWB .quantity-wb-input');
var quantityVariantValue = quantityVariant ? quantityVariant.value : 1;
var itemsToAddToCart = {items: [{quantity: quantityVariantValue, id: selectedVariantId}]};
const atcButtons = Array.from(document.querySelectorAll('.new-form-atc'));
//Disable click
atcButtons.forEach(function (atcButton) {
atcButton.style.pointerEvents = 'none';
});
wideBundle.updateQuantityDisabled().then(function (continueAddToCart) {
if (!continueAddToCart) {
return;
}
if(wideBundle.settings.link_choice == "form"){ //If the user selected "side cart" redirection
wideBundle.showErrorIfSideCart(); //Show error if the user didn't add add-to-cart button and variants selector
wideBundle.updateVariantIdSelector(selectedVariantId); //Update the