When No Variation Image Available… (WooCommerce)

I had an interesting problem to solve today. I was working on a WooCommerce site with the Wootique theme, and we have products with lots of variations, but only some of the variations have their own image.

We wanted at way to put some kind of overlay on the product image when a variation is selected for which we have no picture. The featured product photo happens to be one of the variations, so we don’t want it just reverting back. The ideal situation involves keeping the featured product photo but doing some semi-transparent overlay with an apology message about viewing our fabrics page to get a look at the available fabrics for the item.

Overlay Design Goal

Even if that wasn’t possible, a good second would have been the ability to bulk update the variation images, but we are a little strapped for cash on this project so we weren’t going to invest in one of the bulk products plugins just for this. So that was out — instead it fell to me to program some kind of solution.

The first part of this task was the most tedius, poring over the code in an attempt to find the most appropriate JavaScript event to hook into, around the time that the user selects a new variation to view. Fortunately there was a suitably appropriate event which passed along exactly the needed information when triggered. Here’s how to capture it:

1
2
3
4
5
6
7
8
jQuery(".single_variation_wrap").on("show_variation",function(e, variation_data){
if(variation_data["image_src"]==""){
//add overlay
}
else{
//remove overlay
}
})

Another small challenge was finding the appropriate time to capture an event for the “Clear Selection” option. The overlay needed to be removed at that time as well as in the else branch above. Fortunately that one was a little easier to find, now that I knew my way around a little more of the add-to-cart-variation JavaScript file that comes with WooCommerce.

1
2
3
jQuery(".variations_form").on("reset_image",function(){
//remove the overlay
})

From there it was trivial to find the appropriate elements and modify them. My complete solution is in this zip file as a plugin. You will probably need to replace the ‘sorry.png’ file with one of your own. It’s not my most robust WP plugin ever, but it gets the job done.

