Price in Add to Cart

Description

07.26c07v7 Price in Add to Cart

#1. Install Code

#1.1. Click Gear icon on Store Page

07.26c05v1 Variant Description

Next, click Advanced > Page Header Code Injection

07.26c05v1 Variant Description

#1.2. Add this code to right box

<!-- 07.26c07v7 Price in Add to Cart -->
<script>
const priceOptions = {
  fontSize: "18px",
  spaceBetween: "4px"
};
</script>
<script>
window.addEventListener("DOMContentLoaded", function() {
  const checkElements = setInterval(function() {
    const priceElement = document.querySelector(".product-price-value");
    const cartTextElement = document.querySelector(".add-to-cart-text");
    if (priceElement && cartTextElement && !document.querySelector(".injected-price")) {
      const priceText = priceElement.textContent.trim();
      const originalText = cartTextElement.textContent.trim();
      cartTextElement.innerHTML = "<span class='injected-price' style='display:block; font-size:" + priceOptions.fontSize + "; margin-bottom:" + priceOptions.spaceBetween + ";'>" + priceText + "</span><span style='display:block;'>" + originalText + "</span>";
      clearInterval(checkElements);
    }
  }, 100);
  setTimeout(function() { clearInterval(checkElements); }, 5000);
});
</script>

07.26c07v7 Price in Add to Cart

#2. Customize

#2.1. To change Price size, change Line 04

fontSize: "18px",

#2.2. To change space between Price – Add to Cart, change Line 05

spaceBetween: "4px"

 

Buy me a coffee