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 a Mega Menu and Dropdown Menu Simultaneously in the Header of Shopify's Dawn Theme

Creating an intuitive and comprehensive navigation menu is crucial for an effective online store. Shopify's Dawn theme offers flexibility to add both a mega menu and a dropdown menu in your header. This guide will walk you through the steps to integrate these menus seamlessly.



Step 1: Add the Required HTML Structure

First, you need to update your theme's HTML structure to support both mega menus and dropdown menus. Here’s the updated HTML structure for your navigation menu. Please open the snippets/header-mega-menu.liquid and paste the code given below

<nav class="header__inline-menu">
  <ul class="list-menu list-menu--inline" role="list">
    {%- for link in section.settings.menu.links -%}
      <li>
        {%- if link.links != blank -%}
          {%- assign is_mega_menu = false -%}
          {%- for block in section.blocks -%}
            {%- if block.type == 'menu' and block.settings.mega_menu_name == link.title -%}
              {%- assign is_mega_menu = true -%}
              {%- break -%}
            {%- endif -%}
          {%- endfor -%}

          {%- if is_mega_menu -%}
            <!-- Mega Menu -->
            <header-menu>
              <details id="Details-HeaderMenu-{{ link.handle }}" class="mega-menu">
                <div class="mega-menu-connector"><holder></holder></div>
                <summary
                  id="HeaderMenu-{{ link.handle }}"
                  class="header__menu-item list-menu__item link focus-inset"
                >
                  <span
                    {%- if link.child_active %}
                      class="header__active-menu-item"
                    {% endif %}
                  >
                    {{- link.title | escape }}
                  </span>
                  {% render 'icon-caret' %}
                </summary>
                <div
                  id="MegaMenu-Content-{{ link.handle }}"
                  class="mega-menu__content gradient motion-reduce global-settings-popup"
                  tabindex="-1"
                >
                  <ul
                    class="mega-menu__list page-width{% if link.levels == 1 %} mega-menu__list--condensed{% endif %}"
                    role="list"
                  >
                    {%- for childlink in link.links -%}
                      <li>
                        <a
                          id="HeaderMenu-{{ link.handle }}-{{ childlink.handle }}"
                          href="{{ childlink.url }}"
                          class="mega-menu__link mega-menu__link--level-2 link{% if childlink.current %} mega-menu__link--active{% endif %}"
                          {% if childlink.current %}
                            aria-current="page"
                          {% endif %}
                        >
                          {{ childlink.title | escape }}
                        </a>
                        {%- if childlink.links != blank -%}
                          <ul class="list-unstyled" role="list">
                            {%- for grandchildlink in childlink.links -%}
                              <li>
                                <a
                                  id="HeaderMenu-{{ link.handle }}-{{ childlink.handle }}-{{ grandchildlink.handle }}"
                                  href="{{ grandchildlink.url }}"
                                  class="mega-menu__link link{% if grandchildlink.current %} mega-menu__link--active{% endif %}"
                                  {% if grandchildlink.current %}
                                    aria-current="page"
                                  {% endif %}
                                >
                                  {{ grandchildlink.title | escape }}
                                </a>
                              </li>
                            {%- endfor -%}
                          </ul>
                        {%- endif -%}
                      </li>
                    {%- endfor -%}
                  </ul>
                </div>
              </details>
            </header-menu>
          {%- else -%}
            <!-- Dropdown Menu -->
            <header-menu>
              <details id="Details-HeaderMenu-{{ link.handle }}">
                <summary
                  id="HeaderMenu-{{ link.handle }}"
                  class="header__menu-item list-menu__item link focus-inset"
                >
                  <span
                    {%- if link.child_active %}
                      class="header__active-menu-item"
                    {% endif %}
                  >
                    {{- link.title | escape }}
                  </span>
                  {% render 'icon-caret' %}
                </summary>
                <ul
                  id="HeaderMenu-MenuList-{{ link.handle }}"
                  class="header__submenu list-menu list-menu--disclosure gradient caption-large motion-reduce global-settings-popup"
                  role="list"
                  tabindex="-1"
                >
                  {%- for childlink in link.links -%}
                    <li>
                      {%- if childlink.links == blank -%}
                        <a
                          id="HeaderMenu-{{ link.handle }}-{{ childlink.handle }}"
                          href="{{ childlink.url }}"
                          class="header__menu-item list-menu__item link link--text focus-inset caption-large{% if childlink.current %} list-menu__item--active{% endif %}"
                          {% if childlink.current %}
                            aria-current="page"
                          {% endif %}
                        >
                          {{ childlink.title | escape }}
                        </a>
                      {%- else -%}
                        <details id="Details-HeaderSubMenu-{{ link.handle }}-{{ childlink.handle }}">
                          <summary
                            id="HeaderMenu-{{ link.handle }}-{{ childlink.handle }}"
                            class="header__menu-item link link--text list-menu__item focus-inset caption-large"
                          >
                            <span>{{ childlink.title | escape }}</span>
                            {% render 'icon-caret' %}
                          </summary>
                          <ul
                            id="HeaderMenu-SubMenuList-{{ link.handle }}-{{ childlink.handle }}"
                            class="header__submenu list-menu motion-reduce"
                          >
                            {%- for grandchildlink in childlink.links -%}
                              <li>
                                <a
                                  id="HeaderMenu-{{ link.handle }}-{{ childlink.handle }}-{{ grandchildlink.handle }}"
                                  href="{{ grandchildlink.url }}"
                                  class="header__menu-item list-menu__item link link--text focus-inset caption-large{% if grandchildlink.current %} list-menu__item--active{% endif %}"
                                  {% if grandchildlink.current %}
                                    aria-current="page"
                                  {% endif %}
                                >
                                  {{ grandchildlink.title | escape }}
                                </a>
                              </li>
                            {%- endfor -%}
                          </ul>
                        </details>
                      {%- endif -%}
                    </li>
                  {%- endfor -%}
                </ul>
              </details>
            </header-menu>
          {%- endif -%}
        {%- else -%}
          <a
            id="HeaderMenu-{{ link.handle }}"
            href="{{ link.url }}"
            class="header__menu-item list-menu__item link link--text focus-inset"
            {% if link.current %}
              aria-current="page"
            {% endif %}
          >
            <span
              {%- if link.current %}
                class="header__active-menu-item"
              {% endif %}
            >
              {{- link.title | escape }}
            </span>
          </a>
        {%- endif -%}
      </li>
    {%- endfor -%}
  </ul>
