Jump to content

[Share] Product Custom Badges

Recommended Posts

(This for 7.1. I haven't tested with 7.0 yet)

Suppose we need to create 3 custom badges: Books, Digital, Bike on Products on Store/Category Pages

image.thumb.png.c7ee828e73a54ad90af3925440a7cdee.png

First you need to create 3 tags: Books, Digital, Bike and assign them on products

image.thumb.png.12d15275054e293ccf6abfed482c10a4.png

Next, add this code into Design > Custom CSS

/* Badge: Books */
.tag-books:after {
    content: "Books";
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: #f1f2f3;
    padding-left: 10px;
    padding-right: 10px;
    color: red;
    font-weight: 600;
    font-size: 14px;
}
/* Badge: Digital */
.tag-digital:after {
    content: "Digital";
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: violet;
    padding-left: 10px;
    padding-right: 10px;
    color: white;
    font-weight: 600;
    font-size: 14px;
}
/* Badge: Bike */
.tag-bike:after {
    content: "Bike";
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: #000;
    padding-left: 10px;
    padding-right: 10px;
    color: white;
    font-weight: 600;
    font-size: 14px;
}

You can do similar for other badges.

Result

image.thumb.png.c7ee828e73a54ad90af3925440a7cdee.png

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
14 minutes ago, GastonDuflos said:

Hi @tuanphan thank you so much for this post.

I tried in my customm css but it didnt work for some reason.

This is my shop page: https://www.gastonduflos.com/shop

I've crated the tags: Sold out, New, Limited availability 

You haven't rename tag name in the example code yet. Use this

 

.tag-limited-availability:after {
    content: "LIMITED AVAILABILITY";
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: #f1f2f3;
    padding-left: 10px;
    padding-right: 10px;
    color: red;
    font-weight: 600;
    font-size: 14px
}

.tag-sold-out:after {
    content: "SOLD OUT";
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: violet;
    padding-left: 10px;
    padding-right: 10px;
    color: #fff;
    font-weight: 600;
    font-size: 14px
}

.tag-new:after {
    content: "New";
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: #000;
    padding-left: 10px;
    padding-right: 10px;
    color: #fff;
    font-weight: 600;
    font-size: 14px
}

image.thumb.png.bcaab8f9f21aafc17979cd29970e7cc5.png

Note: If a product has 2 tags, the code will conflict together

Edited by tuanphan

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
On 5/13/2023 at 10:14 AM, GastonDuflos said:

thanks @tuanphan now it works perfect! I just wondering if can the position be changed like the attached image here? Problem with the code is that in phone, the badge is overlapping the image. 

Screenshot 2023-05-13 at 1.12.47 pm.png

DO this position on mobile only or both desktop + mobile?

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment

For example: Tag New

Change current code

.tag-new:after {
    content: "New";
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: #a0cc49;
    padding-left: 10px;
    padding-right: 10px;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
}

to this new code

.tag-new .grid-meta-wrapper:before {
    content: "New";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    background-color: #a0cc49;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
}
div.tag-new section.grid-meta-wrapper {
    position: relative;
    padding-top: 30px;
    margin: 0 !important;
}

image.thumb.png.de4579a21cec9250eabf6fc6c44d41f5.png

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
  • 2 months later...
On 7/19/2023 at 5:13 PM, GastonDuflos said:

Hi @tuanphan thank you so much, this worked perfect! 

I now would like to edit the badge once inside the product page. Its showing the badge on the right upper corner of the page. Can we move it somewhere else? Maybe on top of the image? Or under the price? Thank you so much!

 

Page: https://www.gastonduflos.com/shop/p/sea-of-dreams

 

Screenshot 2023-07-19 at 8.13.08 pm.png

Use this CSS code

body.view-item .tag-sold-out:after {
    display: none;
}
body.view-item .tag-sold-out .ProductItem-gallery-slides-item:before {
    content: "Sold Out";
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: #ff593c;
    padding-left: 10px;
    padding-right: 10px;
    color: #fff;
    font-weight: 600;
    font-size: 15px;
}

image.thumb.png.d0bd41a01555f2dcca05ca5219b4e16e.png

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
On 7/21/2023 at 8:58 PM, tuanphan said:

Use this CSS code

body.view-item .tag-sold-out:after {
    display: none;
}
body.view-item .tag-sold-out .ProductItem-gallery-slides-item:before {
    content: "Sold Out";
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: #ff593c;
    padding-left: 10px;
    padding-right: 10px;
    color: #fff;
    font-weight: 600;
    font-size: 15px;
}

image.thumb.png.d0bd41a01555f2dcca05ca5219b4e16e.png

Thank you so much! It looks awesome!

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.