Add a rating tool into your webshop

Add a rating widget in your SimplyEdit webpage or webshop

SimplyEdit
SimplyEdit
3 min readOct 12, 2017

--

A starry rating tool which can be simply integrated into your own webpage or webshop

Adding a rating tool into your SimplyEdit webpage or webshop is really simple. Here’s a short guide about building the starry tool into your code.

Rating-Widget is a popular tool to include and it is simple as well. First create an account at http://rating-widget.com/. Just click on ‘Get my free widget’. There you can set all kinds of styling preferences and download a small piece of javascript, like this:

You can add this to your webpage, and add the rating widget container to the product template. However, there are two things that need a tweak to work with SimplyEdit:

First, if you have more than one product on a page, you also need more than one rating widget. So you need the `data-title` attribute and you must be able to edit this in SimplyEdit as well. So add the following to the product template:

Second, the Rating-Widget javascript code must run after SimplyEdit has rendered all the content, otherwise it may run before the `data-title` fields are set correctly. So instead of the original javascript, change it slightly like this:

As you can see, we wrapped the original javascript code inside an EventListener. SimplyEdit fires an event called ‘simply-content-loaded’ immediately after the page is rendered and all the information is available. At that point the rating widget has the data-title attribute and only then can it initialize its javascript code.

And that’s it. You’ve added a simple rating tool into your webshop or website.
If you have read our previous article: You now have a complete webshop, with user ratings. You may need to setup some more stuff in Snipcart, but the Snipcart website and dashboard will help you get that sorted.

--

--