Hello.

 

I'd like to add a badge on top of all my product images in both the collection list and product page similar to this page. 

 

<https://arielblankets.com/>

 

I would like my badge to automatically calculate savings percentage from the compare price & sale price. The badge would say something like "You Save 48%".

 

Can anyone help me with the code I need to add?

 

Thank you.





 
 Solved!
 
 [Go to the solution](/c/Shopify-Design/Add-Sales-Badge-Over-Product-Image/m-p/613744#M153762)
Hello [figgy911](https://community.shopify.com/c/user/viewprofilepage/user-id/614952),  
  
Here is code which you can use to display sale badge  



```
{% if product.compare\_at\_price\_max > product.price %}You Save {{ product.compare\_at\_price\_max | minus: product.price | times: 100.0 | divided\_by: product.compare\_at\_price\_max | money\_without\_currency | times: 100 | remove: '.0'}}% {% endif %}
```
Note: You have to add it in collection and product template a/to theme also have to adjust css accordingly.  
  
Thanks



 Want to modify or custom changes on store hire me.  
My Email: guleriathakur43@gmail.com  
Skype: navrocks1  
If helpful then please Like and Accept Solution.  
If you are happy and want to donate small [Click here](https://www.paypal.me/guleria88) (Its my paypal)
try this mate. replacing images and links with your own.



```
<center><script language="JavaScript">
<!--
// Create arrays to contain all the values 
// for links and image locations
link = new Array
image = new Array

link[1]="[http://www.wildexpo.com.au/Aust%20Rep%20Show/](/posts/bad_link/469772?url=http%3A%2F%2Fwww.wildexpo.com.au%2FAust%2520Rep%2520Show%2F)"
image[1]="[http://www.reptilesaustralia.com.au/forums/Ads/wildexpo.gif](/posts/bad_link/469772?url=http%3A%2F%2Fwww.reptilesaustralia.com.au%2Fforums%2FAds%2Fwildexpo.gif)"

link[2]="[http://www.freewebs.com/langylot/](/posts/bad_link/469772?url=http%3A%2F%2Fwww.freewebs.com%2Flangylot%2F)"
image[2]="<http://i14.photobucket.com/albums/a345/Instar/reptilemad.jpg>"

link[3]="[http://www.theherphouse.com/](/posts/bad_link/469772?url=http%3A%2F%2Fwww.theherphouse.com%2F)"
image[3]="[http://www.theherphouse.com/mkportal/templates/default/images/logo.jpg](/posts/bad_link/469772?url=http%3A%2F%2Fwww.theherphouse.com%2Fmkportal%2Ftemplates%2Fdefault%2Fimages%2Flogo.jpg)"

link[4]="[http://www.aftcra.org.au/](/posts/bad_link/469772?url=http%3A%2F%2Fwww.aftcra.org.au%2F)"
image[4]="<http://i14.photobucket.com/albums/a345/Instar/adimage2.jpg>"

link[5]="<http://reptilesaustralia.com.au/index.html>"
image[5]="<http://i14.photobucket.com/albums/a345/Instar/reptilesaustralia.jpg>"

link[6]="<http://www.zoomed.com/>"
image[6]="[http://www.reptilesaustralia.com.au/forums/Ads/zoomed.jpg](/posts/bad_link/469772?url=http%3A%2F%2Fwww.reptilesaustralia.com.au%2Fforums%2FAds%2Fzoomed.jpg)"

link[7]="<http://www.reptilepark.com.au/>"
image[7]="<http://i14.photobucket.com/albums/a345/Instar/arpbanner468x60.jpg>"

link[8]="<http://www.wildlifewarriors.org.au/>"
image[8]="<http://i14.photobucket.com/albums/a345/Instar/www_banner.jpg>"

link[9]="[http://saveourreptiles.proboards50.com/index.cgi](/posts/bad_link/469772?url=http%3A%2F%2Fsaveourreptiles.proboards50.com%2Findex.cgi)"
image[9]="<http://i50.photobucket.com/albums/f335/lnvexotics/Untitled-1undoner11.jpg>"

// Create a random number between 1 and last number
random_num = (Math.round((Math.random()*8)+1))
// Write a link and images with random array
document.write('<a href="' + link[random_num] + '" target="_blank">'); 
document.write('<img src="' + image[random_num] + '" border="0"></a>'); 
-->
</script>
</center>
``` rates on get4x can be managed through the rates section on the dashboard, by going to rates > your rates, or digital storefront > rates. hi, kimberly! ordering and pre-purchasing photo credits, beverage packages or a spa treatment from the gifts & amenities page on disneycruise.com serve as a convenience for guests and one less thing to think about when you're in vacation mode once you're on board. it also is a great way for friends and family who may or may not be traveling with you to celebrate your vacation and help pay for extra, on-board expenses from a distance. for instance, when we were on board celebrating our 20th anniversary, we had friends who had ordered a wine package for us as a congratulatory wish. we were stunned when our server came to our table with our friends' well wishes, and it was such a treat each night at dinner to be reminded of our friends back at home. in addition to possibly being able to save a few dollars by pre-purchasing, the photo credits help to keep you in check since there are so many photos taken during the course of a cruise. you can agree on an amount/budget for photos before you leave home, pre-purchase that amount and choose accordingly once you're on board. i hope this helps clear things up for you. let me know if i can answer any more questions for you. have a wonderful day and a magical vacation. bon voyage, andi besides what [@trevorhodges](/u/trevorhodges) said with [codepen.io](http://codepen.io), you can use a about:blank. next inspect, then add your code. my browser is generally chrome, and it works for me. basically, you could use picking from the camera to the center of the tag position to see if it is behind something.

if yes, you could manually adapt the style. <p>google's above the fold page layout algorithm looks at how much good, helpful content is visible without scrolling:</p>
<p>&nbsp;</p>
<p>https://webmasters.googleblog.com/2012/01/page-layout-algorithm-improvement.html</p>
<p>there is often a struggle between designers and seos because it sure looks nice to have a big huge image taking up all of the above the fold content but if there is no or limited helpful text there then that's not good from an seo standpoint.</p>
<p>with that said, google will still index content that is below the fold. it's debatable whether it's given the same weight as content higher up on a page though. matt cutts from google has said before that a link that is higher up on a page is not worth any more than a link lower down on the page. however, some <a href="https://moz.com/blog/10-illustrations-on-search-engines-valuation-of-links">experiments</a> by moz contradict this.&nbsp;</p>
<p>this might be a fun experiment to do - create content both above and below a hero image and see what ranks best. i might even do that!</p>
<p>marie</p> using a gas credit card is merely one of the ways that you can save on fuel consumption. you can also use a website like gasbuddy, which identifies the lowest gas prices in your area. and many supermarkets have loyalty programs that allow you to earn gas rebates when you shop. so opening the gas reward credit card tied to the same gas station as your supermarket loyalty program is a great way to save extra. hi dear. you can easily save a lot of money by making a few changes in your lifestyle. when you go grocery shopping, try to buy products that are of local brands, fruits and vegetables that are seasonal, bulk packets, etc. always make a list when you go shopping as it helps in avoiding unnecessary expenses. you can easily make a lot of crafts at home to decorate your house or for gifting such as lamps, photo frames, cushions, etc. make a monthly budget where you keep aside some amount to save. try to stick to the budget to save more. you can use the negative lookbehind (?<!sub +) to skip matching "sub " in front of “total”.

(?<=(?<!sub +)(total amount|\btotal\b|total due|total amount due)\s+)(zar|r|)[\s-$\d,.]+

[[image]](https://aws1.discourse-cdn.com/uipath/original/3x/7/7/771d2a72ff53c33207c48813c7b379782be96d4f.png "image") depending if you want to physically add a back return into the code, of if you want to only format the display of the code, you will have to apply different solution

1 if you want to change the code... search and replace using reg exp

search (<p[^+>]*>)|(<\/p>)|(<img[^+>]*>)

replace by $1$2$3<br>

2 if you want to display code format differently

go on edition > bibliotheque de balises...

search for you concerned tag and edit the line retun pop up

![](/legacyfs/online/1611145_pastedImage_0.png)