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)
293 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

  144. 100mg viagra without a doctor prescription

    100mg viagra without a doctor prescription

  145. natural viagra

    natural viagra

  146. viagra on line

    viagra on line

  147. over the counter viagra

    over the counter viagra

  148. female viagra pills

    female viagra pills

  149. viagra for men

    viagra for men

  150. viagra for women

    viagra for women

  151. viagra without a doctor prescription

    viagra without a doctor prescription

  152. viagra without a doctor prescription usa

    viagra without a doctor prescription usa

  153. viagra medicine online order

    viagra medicine online order

  154. viagra without doctor prescription usa

    viagra without doctor prescription usa

  155. cialis generico

    cialis generico

  156. cialis generika

    cialis generika

  157. tadalafila says:

    tadalafila

    tadalafila

  158. can amitriptyline cause poor judgement

    can amitriptyline cause poor judgement

  159. mixing baclofen and weed side effects

    mixing baclofen and weed side effects

  160. escitalopram oxalate 10mg v. citalopram

    escitalopram oxalate 10mg v. citalopram

  161. prednisone dose pack

    prednisone dose pack

  162. Viagra vs viagra http://albulu.strikingly.com/

    This is nicely expressed! .

  163. Cialis 20 mg says:

    tadalafil generic http://cialisvi.com/

    Valuable facts. Thanks.

  164. cialis cost says:

    cialis cost

    cialis cost

  165. cialis cooupons

    cialis cooupons

  166. cialis free trial

    cialis free trial

  167. atorvastatin says:

    atorvastatin

    atorvastatin

  168. cymbalta says:

    cymbalta

    cymbalta

  169. levitra generic

    levitra generic

  170. atorvastatin 10 mg

    atorvastatin 10 mg

  171. cymbalta dosage

    cymbalta dosage

  172. cialis online pharmacy

    cialis online pharmacy

  173. atorvastatin 10mg

    atorvastatin 10mg

  174. cymbalta for pain

    cymbalta for pain

  175. levitra 20 mg

    levitra 20 mg

  176. cymbalta generic

    cymbalta generic

  177. levitra coupon

    levitra coupon

  178. cymbalta medication

    cymbalta medication

  179. levitra dosage

    levitra dosage

  180. cialis side effects

    cialis side effects

  181. cymbalta reviews

    cymbalta reviews

  182. cymbalta side effects

    cymbalta side effects

  183. levitra vs viagra

    levitra vs viagra

  184. cymbalta withdrawal

    cymbalta withdrawal

  185. vardenafil says:

    vardenafil

    vardenafil

  186. duloxetine says:

    duloxetine

    duloxetine

  187. vardenafil 20 mg

    vardenafil 20 mg

  188. duloxetine 20 mg

    duloxetine 20 mg

  189. vardenafil 20mg

    vardenafil 20mg

  190. duloxetine hcl

    duloxetine hcl

  191. duloxetine side effectss

    duloxetine side effectss

  192. duloxetine 60 mg

    duloxetine 60 mg

  193. Canadian Pharmacies Shipping to USA http://www.buylevitraa.com/

    Amazing a lot of beneficial data!

  194. canadian government approved pharmacies http://www.viagravonline.com/

    Amazing info. Many thanks.

  195. canadian pharmacy no prescription http://www.viagravonline.com/

    You actually mentioned it terrifically.

  196. generic levitra

    generic levitra

  197. dutch women viagra

    dutch women viagra

  198. generic viagra online pharmacy

    generic viagra online pharmacy

  199. cialis over the counter at walmart

    cialis over the counter at walmart

  200. pfizer generic viagra

    pfizer generic viagra

  201. sildenafil 20 mg tablet vs viagra

    sildenafil 20 mg tablet vs viagra

  202. sophia viagra

    sophia viagra

  203. viagra dosage recommendations

    viagra dosage recommendations

  204. viagra for sale

    viagra for sale

  205. cialis generic availability

    cialis generic availability

  206. cialis generic name

    cialis generic name

  207. cialis generic tadalafil

    cialis generic tadalafil

  208. viagra online canada pharmacy

    viagra online canada pharmacy

  209. cialis generic tadalafil 10mg

    cialis generic tadalafil 10mg

  210. cialis generic tadalafil 60mg

    cialis generic tadalafil 60mg

  211. cialis generic tadalafil walmart

    cialis generic tadalafil walmart

  212. cialis generic tadalafil for sale

    cialis generic tadalafil for sale

  213. cialis generic tadalafil india

    cialis generic tadalafil india

  214. viagra sex says:

    viagra sex

    viagra sex

  215. cialis prices 10mg

    cialis prices 10mg

  216. viagra side effects

    viagra side effects

  217. cialis prices 100mg

    cialis prices 100mg

  218. viagra without a doctor prescription from canada

    viagra without a doctor prescription from canada

  219. cialis prices 20mg

    cialis prices 20mg

  220. cialis prices 5mg

    cialis prices 5mg

  221. generic cialis tadalafil 20mg

    generic cialis tadalafil 20mg

  222. cialis prices walmart

    cialis prices walmart

  223. generic cialis pricing

    generic cialis pricing

  224. best place to buy cialis online without script

    best place to buy cialis online without script

  225. generic viagra sildenafil citrate

    generic viagra sildenafil citrate

  226. buy cialis canada online

    buy cialis canada online

  227. buy cialis generic tadalafil

    buy cialis generic tadalafil

  228. sildenafil 100mg tablets

    sildenafil 100mg tablets

  229. buy cialis online without script

    buy cialis online without script

  230. sildenafil 20 mg tablet

    sildenafil 20 mg tablet

  231. where can i buy cialis over the counter at walmart

    where can i buy cialis over the counter at walmart

  232. where to buy cialis online safely

    where to buy cialis online safely

  233. sildenafil citrate 20 mg

    sildenafil citrate 20 mg

  234. sildenafil dosage

    sildenafil dosage

  235. sildenafil side effects

    sildenafil side effects

  236. 5mg cialis says:

    5mg cialis

    5mg cialis

  237. canadian viagra

    canadian viagra

  238. buying cialis online

    buying cialis online

  239. canadian cialis

    canadian cialis

  240. canadian pharmacy cialis

    canadian pharmacy cialis

  241. cost of viagra

    cost of viagra

  242. cheap cialis generic

    cheap cialis generic

  243. cheap generic cialis

    cheap generic cialis

  244. generic viagra prices

    generic viagra prices

  245. cialis 5mg says:

    cialis 5mg

    cialis 5mg

  246. herbal viagra

    herbal viagra

  247. cialis black says:

    cialis black

    cialis black

  248. marley generic viagra

    marley generic viagra

  249. cialis daily says:

    cialis daily

    cialis daily

  250. online pharmacy viagra

    online pharmacy viagra

  251. cialis for sale

    cialis for sale

  252. online viagra

    online viagra

  253. cialis from canada

    cialis from canada

  254. real viagra says:

    real viagra

    real viagra

  255. cialis generic canada

    cialis generic canada

  256. cialis on line

    cialis on line

  257. viagra alternative

    viagra alternative

  258. viagra cost says:

    viagra cost

    viagra cost

  259. cialis price says:

    cialis price

    cialis price

  260. cialis vs levitra

    cialis vs levitra

  261. viagra in action

    viagra in action

  262. cost of cialis

    cost of cialis

  263. generic cialis canada

    generic cialis canada

  264. viagra online pharmacy

    viagra online pharmacy

  265. generic cialis online

    generic cialis online

  266. viagra pill says:

    viagra pill

    viagra pill

  267. generic for cialis

    generic for cialis

  268. viagra price says:

    viagra price

    viagra price

  269. natural cialis

    natural cialis

  270. no prescription cialis

    no prescription cialis

  271. canadianpharmacy http://www.buylevitraa.com/

    You actually suggested that exceptionally well!

  272. top rated online canadian pharmacies http://www.viagravipsale.com/

    You actually reported it fantastically.

  273. pharmacy canada http://www.viagraessale.com/

    Regards, A lot of forum posts.

  274. drugstore online http://www.viagrayosale.com/

    Nicely expressed certainly. !

  275. viagra pills says:

    northwest pharmacies http://www.viagravonline.com/

    You actually said that effectively!

  276. canadian pharmacies shipping to usa http://canadianpharmacyes.com/

    Thanks, I value it!

  277. trust pharmacy canada http://canadianpharmacyonl.com/

    Excellent advice. Thanks a lot!

  278. canadian discount pharmacies http://canadianorderpharmacy.com/

    Thanks, Awesome stuff!

  279. best canadian pharmacy http://canadiantousapharmacy.com/

    Seriously lots of fantastic advice!

  280. northwest pharmacies http://ukcanadianpharmacy.com/

    You suggested this exceptionally well.

  281. buy viagra usa http://babecolate.com/

    Kudos. Lots of write ups.

  282. buy cialis says:

    canada online pharmacies http://babecolate.com/

    Very good posts. Thanks a lot!

  283. cialis 20mg says:

    canadian pharmacies http://babecolate.com/

    You actually mentioned that effectively!

  284. canadian pharmacycanadian pharmacy http://canadianpharmacyes.com/

    Reliable information. Cheers.

  285. cialis canadian pharmacy http://withoutadoctor.viagraiy.com/

    Thank you, Terrific stuff!

  286. viagra generic availability

    viagra generic availability

  287. generic cialis at walmart

    generic cialis at walmart

  288. buy generic cialis

    buy generic cialis

Leave a Reply