if (window.customCardProps?.custom_pc) { 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.price_ratio_after_word = window.customCardProps?.price_ratio_after_word; _this.small_atc = window.customCardProps?.small_atc; _this.show_pc_ratings = window.customCardProps?.show_pc_ratings; if (_this.show_pc_ratings === "hide") { _this.show_pc_ratings = false; } if (!_this.config) { _this.config = {}; if (window.product_options_in_pc) { if (window.single_option_new_shape) { _this.config["single-option"] = { type: "button" }; } if (window.multiple_option_new_shape) { _this.config["multiple-option"] = { type: "button" }; } } } let product_ration_html; 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" ? 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.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 ? ` ` : "" }
` : "" }

${salla.money( _this.product.sale_price || 0 )}

${salla.money( _this.product.regular_price || 0 )}
${_this.product.starting_price ? `${startingPrice}` : ""}

${salla.money( _this.product.starting_price || _this.product.price || 0 )}

${ _this.product?.is_on_sale && _this.is_price_ratio_on && _this.price_ratio_place === "down" ? product_ration_html || "" : "" }
${ window.product_options_in_pc || _this.product.options?.length > 0 ? ` ` : "" } ${ _this.has_count_down ? `
` : "" } ${ !_this.hideAddBtn ? `
${ _this.p_atc_btn_hidden ? `` : ` ${_this.product.add_to_cart_label || ""} ` } ${ "" == "" ? "" : ` ` }
` : "" } ${ !_this.product_preview_down ? `` : `
${_this.preview_text}
` }
`; // handle home page grid view // add banner as fifth product card setTimeout(() => { const parentElement = _this.parentElement; if (parentElement?.classList.contains("s-products-list-wrapper")) { const children = Array.from(parentElement.children); const lastChild = children[children.length - 1]; if (lastChild === _this) { _this.classList.add("last-product-card"); addBannerAfterLastCard(_this); } } }, 100); // دالة للحصول على CSS variable بشكل آمن function getCSSVariableValue(varName, fallback = "") { try { let value = getComputedStyle(document.body).getPropertyValue(varName).trim(); // إزالة quotes (Safari) value = value.replace(/^['"]|['"]$/g, ""); // استخراج URL من url() const urlMatch = value.match(/url\(['"]?(.+?)['"]?\)/); if (urlMatch) { value = urlMatch[1].trim(); } // 🔧 Safari fix - unescape escaped characters value = value.replace(/\\/g, ""); // حذف backslashes value = decodeURI(value); // decode URI return value && value !== "undefined" ? value : fallback; } catch (error) { console.warn(`Error getting CSS variable ${varName}:`, error); return fallback; } } function addBannerAfterLastCard(_p_card) { const parentElement = _p_card.parentElement; if (parentElement?.classList.contains("s-products-list-wrapper")) { const children = Array.from(parentElement.children); const lastChild = children[children.length - 1]; if (lastChild === _p_card) { // احصل على الـ values من theme let is_second; if (parentElement.closest(".aali-products-tabs")?.classList.contains("tab3")) { is_second = "2"; } const bannerImageUrl = getCSSVariableValue( `--custom-image${is_second || "1"}`, "https://cdn.salla.sa/cdn-cgi/image/fit=scale-down,width=400,height=400,onerror=redirect,format=auto/NKZRyX/zEWlqfJ1duwF5Xd6KsyI8C69uRaq0R5ZkgVUJVPe.jpg" ); const bannerHref = getCSSVariableValue("--custom-title7", "https://antoniosotosar.com/test/page-1208141940"); // Create banner const banner = document.createElement("div"); banner.classList.add("product-card-banner"); banner.innerHTML = ` our story `; // Insert banner parentElement.insertBefore(banner, _p_card.nextSibling); console.log("Banner added", { image: bannerImageUrl, href: bannerHref }); } } } console.log(_this.config); }; } // transfer footer-tax-wrapper to be inside footer-bottom__inside-footer-top using insertAdjecentelement let footer_tax = document.querySelector(".store-footer .footer-tax-wrapper"); let footer_top_side = document.querySelector(".store-footer .footer-bottom__inside-footer-top"); footer_top_side.insertAdjacentElement("afterbegin", footer_tax); // also: transfer .footer-contact > div.block to be inside .footer-social-outer using insertAdjecentelement let footer_contact_block = document.querySelector(".store-footer .footer-contact > div.block"); footer_contact_block.classList.add("m-auto"); let footer_social_outer = document.querySelector(".store-footer .footer-social-outer"); footer_social_outer.insertAdjacentElement("beforeend", footer_contact_block); // end transfer footer-tax-wrapper