Ecommerce Shopify WordPress Discussion

Issue with Rendering Image Swatch Colors on Product Page

I am currently working on a project where I need to implement image swatches on a product page. However, I seem to be facing an issue with the code I have used the following code for the image swatches, but it does not seem to be working as expected class ColorName extends HTMLElement { constructor() { super(); this.color = this.parentNode.innerText; this.optionSelects = this.parentNode.parentNode; this.optionSelects.addEventListener( "change", this.colorRender.bind(this) ); THIS.colorRender(); console.log(this); console.log(this.color); console.log(this.optionSelects); } colorRender() { this.selectedColor = document.querySelector( `input[name="Color"]:checked` ).value; this.innerText = this.selectedColor.charAt(0).toUpperCase() + this.selectedColor.slice(1); } } customElements.define("color-name", ColorName); class SizeName extends HTMLElement { constructor() { super(); this.size = this.parentNode.innerText; this.optionSelects = this.parentNode.parentNode; this.optionSelects.addEventListener( "change", this.sizeRender.bind(this) ); THIS.sizeRender(); console.log(this); console.log(this.size); console.log(this.optionSelects); } sizeRender() { this.selectedSize = document.querySelector( `input[name="Size"]:checked` ).value; this.innerText = this.selectedSize.toUpperCase(); this.innerText = this.selectedSize.charAt(0).toUpperCase() + this.selectedColor.slice(1); } } I am unsure of what I am doing wrong here. I have tried reaching out to the original developer for assistance, but have not received a response yet.
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.