Shopify themes, liquid, logos, and UX
Sorry you are facing this issue, it would be my pleasure to help you.
Welcome to the Shopify community!😊
Thanks for your good question.
Please share your site URL,
I will check out the issue and provide you a solution here.
Hi @Moise75,
This is Victor from PageFly - Landing Page Builder App
You can try this code by following these steps:
Go to Online Store->Theme->Edit code theme.liquid paste my code before </body> element
<script>
window.onload=()=>{
const changeColor=()=>{
const variant=document.querySelectorAll('fieldset')
variant.forEach(v=>{
const infor=v.closest('.product__info-wrapper');
const title=infor.querySelector('.product__title h1')
const inputs=v.querySelectorAll('input[name="Color"]')
if(inputs.length>0){
inputs.forEach(input=>{
if(input.checked){
const value=input.value;
const checkLenght=value.indexOf(' ');
if(checkLenght<0){
title.style.color=`${value}`
}else{
const newColor=value.slice(checkLenght+1);
title.style.color=`${newColor}`
}
}
})
}
})
}
changeColor();
document.querySelectorAll('fieldset input[name="Color"]').forEach(item=>{
item.onclick=()=>changeColor()
})
}
</script>
Hope my solution works perfectly for you!
Regards,
Victor | PageFly
how can I change the title then? Will that work for only this product?
this only change the color I don't want the color to be change I want the title to change is it's black t-shirt change it to black T-shirt instead of Green
You can try again with this code:
<script>
window.onload=()=>{
const changeColor=()=>{
const variant=document.querySelectorAll('fieldset')
variant.forEach(v=>{
const infor=v.closest('.product__info-wrapper');
const title=infor.querySelector('.product__title h1')
const inputs=v.querySelectorAll('input[name="Color"]')
if(inputs.length>0){
inputs.forEach(input=>{
if(input.checked){
const value=input.value;
const content=title.innerText
title.innerText=content.slice(0,content.indexOf('-')-1) + value
}
})
}
})
}
changeColor();
document.querySelectorAll('fieldset input[name="Color"]').forEach(item=>{
item.onclick=()=>changeColor()
})
}
</script>
Hope my solution works perfectly for you!
Regards,
Victor | PageFly
User | RANK |
---|---|
74 | |
74 | |
69 | |
65 | |
40 |
As a business owner, have you ever wondered when your customer's first impression of yo...
By Skye Jun 6, 2023We're excited to announce improvements to the threaded messaging experience in our communi...
By TyW May 31, 2023Thank you to everyone who participated in our AMA with Klaviyo. It was great to see so man...
By Jacqui May 30, 2023