</nav>

Step 2: Style the Menus with CSS

Next, you'll need to add some CSS to ensure that the menus display correctly. Here are the styles you need to include:

<style>
  /* Ensure submenus are hidden by default */
.header__submenu {
  display: none;
}
.header__submenu li{
  position: relative;
}

/* Show submenus when their parent <details> element is open */
details[open] > ul.header__submenu {
  display: block;
}

/* Style for nested submenus to align correctly */
.header__submenu .header__submenu {
  position: absolute;
  left: 100%;
  top: 0;
  background: #fff;
  padding-left: 10px; /* Padding for spacing */
  margin-left: 1px; /* Counteract padding for proper alignment */
  width: 20rem;
  min-width: 100%;
  border:1px solid #c1c1c1;
}
  .mega-menu-connector {
    position: relative;
    display: flex;
    justify-content: center;
  }

  .mega-menu-connector:after {
    content: '';
    width: 100%;
    position: absolute;
    opacity: 0;
    padding-top: 2.4rem;
    padding-bottom: 2.4rem;
  }

  .menu-6 ul.mega-menu__list.page-width.mega-menu__list--condensed {
    display: block !important;
  }
</style>

Step 3: Add Interactivity with JavaScript

To make the menus interactive, you need to add some JavaScript. Here’s the script you should include:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script>
  $(document).ready(function(){
    $('.mega-menu').hover(
      function() {
        $(this).find('.mega-menu__content').toggleClass('mega-menu-open');
      }
    );

    document.querySelectorAll(".header__inline-menu details.mega-menu").forEach(item => {
      const toggleOpen = (state) => item.toggleAttribute("open", state);
      item.addEventListener("mouseover", () => toggleOpen(true));
      item.addEventListener("mouseleave", () => toggleOpen(false));
      item.querySelector(".mega-menu__content").addEventListener("mouseover", () => toggleOpen(true));
      item.querySelector(".mega-menu__content").addEventListener("mouseleave", () => toggleOpen(false));
    });
  });
</script>

<script>
  $(document).ready(function() {
    $(".header__inline-menu details").on("mouseover", function() {
      $(this).attr("open", true);
    });

    $(".header__inline-menu details").on("mouseleave", function() {
      $(this).removeAttr("open");
    });

    $(".header__inline-menu details ul").on("mouseleave", function() {
      $(this).closest("details").removeAttr("open");
    });
  });
</script>

Step 4: Add the Schema to the Header File

This schema will allow you to define and customize the mega menu from the Shopify admin interface.

{
  "type": "menu",
  "name": "Mega menu",
  "settings": [
    {
      "type": "text",
      "id": "mega_menu_name",
      "label": "Mega Menu Name",
      "default": "Main Menu"
    }
  ]
}

Conclusion

By following these steps, you can add both a mega menu and a dropdown menu to the header of the Shopify Dawn theme. This integration will enhance your store's navigation, providing a better user experience for your customers. Customize the styles and interactivity further to match your store’s design and functionality requirements. Happy coding!

Comments

  1. Wow Great. Thank You So Much, This Worked Perfectly!

    ReplyDelete
  2. Thank you so much! Amazing! Works. Q - how to make main sub-menu in menu with Bold font?

    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 ...

Create a Dynamic Video Slider with Customization Options in shopify

 In the fast-paced world of digital content, captivating your audience's attention is crucial. One effective way to engage your viewers is through dynamic video sliders, seamlessly blending visuals with interactivity. Today, we unveil a versatile solution that not only showcases your video content but also offers customization options to align with your brand's identity. Unveiling the Interface Our video slider combines sleek design with intuitive functionality. Let's dive into its key components: Background Customization: Set the stage with a background color of your choice to complement your brand's aesthetic. Engaging Heading and Text: Craft a compelling message with customizable heading and descriptive text, ensuring your audience stays informed and intrigued. Interactive Play Button: Enhance user engagement with a play button overlay, enticing viewers to interact with your video content. Navigation Arrows: Navigate through the slider effortlessly with customiza...