Skip to main content

Widget Customization Guide

This guide provides JavaScript snippets to control the visibility and behavior of Trustoo widgets on specific pages of your store.

1. Widget Visibility Control (Show/Hide)

Use these snippets to manage the display of all widgets or specifically the Review Widget based on the page URL.

1.1 All Widgets (Star Ratings & Review Sections)

Use Case: Controls everything including star ratings, the main review widget, and the "no reviews" wrapper.

  • Show ONLY on a specific page:
    if (location.pathname !== "/products/target-page-path") {
    u.vstarCustomSty = `.trustoo-widget, .vstar-star, #noreviews-wrapper { display: none !important; }`;
    }
  • Hide on a specific page:
    if (location.pathname === "/products/target-page-path") {
    u.vstarCustomSty = `.trustoo-widget, .vstar-star, #noreviews-wrapper { display: none !important; }`;
    }

1.2 Review Widget ONLY

Use Case: Specifically targets the main review section while leaving star ratings unaffected.

  • Show ONLY on a specific page:
    if (location.pathname !== "/products/target-page-path") {
    u.vstarCustomSty = `div#vstar-reviews, div#noreviews-wrapper{display: none;}`;
    }
  • Hide on a specific page:
    if (location.pathname === "/products/target-page-path") {
    u.vstarCustomSty = `div#vstar-reviews, div#noreviews-wrapper{display: none;}`;
    }

How to Apply the Code

To implement any of the solutions above, follow these precise steps:

  1. Access Settings: Log in to the Trustoo admin panel and go to the "Customize functions" section.
  2. Input Code: Locate the text box labeled "Before execution function".
  3. Paste Snippet: Copy the desired JavaScript code from above and paste it into the box.
    • Note: Ensure you replace the placeholder URL (e.g., /products/target-page-path) with your actual page path.
  4. Configure Type: In the "Type" dropdown menu, select Common.
  5. Save & Execute: Click the Execute button to apply the logic to your live store.

2. Star Ratings on Custom Pages

Use this snippet to enable star rating widgets on non-standard pages (e.g., landing pages or custom "About Us" pages) where they do not load by default.

2.1 Enable Stars on Custom URL

Use Case: Forces the widget to initialize on a page containing a specific keyword in the URL.

  • Code Snippet:
    if (location.href.includes("/custom-page-keyword")) {
    u.otherPageColl = true;
    }

How to Apply the Code

To implement any of the solutions above, follow these precise steps:

  1. Access Settings: Log in to the Trustoo admin panel and go to the "Customize functions" section.
  2. Input Code: Locate the text box labeled "Before execution function".
  3. Paste Snippet: Copy the desired JavaScript code from above and paste it into the box.
    • Note: Ensure you replace the placeholder URL (e.g., /products/target-page-path) with your actual page path.
  4. Configure Type: In the "Type" dropdown menu, select Common.
  5. Save & Execute: Click the Execute button to apply the logic to your live store.