hello,
Just wondering how can i add a price on the add to cart button on the product page.
i tried using this code here, it works however when a variant of the product is selected the price will disappear.
<script>
try{
setTimeout(() => {
document.querySelector('.product-form__submit.button span').innerHTML = document.querySelector('.product-form__submit.button span').innerHTML.trim() + ' ' +document.querySelector('.price-item.price-item--sale.price-item--last').innerHTML.trim()
},300)
} catch {}
</script>
link to my website: https://notonlywater.com.au/
any help is appreciated!
thankyou
1 Like
Hello @LeviFurey ,
To make it work you need a callback function of JS.
But it will not work until you will not refine the first step code to apply price with the atc button.
I mean in my opinion the JS code you are using to apply price with the atc button is completely wrong.
You need to edit the product template, search for existing price code, copy that code and apply with the atc button.
Then the second step will start to change it on change of the variant.
Regards
Guleria
thankyou for getting back to me.
could you tell me step by step how to do this im only a beginner at CSS,
If this is an issue or this requirement is related to css definitely I provide a step by step instructions.
But this requirement need customization of code part. And if you are not good with that then I suggest you to go with a developer who will write code a/to your requirement.
im good with css i just need a step by step instructions to follow so i can do it
Hi @LeviFurey
Please add this code more in buy button liquid
Above is the result
I hope this helps
Best,
Daisy
thankyou for getting back to me i tried it but it dosnt work.
the price comes up, but as soon as i choose a different variant the price tag disappears.
thanks
1 Like
Hello @LeviFurey
Which theme are you using?
Hi @LeviFurey
This task requires more advanced coding, and unfortunately, it cannot be achieved by simply adding a straightforward code. It would likely require custom development. I suggest reaching out to an external developer who can help implement this solution.
Best,
Daisy