document.addEventListener("DOMContentLoaded", () => { // get this element count-down_wrapper p-single-count-down let countDown = document.querySelector(".p-single-count-down"); // get text from css computed styles --custom-title1 let title1 = getComputedStyle(document.body).getPropertyValue("--custom-title1").slice(1, -1); // create a new div and insert it inside of it after start let newDiv = document.createElement("div"); newDiv.classList.add("discount-ends-title", "dm-text-main"); newDiv.innerHTML = title1; countDown.insertAdjacentElement("afterbegin", newDiv); }); if (window.customCardProps?.custom_pc) { // start custom custom product card window.run_product_card = function (_this) { let lang = document.documentElement.getAttribute("lang"); const remained = salla.lang.get("pages.products.remained"); const donationPH = salla.lang.get("pages.products.donation_placeholder"); const startingPrice = salla.lang.get("pages.products.starting_price"); const outOfStock = salla.lang.get("pages.products.out_of_stock"); const calories = salla.lang.get("pages.products.calories"); _this.product_preview_down = window.customCardProps?.product_preview_down; _this.p_atc_btn_hidden = window.customCardProps?.p_atc_btn_hidden; _this.product_preview_icon_hide = window.customCardProps?.product_preview_icon_hide; _this.preview_text = window.customCardProps?.preview_text; _this.is_price_ratio_on = window.customCardProps?.is_price_ratio_on; _this.price_ratio_place = window.customCardProps?.price_ratio_place; _this.price_ratio_word = window.customCardProps?.price_ratio_word; _this.small_atc = window.customCardProps?.small_atc; _this.custom_pc = window.customCardProps?.custom_pc; console.log(_this.product); _this.show_pc_ratings = window.customCardProps?.show_pc_ratings; if (_this.show_pc_ratings == "hide") { _this.show_pc_ratings = false; } let product_ration_html = undefined; if (_this?.product?.is_on_sale) { _this.product_ratio_percent = Math.round( ((_this.product?.regular_price - _this.product?.sale_price) / _this.product?.regular_price) * 100 ); product_ration_html = `
${_this.price_ratio_word} ${_this.product_ratio_percent}%
`; } _this.innerHTML = `
${_this.product.is_on_sale && _this.is_price_ratio_on && _this.price_ratio_place == "over" ? `${_this.product_ration_html || ""}` : ``} ${ _this.product.promotion_title ? `${_this.product.promotion_title}` : _this.showQuantity && _this.product.quantity ? `${remained} ${_this.product.quantity}` : _this.showQuantity && _this.product.is_out_of_stock ? `
${outOfStock}
` : "" } ${_this.product.image.alt} ${ _this.product_preview_down ? `` : `
` }
${ _this.showWishlist ? ` ` : "" }
${ _this.product.is_on_sale && _this.product.discount_ends ? ` ` : `` }

${!!_this.product.subtitle ? _this.product.subtitle : ""}

${_this.product.name}

${ _this.product.rating && _this.show_pc_ratings ? ` ` : "" } ${ _this.product.calories ? `
${_this.product.calories} ${calories}
` : "" } ${ _this.product.is_donation ? `
${ _this.product.can_donate ? ` ` : "" }
` : "" }
${ _this.product.is_on_sale ? `${salla.money( _this.product.sale_price )}${salla.money( _this.product.regular_price )}` : _this.product.starting_price ? `${startingPrice}${salla.money(_this.product.starting_price)}` : `${salla.money(_this.product.price)}` } ${_this.product?.is_on_sale && _this.is_price_ratio_on && _this.price_ratio_place == "down" ? `${_this.product_ration_html || ""}` : ``}
${ _this.has_count_down ? `
` : "" } ${ !_this.hideAddBtn ? `
${ _this.p_atc_btn_hidden ? `` : ` ${_this.product.add_to_cart_label !== undefined ? _this.product.add_to_cart_label : ""} ` }
${ !_this.product_preview_down ? `` : `
${_this.preview_text}
` } ` : "" }`; }; // // // // end if window.customCardProps?.custom_pc } // test bb