insert text above 'add to cart' button on product pages

apexbiking
New Member
2 0 0

Hi all,

 

Im hoping someone can help.

 

I am looking to add text, specifically 'free 72hr delivery guaranteed!' above the 'add to cart' button on my product page (link attached below).

 

https://apexbikingaccessories.co.uk/products/inbike-anti-shear-thief-deterrent-bike-lock

 

I want this to do the same on all product pages.

 

Please can someone advise/ offer a solution?

 

Thanks,

Jack

@apexbikingaccessories

0 Likes

Hey,

1. In your Shopify Admin go to online store > themes > actions > edit code
2. In your theme.liquid file, find the </body> (press CTRL + F or command + F on Mac)
3. paste this code right above the </body> tag:



 

<script>
function addText(){

var fontSize = 20;
var text = `free 72hr delivery guaranteed!`;

var atc = document.getElementById(`AddToCart-product-template`);
if (!atc) return;


var html = `<p class="custom-atc-text" style="text-align:center;font-size:${fontSize}px;">${text}</p>`
atc.insertAdjacentHTML(`beforebegin`, html)

}

addText();
</script>

 


you can change the "text" and "fontSize" values to your liking.

Let me know how it goes.

◦ Problem Solved? ✔️ Please click on Accept as Solution and like.
◦ How to add a slider & thumbnails to product page images: Minimal theme | Debut theme | Brooklyn theme
◦ Replace apps with simple copy/paste code snippets. Examples clicking here.
0 Likes
Mattia234
Tourist
4 0 1

Hi, it seems it's not working...

Did i make it wrong? 

Schermata 2020-11-11 alle 11.17.29.png

moe6
New Member
2 0 0

hi 

i would like to add "Availability: Usually leaves warehouse in 2-3 business day" above add to cart in supply theme. can you help? thanks

0 Likes