Dynamic Background Colour

This topic contains 2 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 2 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #40377
    mikemoded
    mikemoded
    Participant

    Hi there.

    The plugin is great, but there’s some unique functionality I require and without it, the plugin is no use to me. My client sells paint and each WooCommerce product has a custom field $rgb_values that define the colour of a swatch. I would like to show that colour as the background colour of the search results product image.

    You can see an example here https://www.advancedpaints.co.uk/product/pantone-012-012/ where the yellow background colour of the product image is set dynamically based on this custom field.

    I have found the relevant code in /ajax-search-pro/includes/views/results/vertical.php and can hard code an RGB value into the image background colour on the results. What I’m trying to achieve is setting that value dynamically for the individual products shown in the search results.

    I guess that this field will need setting up in your functions.php file or directly in vertical.php, but I can’t figure out how to make it available to the script? I do realise this is a customisation, but if you could provide any suggested code to pull in a custom Woocommerce product field into your script it would be amazing. I’ve spent hours trying to find a solution. I’m sure it’s an easy thing for you guys.

    Thanks,

    Mike.

    #40378
    mikemoded
    mikemoded
    Participant

    Pleased to report that this is now resolved. Try searching ‘pantone’ on this demo page and you’ll see each paint colour has a dynamically generated background colour.

    https://www.advancedpaints.co.uk/aerosols-pantone/

    #40396
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    All right, I will mark this as resolved then, great job!

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.