Skip to main content

How to Add a Social Proof Block in Shopify Product Page (Dawn Theme)

 Adding social proof to your product pages can significantly increase trust and conversion rates. In this tutorial, we'll show you how to add a stylish Verified Testimonials block to your Shopify store using the Dawn theme . This block displays user avatars, names, and a verified icon—all customizable from the theme editor. ✅ Step 1: Open the main-product.liquid file Go to your Shopify Admin. Navigate to: Online Store → Themes → Edit code . Open the file: sections/main-product.liquid . Now add this code exactly as I’ve shown in the video — and yes, make sure to test it on a duplicate theme first! Full Code {%- when 'verified-testimonials' -%} <style> .verified-testimonials-container-{{block.id}} .verified-testimonials-user-icon-img-class { width: {{block.settings.verified_use...

How to add recently viewed products in shopify

 Have you ever visited a website, browsed through products, left, and then wanted to go back to something you saw earlier? It's a common online shopping experience, and it's precisely why we've implemented a new feature on our store: Recently Viewed Products for the Dawn theme.



Introducing Recently Viewed Products

Our Recent Products section keeps track of the items you've recently browsed, making it easier for you to revisit them without having to search all over again. It's like your personal shopping assistant, remembering your preferences and making your shopping experience more convenient.

How It Works

Behind the scenes, our website cleverly saves the details of the products you've viewed using advanced JavaScript techniques. Here's a quick rundown of how it operates:

Data Collection: Whenever you view a product page, our website captures essential details like the product title, image, price, and URL.

Local Storage: This information is securely stored in your browser's local storage, ensuring that it's accessible whenever you return to our site.

Display: The Recent Products section dynamically fetches this data and displays it for your convenience, allowing you to quickly jump back to any item you've recently checked out.

Customizable Title

You can customize the title of the Recently Viewed Products section to suit your preferences. Whether you prefer "Recently Viewed" or something more personalized, you can easily adjust it in the settings.

How to Access

Finding the Recently Viewed Products section is a breeze. Simply navigate to our homepage, and you'll spot it prominently displayed, ready to show you the items you've been eyeing.

Try It Out Today!

Ready to experience the convenience of Recently Viewed Products? Head over to our store now and start exploring. Whether you're planning your next purchase or simply revisiting items you loved, this feature makes your shopping journey smoother than ever.

Update Instructions

To enable the Recent Products section on your store, follow these simple steps:

Create a New Section File: Add the provided code snippet to a new file named recent-products.liquid.

<div class="page-width">

    <h2 class="product-recommendations__heading h2 center">{{ section.settings.heading | escape }}</h2>

    <ul class="recently-viewed grid product-grid grid--4-col-desktop grid--2-col-tablet-down" role="list">

    <!-- Recently viewed products will appear here -->

    </ul>

</div>


<script>

function setRecentlyViewedProducts() {

  const productData = {

    productTitle: "{{ product.title }}",

    productImg: "{{ product.featured_media | image_url: width: 533 }}",

    imgWidth:"{{ product.featured_media.width }}",

    imgHeight:"{{ product.featured_media.height }}",

    productPrice: "{{ product.price | money_with_currency }}",

    productUrl: "{{ product.url }}",

    productImageAltText: "{{product.featured_media.alt | escape }}"

  };

  const productList = [];

  let jsonResp, jsonRespArr, jsonRespArrStr;

  const numberOfProducts = 4;

  productList.push(productData);

  const currProductPageTitle = productData.productTitle;

  const productDataString = JSON.stringify(productList);

  const localData = localStorage.getItem("recentlyViewedProduct");


  if (localData === null) {

    localStorage.setItem("recentlyViewedProduct", productDataString);

  } else if (localData) {

    const oldProductData = localStorage.getItem("recentlyViewedProduct");

    const countProductData = (oldProductData.match(/productTitle/g) || []).length;

    const sameProduct = oldProductData.includes(currProductPageTitle);

    if (countProductData < numberOfProducts && sameProduct == false) {

      jsonResp = JSON.parse(oldProductData);

      jsonRespArr = jsonResp.concat(productList);

      jsonRespArrStr = JSON.stringify(jsonRespArr);

      localStorage.setItem("recentlyViewedProduct", jsonRespArrStr);

    } else if (countProductData >= numberOfProducts && sameProduct == false) {

      jsonResp = JSON.parse(oldProductData);

      jsonResp.shift();

      jsonRespArr = jsonResp.concat(productList);

      jsonRespArr = JSON.stringify(jsonRespArr);

      localStorage.setItem("recentlyViewedProduct", jsonRespArr);

    }

  }

}


