Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Dynamic Background Colour
This topic contains 2 replies, has 2 voices, and was last updated by Ernest Marcinko 1 year, 4 months ago.
- AuthorPosts
- December 3, 2022 at 11:13 am #40377
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.
December 3, 2022 at 1:03 pm #40378Pleased 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.
December 5, 2022 at 1:53 pm #40396All 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 :)
- AuthorPosts
You must be logged in to reply to this topic.