Text on product page gets removed when switching variant (example: color or size)

TrendBlend
Explorer
105 0 13

https://codeshare.io/pAAolE this is my current code which results in this:

Schermafbeelding 2024-02-28 123036.png

 

But when I switch color (Grijs -> Zwart) for example all text is removed can anyone help me so that that doesn't happen? Thanks in advance

Replies 8 (8)

TrendBlend
Explorer
105 0 13

The text that gets deleted is this part

7C2A5488-F63E-402A-B4EF-521B819903A8.jpeg

so the text from the code but how can I make it that it doesn’t remove the text when changing variant? The text is not removed when refreshing

JohnE10
Shopify Partner
112 14 19

Hi,

 

I could be wrong, but I think a better way to add the text is by adding a custom liquid block to your product page template. It's easy to add one, it can be styled and made to look the way you want it, it can even be made dynamic in case you want to show different messages for different products, and It's sure to appear with all variants on the page.

 

Hope that helps.

If my reply was helpful, Like and Accept. Or Buy Me a Beverage
App Development/Custom Modifications, Visit My Gig and let me how I can help
For help with your store speed optimization, Check Out My Other Gig
Feel free to email with any questions: ProjectCoder10@gmail.com
TrendBlend
Explorer
105 0 13

Hello @JohnE10 do you also know if this can be achieved by some code in the main-product-page? Ive tried to add an eventlistener for when the variant changes but it did not work.

TrendBlend
Explorer
105 0 13

I mean main-product.liquid

JohnE10
Shopify Partner
112 14 19

I'm sure it could depending on the theme/code.

If my reply was helpful, Like and Accept. Or Buy Me a Beverage
App Development/Custom Modifications, Visit My Gig and let me how I can help
For help with your store speed optimization, Check Out My Other Gig
Feel free to email with any questions: ProjectCoder10@gmail.com
TrendBlend
Explorer
105 0 13

Yeah I got it by updating the product page when the url switches

TrendBlend
Explorer
105 0 13

Thanks for thinking with me tough

JohnE10
Shopify Partner
112 14 19

You bet. Good to hear you got it working.

If my reply was helpful, Like and Accept. Or Buy Me a Beverage
App Development/Custom Modifications, Visit My Gig and let me how I can help
For help with your store speed optimization, Check Out My Other Gig
Feel free to email with any questions: ProjectCoder10@gmail.com