setRecentlyViewedProducts();

const localViewed = localStorage.recentlyViewedProduct;

function getRecentlyViewedProducts() {

  const productData = JSON.parse(localStorage.getItem("recentlyViewedProduct"));

  const recentlyViewedHtml = [];

  productData.map(item => {

    recentlyViewedHtml.unshift(`

    <li class="grid__item">

     <div class="card-wrapper underline-links-hover">

      <div class="card card--standard card--media " style="--ratio-percent: 100%;">

        <div class="card__inner color-background-2 gradient ratio" style="--ratio-percent: 100%;">

         <div style="position:static" class="card__media">

         <div class="media media--transparent media--hover-effect">

      <img class="motion-reduce" src="${item.productImg}" width="${item.imgWidth}" height="${item.imgHeight}"  loading="lazy" alt="${item.productImageAltText}"/>

         </div>

         </div>

       </div>

       <div class="card__content">

       <div class="card__information">

       <h3 class="card__heading h5">

       <a class="full-unstyled-link" href="${item.productUrl}">${item.productTitle}</a></h3>

         <div class="card-information">

           <div class="price ">

             <div class="price__container">

               <div class="price-item price-item--regular">

                   ${item.productPrice}

               </div>

             </div>

           </div>

         </div>

       </div>

       </div>

       </div>

       </div>

    </li>

   `);

  });

  const newProductData = `${recentlyViewedHtml.join("")}`;

  const fullContent = document.getElementsByClassName("recently-viewed");

  fullContent[0].innerHTML = newProductData;

}


document.addEventListener("DOMContentLoaded", function (event) {

  getRecentlyViewedProducts();

});


</script>



{% schema %}

  {

    "name": "Recent Products",

    "settings": [

      {

      "type": "text",

      "id": "heading",

      "default": "Recently Viewed",

      "label": "Title"

    }

    ]

  }

{% endschema %}

Update Product JSON: Include the details of the Recent Products section in your product.json file within the Templates folder.

    "recent-products": {

      "type": "recent-products",

      "settings": {

      }

    }

Add to Order: Don't forget to add the section name to the order to ensure it appears correctly on your store.

  "order": [

    "main",

    "related-products",

    "recent-products" // Add this in order

  ]

}

That's it! With these updates in place, your customers can enjoy the benefits of the Recently Viewed Products feature on your store.

Enhance your store's functionality and make shopping more convenient for your customers with the Recent Products section. Try it out today and elevate your online shopping experience!

