Setting colours for colour swatches
A colour swatch needs a colour value, but WooCommerce attributes only store names. The plugin fills that gap in two ways: it recognises standard colour names on its own, and it gives you a screen to set the exact colour for every other name.
Standard colour names work straight away
If your colour attribute is called Color (internal name pa_color) and an option’s slug matches a standard web colour name, the dot is coloured automatically. That covers about 140 names, including:
black,white,greyandgray,silverred,crimson,maroon,pink,hotpinknavy,blue,royalblue,skyblue,tealgreen,olive,forestgreen,limeyellow,gold,orange,coral,brown,tan,beigepurple,violet,lavender,indigo
The match uses the option’s slug, the URL-friendly name you see at Products › Attributes › Configure terms. “Navy” with slug navy works. “Navy Blue” with slug navy-blue doesn’t, because there’s no standard colour of that name. For those, set the colour yourself as below.
Setting your own colours
Most shops use names like “Sage”, “Oat” or “Midnight”. You can set each one to an exact colour on the Colours tab of the plugin’s own settings page. No other plugin is needed.
- Make sure the colour options exist under Products › Attributes › Configure terms.
- Go to C4D › Swatches › Colours.
- Each option of your colour attribute has a colour picker. Pick the colour, or paste a hex code such as
#9caf88. Argb()orrgba()value works too. - Click Save Changes.
To clear a colour, empty its field and save. The colour you set here wins over the standard name, so you can also correct a standard colour. If your “Red” is really a brick red, set it to the shade that matches the product.
If the Colours tab says no colour attribute with terms was found, the attribute name doesn’t match. See the next section.
If your colour attribute isn’t called “color”
The Colours tab lists the options of one attribute. By default that’s the attribute named color. If yours is called something else, such as colour or shade:
- Go to C4D › Swatches › General.
- Enter the attribute’s name in Colour attribute name, without the
pa_prefix, and save. - Open the Colours tab. The colour pickers now list that attribute’s options.
This setting only decides which options the Colours tab lists. On the product page, the plugin applies colours to the swatches of an attribute whose internal name is pa_color (and to custom attributes named color or colors). On shop pages it applies them to any attribute. If your attribute has another name, add one CSS rule per colour on the Custom CSS tab, for example:
.c4d-woo-vs-single-list-box .c4d-woo-vs-attribute_pa_colour-sage {
background-color: #9caf88;
}
Getting colours right
A few habits make colour swatches more useful:
- Take the colour from the product photo, not the supplier’s name. Open a product photo in any image editor and use its colour picker on a well-lit area of the fabric or surface.
- Avoid pure white dots on a white page. Pick a very light grey such as
#f2f2f2, or add a border with CSS. Style swatches with CSS has an example. - Use an image swatch for mixed colours. A “black/white stripe” is clearer as a photo than any single colour.
- Keep names readable. The tooltip shows the option name when a customer hovers over a dot, so “Sage” is better than “SG-04”.