I am building my new site, and am currently trying to change the background of the product details section based on which variant is selected.
For example:
Variant A selected = Red background
Variant B selected = Blue background
I currently have the following implemented as a Custom Liquid block on the main editor page, but it’s in no way dynamic:
.very-large-row-under, .breadcrumbs-container {
background: red !important;
}
(this will change the section background and breadcrumb container background to red)
My question is, what do I need to add to this to have the background change colour depending on the variant selection? I have tried exploring changes based on the URL (as each variant has a unique path), but that didn’t work as expected.
Can you share your website link? The task is doable, however, it can get pretty complex. If you don’t have coding experience, I’d suggest to hire a developer.
There are a few ways. Like you mentioned inspecting the URL, as well the click event when a variant is selected. Do all your products have the colour in the name? If so it’s a JS code snippet would do the trick.