Comments

  1. Great post! Really enjoyed reading it.

    ReplyDelete
  2. Great Tutorial, I lovt it.
    How can i the description of the product and the prize in the middle? Now, the information ist in the left, but i try to put it in the middle under the picture

    ReplyDelete
    Replies
    1. Thank you for your kind words! I can definitely help you center the product description and price under the picture. Please send me an email with the details, and I'll take care of it for you!

      Delete
  3. Hi, I am trying to add a new constant, but its value is always undefined. For example:
    productTitle: "{{ product.title }}" -> output "Blablabla",
    but productSomething: "{{ product.title }}" -> output "undefined"
    why ???

    ReplyDelete
  4. Hi one more time,
    Problem has been resolved! The missing line was localStorage.clear()

    ReplyDelete
  5. First of all, thank you!
    My plan was to use this -instead- of Related Products. However, when I hide the Related Products (using Customization) , the images disappear from Recent Products. Is there anything I can do about that?

    ReplyDelete
    Replies
    1. Hi, Can you please let me know which theme are you using

      Delete
  6. Hi thank you this works very well. But I did notice a small issue when i viewed on mobile. When there is no item image populating the recent items, i see a question mark "?", in place of the image. Anyway to get rid of this question mark "?". Thank you.

    ReplyDelete
    Replies
    1. Yes, I can help you with this. Can you share the link of your store with me in my email is and also a screenshot so that I can check it once?

      Delete
  7. Olá, obrigado, isso funciona muito bem. Mas notei um pequeno problema quando visualizei no celular. Quando não há imagem de item preenchendo os itens recentes, vejo um ponto de interrogação "?", no lugar da imagem. De qualquer forma, para se livrar desse ponto de interrogação "?". Obrigado.

    ReplyDelete
    Replies
    1. marcusvpereiras@gmail.com, me envie um email que te envio prints.

      Delete
    2. Alright, I have sent the code to your email.

      Delete
  8. Hi, this was very helpful :D I was just wondering if it's possible to make the header be left centered?

    ReplyDelete
    Replies
    1. Hi, yes it is possible. Please message me on my email id.

      Delete
  9. I just entered this code. It is working partially. Images are showing , but not in the slider format. Each image is huge and occupying the entire desktop screen . Kindly help.

    ReplyDelete
  10. my Shopify theme is Ella 6.0

    ReplyDelete
    Replies
    1. Can you send me the theme to my email... because this code is only for the Dawn theme.

      Delete
    2. Okay.Can you send me the theme to my email... because this code is only for the Dawn theme.

      Delete
  11. Thanks for your response. I have mailed you the theme and my Website link.

    ReplyDelete
    Replies
    1. Hi, i have not recived yet your email...please email me on this shopifycheatcode@gmail.com

      Delete
  12. Have resent you the Email . You can search for my mail using my email ID, surabhitripathi@gmail.com.

    ReplyDelete

Post a Comment

Popular posts from this blog

How to create a Image scrolling/marquee section in Shopify theme

We are excited to unveil our latest addition to the customization options for your website: the Image Marquee section. This dynamic feature allows you to create a continuous scrolling display of your brand logos, offering a visually engaging way to showcase your partners, sponsors, or featured brands. Let's dive into the features and customization options available with the Image Marquee section. Key Features Continuous Scrolling Animation : The marquee animation provides a smooth, continuous scroll of images, giving your site a modern and dynamic feel. Responsive Design : The section is fully responsive, ensuring that your logos look great on desktops, tablets, and mobile devices. Customizable Speed and Direction : Adjust the scroll speed and choose the direction of the animation to fit your design preferences. Interactive Elements : You can enable or disable the pause-on-hover feature, giving visitors the option to pause the marquee for a closer look at the logos. Styling Option...

How to Create Fake Sales Pop-Ups on Your Shopify Store

 How to Create Fake Sales Pop-Ups on Your Shopify Store Adding sales pop-ups to your Shopify store can create a sense of urgency and social proof, encouraging potential customers to make a purchase. While it's always best to be transparent and honest with your customers, some store owners may choose to implement fake sales pop-ups to simulate recent purchases. Here's a step-by-step guide on how to create such pop-ups using custom code in your Shopify store. Step 1: Create a New Section First, you'll need to create a new section in your Shopify theme. To do this, follow these steps: Go to the Shopify Admin Dashboard . Navigate to Online Store > Themes . Click on Actions > Edit Code for the theme you want to modify. Under the Sections directory, click on Add a new section . Name the section customer-purchased . Conclusion This guide walks you through creating a fake sales pop-up on your Shopify store using a custom section. Full code ...

🔥 How to Create Stunning Section Dividers in Shopify

 Creating visually striking section dividers is a fantastic way to enhance the design and flow of your Shopify store. Section dividers can break the monotony of a page, guide the user’s eye, and add a professional touch to your site’s layout. In this blog, we'll explore how to create custom section dividers in Shopify using Liquid , CSS , and Schema options for maximum flexibility. 🛠 Why Use Section Dividers? Improve Visual Appeal : Add flair to your design and make transitions between sections seamless. Enhance Branding : Use custom shapes or patterns that reflect your brand identity. Guide User Attention : Direct users to specific sections like promotions, testimonials, or CTAs. Create Distinction : Separate content effectively to improve readability and layout organization. 📝 How to Add Custom Section Dividers in Shopify Follow these steps to create and customize section dividers: 1️⃣ Add a Section File Log in to your Shopify admin and navigate to Online Store > Themes . C...