Hozzanator Posted December 4, 2020 Posted December 4, 2020 Site URL: https://www.pcupgrade.org/competition/8rg4ap6i7a84ojl8alljljnsitsg3o-wddar-wdzta-9f6dt-c8dak I am trying to customize the scarcity text from say "only 150 left in stock" to "only 150 tickets left" or anything else I like really. The custom label is no good as it doesn't add the quantity of items. can anyone helps with this please?
Beyondspace Posted December 5, 2020 Posted December 5, 2020 49 minutes ago, Hozzanator said: Site URL: https://www.pcupgrade.org/competition/8rg4ap6i7a84ojl8alljljnsitsg3o-wddar-wdzta-9f6dt-c8dak I am trying to customize the scarcity text from say "only 150 left in stock" to "only 150 tickets left" or anything else I like really. The custom label is no good as it doesn't add the quantity of items. can anyone helps with this please? Could you try this method, kindly move the placeholde {remain} anywhere in the string <script> var scarcityMessage = "Only {remain} tickets left"; window.Squarespace.onInitialize(Y, function() { if (document.querySelector(".product-scarcity")) { var text = document.querySelector(".product-scarcity").innerText; var remain = text.match("Only (.*) left"); console.log(remain); if (remain) { remain = remain[1]; } document.querySelector(".product-scarcity").innerText = scarcityMessage.replace("{remain}", remain); } }); </script> BeyondSpace - Squarespace Website Developer 🖼️ Lightbox Studio (Pinch/Zoom images, videos - PDFs Lightbox - ...) </> 🗓️ Delivery Date Picker (Date picker form field) Gallery block 7.1 workaround </> 🤖 Ask me anything
Recommended Posts
Archived
This topic is now archived and is closed to further replies.