Set default WooCommerce colors

Here’s a handy bit of PHP code to put into your ‘after_setup_theme’ WordPress hook:

        $default_colors = get_option('woocommerce_frontend_css_colors');
        Defaults are: 
        [primary] => #ad74a2
        [secondary] => #f7f6f7
        [highlight] => #85ad74
        [content_bg] => #ffffff
        [subtext] => #777777 
        if(!$default_colors || !$default_colors['primary'] || $default_colors['primary'] == '#ad74a2'){
                'primary' => '#a38530', 
                'secondary' => '#fddc8f', 
                'highlight' => '#a38530',
                'content_bg' => '#ffffff',
                'subtext' => '#777777',

This will allow you to match the WooCommerce colors with a newly installed theme. The user can change these default colors using the built in WooCommerce color picker on the Settings page.

I have used this above code on the new Sunny Kids WordPress Theme which you can see here: – notice the colors through out the WooCommerce shop. Much easier (and more user configurable) doing it this way than hardcoding new colors into CSS files.

Leave a Reply

Your email address will not be published.