$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>plugins - how woocommerce swatch color name when hovered or selected|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

plugins - how woocommerce swatch color name when hovered or selected

matteradmin7PV0评论

I have the woocommerce plugin and the woocommerce swatches and photos extension that shows swatches instead of variations as a drop down.

When hovering over the swatches and when a swatch is selected, I would like to be able to see the name of the color above the color table.

enter link description here

like the link above

please and thank you for your help

I have the woocommerce plugin and the woocommerce swatches and photos extension that shows swatches instead of variations as a drop down.

When hovering over the swatches and when a swatch is selected, I would like to be able to see the name of the color above the color table.

enter link description here

like the link above

please and thank you for your help

Share Improve this question asked Sep 10, 2013 at 5:48 anmareeanmaree 1111 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 1

I’ve got it to show the variation name in a separate div on “hover”, but not yet on “click” as there seems to be a conflict somewhere with WooCommerce.

First of all, place an empty div somewhere on the single product page in your child theme, I'm using /single-product/meta.php.

My div looks like this: <div id="colour-name"></div>.

Then you can use the following javascript to show the variation name:

$j=jQuery.noConflict();
$j(document).ready(function() { 
  $j(".swatch-anchor").hover(function() {
  var newTitle = $j(this).attr("title");
  $j("#colour-name").html(newTitle);
  },
  function() {
  var swapTitle = $j("#colour-name").html();
  $j(this).attr("title",swapTitle);
  $j("#colour-name").html("");
});});
Post a comment

comment list (0)

  1. No comments so far