Tagged with: , , , ,
Posted in Career, Code for Fun
0 comments on “When No Variation Image Available… (WooCommerce)
146 Pings/Trackbacks for "When No Variation Image Available… (WooCommerce)"
  1. … [Trackback]…

    […] Find More Informations here: abbysdoor.com/when-no-variation-image-available/ […]…

  2. Livermore CA says:

    … [Trackback]…

    […] Informations on that Topic: abbysdoor.com/when-no-variation-image-available/ […]…

  3. Manassas VA says:

    … [Trackback]…

    […] Read More Infos here: abbysdoor.com/when-no-variation-image-available/ […]…

  4. … [Trackback]…

    […] There you will find 77927 more Infos: abbysdoor.com/when-no-variation-image-available/ […]…

  5. more says:

    … [Trackback]…

    […] Read More: abbysdoor.com/when-no-variation-image-available/ […]…

  6. … [Trackback]…

    […] Read More here: abbysdoor.com/when-no-variation-image-available/ […]…

  7. … [Trackback]…

    […] Read More here: abbysdoor.com/when-no-variation-image-available/ […]…

  8. … [Trackback]…

    […] Read More Infos here: abbysdoor.com/when-no-variation-image-available/ […]…

  9. phentermine says:

    … [Trackback]…

    […] Read More here: abbysdoor.com/when-no-variation-image-available/ […]…

  10. hampton bay says:

    … [Trackback]…

    […] Read More: abbysdoor.com/when-no-variation-image-available/ […]…

  11. url opener says:

    this is really a nice post….

    I saw this really good post today….

  12. said, “if you wish to converse with…

    me, define your terms.” when trying to convey your thoughts to someone else it will be to your advantage to organize your thoughts into a coherent message before you start talking. stay on point and do not dilute your message with…

  13. strategies for success.because technical writers work primarily…

    in information technology-related industries, they need specialized capabilities and knowledge which may be beyond the skill set of the typical grant writer. however, good technical writers are also experts in less technical areas critical to those pur…

  14. wanted to write. instead of just sitting…

    down at the computer as i had always done, i went and bought “the chicago manual of style”. for those that don’t know, this book lays out the general rules and requirements that people expect to see from your work in…

  15. a blogger? a blogger is a person…

    that owns a blog and writes content for it. so what is a blog?a blog is basically a website that consists of posts about a certain topic. they are used to interact and communicate with people all over the world. everyone…

  16. other “quality” violations like spelling and grammar…

    mistakes. a catchy title that creates an impact is the essence of blog writing. readers shall base their decision to read the article through only after looking at the title. as for search engines – include your strongest search terms (keywords)…

  17. this is really a nice post….

    I saw this really good post today….

  18. this is really a nice post….

    I saw this really great post today….

  19. this is really a nice post….

    I saw this really great post today….

  20. this is really a nice post….

    I saw this really good post today….

  21. charge for the word count. let’s say…

    one word will cost you 10 cent. now your next step is to decide on how big articles your business requires to write a really informative article on the topic. other blog writing companies charge for the quality level of content…

  22. … [Trackback]…

    […] Read More here: abbysdoor.com/when-no-variation-image-available/ […]…

  23. Gerda Bosch says:

    will always result to perfection. practice the…

    guide above with dedication and it will be in no time that you will be writing your own bestseller. the single biggest problem in communication is the illusion that it has taken place.”~ george bernard shawfor many, the word “communication” is…

  24. for your blog.conclusion: this topic is so…

    diverse, there is a lot more to say about the mistakes. feel free to use the comments section below to share the mistakes you see bloggers making. in this time and age the easiest way to connect and engage further with…

  25. quality in order to avoid getting stuck…

    paying for potentially sub-par articles or content.seo article and content writing is an important aspect of many websites to attract potential customers. contact a writing service today to get more information. when you start writing your article a cl…

  26. m88 says:

    such sites. don’t commit to big jobs…

    straightaway, because quite often the people you are writing content for live in other countries. you can’t meet them, and phoning would be prohibitively expensive, unless you both have skype. you have no way of knowing how reliable they are until…

  27. content is a necessity. the majority of…

    bloggers who never succeed discover that it is hard to get anything of value from their blogs. this is usually because they are doing too much to optimize their blog for the search engines or they are looking for shortcuts to…

  28. this is really a nice post….

    I saw this really good post today….

  29. directory says:

    find and pinpoint certain resources in your…

    genre and list them in a way that would be beneficial to your audience. people love to instantly know where to go especially when the work has already been done for them.this is just the tip of the iceberg, there are…

  30. Continued says:

    in being interviewed you can just send…

    them a list of questions that they can answer on their own time. you readers will appreciate getting an outside point of view and if the person you are interviewing is an expert then that’s just all the better.start researchingas a…

  31. why i enjoy (nay love) wordpress.first and…

    foremost, it’s so easy to use. when you first approach learning how to use it, it may seem bewildering. i have been using xsitepro for years and felt daunted by wordpress until i actually stopped watching all the videos available on…

  32. Friv Games says:

    … [Trackback]…

    […] There you will find 27977 more Infos: abbysdoor.com/when-no-variation-image-available/ […]…

  33. technical writing. therefore, simplicity is a very…

    important attribute of a good technical writer.conciseness is another major attribute of a good technical writer. a writer should be able to provide the user with all the information that is needed without going overboard with the words. too much infor…

  34. akismet- great plugin that stops spamming comments…

    and deletes automatically saving you the time and annoyance of having to go through the comments left by people pushing porn or viagra! akismet is usually pre-loaded into wordpress and should be found in the plugin section. this will need a…

  35. neglect but you can have the trust…

    of the figures that show that once you pass the pqq stage with a good impression on the client, you are likely to get the contract.like they say, “well begun is half done.” the cell phone has crept or really jumped…

  36. this is really a nice post….

    I saw this really great post today….

  37. them what i’m doing to be successful….

    i teach social media because i’m already doing it. i teach how to make money online because i’m already doing it. a few years ago, i wasn’t an expert in those subjects so i wouldn’t have been believable or credible.make sense?you…

  38. Netflix News says:

    into one post. your window of opportunity…

    is often narrow – people have short attentions spans – so keep your blog content to the point. and make it a good point.• make it easy to share. people will hit the ‘share’ button without a moments hesitation if it…

  39. upon that blog entry, read the review…

    and decide then and there that the product is worth trying.third, consider the number of people who will go on to write about your brand after seeing someone else do it. i don’t mean this in a derogatory way, but many…

  40. this is really a nice post.

    I saw this really good post today.

  41. […] is a followup to a post I made in 2013 with an early hacked-together version of the plugin. Here’s the main problem we needed to […]

  42. essayforme says:

    essay for me http://sertyumnt.com/

    What’s up Dear, are you in fact visiting this website daily, if so then you will without doubt get fastidious knowledge.

  43. Cialis 20mg prix en pharmacie http://kawanboni.com/

    Many thanks, Fantastic stuff!

  44. Viagra tablets http://rldta.com/

    With thanks! Good stuff!

  45. writeaessay says:

    essay for me http://dekrtyuijg.com/

    You actually said it perfectly.

  46. Cialis coupon http://cialisvipsale.com/

    You stated it superbly!

  47. Buy viagra online http://viagravipsale.com/

    With thanks. Lots of content!

  48. Cialis daily http://cialisyoues.com/

    Whoa tons of very good data!

  49. Viagra coupon http://viagravonline.com/

    Helpful postings. Thanks.

  50. cialis great britain http://cialisvus.com/

    Incredible lots of helpful info.

  51. cialis purchasing http://cialisbuys.com/

    Wow all kinds of valuable knowledge!

  52. cialis canada http://cialisonl.com/

    With thanks, I value it!

  53. cialis daily http://cialisees.com/

    Amazing all kinds of wonderful facts!

  54. writeessay says:

    write my college essay for me http://gsgfsdgfdhjhjhj.com/

    Information effectively taken.!

  55. Cialis 5 mg says:

    generic for cialis http://cialisky.com/

    You’ve made your point.

  56. viagra vs cialis vs levitra http://cialisiv.com/

    Thanks. An abundance of forum posts!

  57. Cialis cost says:

    buy cialis http://cialisvi.com/

    You actually revealed it well!

  58. cialis tablets australia http://cialisonla.com/

    Nicely put, Thank you.

  59. Cialis 20mg says:

    buy cialis without a doctor’s prescription http://cialisonli.com/

    You have made your position extremely nicely!!

  60. buy cialis says:

    buy cialis

    buy cialis

  61. tadalafil generic

    tadalafil generic

  62. sildenafil citrate

    sildenafil citrate

  63. sildenafil 100mg coupon

    sildenafil 100mg coupon

  64. buy viagra says:

    buy viagra

    buy viagra

  65. cialis says:

    cialis

    cialis

  66. sildenafil 100mg

    sildenafil 100mg

  67. cialis generic

    cialis generic

  68. cialis coupon

    cialis coupon

  69. cialis 20mg says:

    cialis 20mg

    cialis 20mg

  70. levitra says:

    levitra

    levitra

  71. generic cialis

    generic cialis

  72. cialis online

    cialis online

  73. tadalafil 5mg

    tadalafil 5mg

  74. tadalafil 20mg

    tadalafil 20mg

  75. viagra tablets

    viagra tablets

  76. sildenafil says:

    sildenafil

    sildenafil

  77. tadalafil says:

    tadalafil

    tadalafil

  78. cialis dosage

    cialis dosage

  79. cialis prices

    cialis prices

  80. cialis tablets

    cialis tablets

  81. viagra vs cialis

    viagra vs cialis

  82. generic viagra

    generic viagra

  83. viagra connect

    viagra connect

  84. viagra without doctor prescription

    viagra without doctor prescription

  85. viagra natural

    viagra natural

  86. cialis vs viagra

    cialis vs viagra

  87. tadalafil 20 mg

    tadalafil 20 mg

  88. cialis 20 mg says:

    cialis 20 mg

    cialis 20 mg

  89. cialis 5 mg says:

    cialis 5 mg

    cialis 5 mg

  90. cialis pills says:

    cialis pills

    cialis pills

  91. cheap cialis says:

    cheap cialis

    cheap cialis

  92. cialis coupons

    cialis coupons

  93. cialis canada

    cialis canada

  94. viagra pills says:

    viagra pills

    viagra pills

  95. viagra 100mg says:

    viagra 100mg

    viagra 100mg

  96. viagra online

    viagra online

  97. viagra prices

    viagra prices

  98. viagra generic

    viagra generic

  99. generic viagra 100mg

    generic viagra 100mg

  100. viagra coupons

    viagra coupons

  101. cheap viagra says:

    cheap viagra

    cheap viagra

  102. generic viagra available

    generic viagra available

  103. buy viagra online

    buy viagra online

  104. viagra tablet

    viagra tablet

  105. sildenafil 20 mg

    sildenafil 20 mg

  106. sildenafil 100

    sildenafil 100

  107. buy biaxin says:

    buy biaxin

    buy biaxin

  108. buy ceftin says:

    buy ceftin

    buy ceftin

  109. buy chloromycetin

    buy chloromycetin

  110. buy biaxin online

    buy biaxin online

  111. buy ceftin online

    buy ceftin online

  112. chloromycetin

    chloromycetin

  113. buy cordarone

    buy cordarone

  114. cialis 20mg generic

    cialis 20mg generic

  115. generic cialis 20mg

    generic cialis 20mg

  116. generic cialis available

    generic cialis available

  117. generic cialis tadalafil

    generic cialis tadalafil

  118. female viagra

    female viagra

  119. sildenafil tablets

    sildenafil tablets

  120. prednisone 20 mg

    prednisone 20 mg

  121. buy sildenafil

    buy sildenafil

  122. sildenafil generic

    sildenafil generic

  123. viagra doctor prescription

    viagra doctor prescription

  124. sildenafil 50 mg

    sildenafil 50 mg

  125. sildenafil coupons

    sildenafil coupons

  126. sildenafil 100 mg

    sildenafil 100 mg

  127. sildenafil citrate 100mg

    sildenafil citrate 100mg

  128. buy cialis online

    buy cialis online

  129. cialis tadalafil

    cialis tadalafil

  130. sildenafil citrate tablets

    sildenafil citrate tablets

  131. sildenafil citrate pricing

    sildenafil citrate pricing

  132. fluoxetine 20 mg

    fluoxetine 20 mg

  133. prozac generic

    prozac generic

  134. bactrim ds says:

    bactrim ds

    bactrim ds

  135. biaxin antibiotic

    biaxin antibiotic

  136. ceftin antibiotic

    ceftin antibiotic

  137. cephalexin 500mg

    cephalexin 500mg

  138. ciprofloxacin 500mg

    ciprofloxacin 500mg

  139. fluconazole 150 mg

    fluconazole 150 mg

  140. levofloxacin 500 mg

    levofloxacin 500 mg

  141. cefdinir 300 mg

    cefdinir 300 mg

  142. bactrim antibiotic

    bactrim antibiotic

  143. azithromycin 250 mg

    azithromycin 250 mg

Leave a Reply