# Introduction to Dukaan Themes

Dukaan themes are a collection of templates, stylesheets, and scripts that determine the look and feel of your online store. They are built using a combination of HTML, CSS, JavaScript, and the Nunjucks templating language. Customizing your theme allows you to create a unique shopping experience tailored to your brand and audience.

## 😎 If you're not a coder&#x20;

We recommend that you learn about the basics of HTML, CSS, JS (can also skip this if you're really good at Googling :wink:) and then start with the tutorial from the [next chapter](/building-your-own-custom-theme).

## 🧑‍💻 If you're a coder

Brush up on your HTML, CSS & JS skills and top it with some Nunjucks. If you're not aware of Nunjucks worry not we have covered the basics of it here in the [Nunjucks chapter](/nunjucks-templating-language).

## 🛠️ Cut the fluff and just show me how to deploy

You can directly learn about deploying your changes [from this chapter](/making-your-first-edit).

<br>


# Building your own custom theme

Before you start building your custom theme, you must have a Dukaan account.

Sign up for a free Dukaan account to access theme development resources (You can create your dukaan account [here](https://web.mydukaan.io/))\
\
Once your account is created we're all set get tinkering.

To make your custom theme you'll get HTML, CSS & JS files with the bare minimum amount of code which is required and you can build on top of that.


# Getting the basics right

* Login to your Dukaan account here - [web.mydukaan.io](https://web.mydukaan.io/)
* Then click on the "**Appearance"** section on the left hand navigation pane\
  ![](https://869317877-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEpxvKr8371wMxhqFS6hu%2Fuploads%2FSaJ7Yai3Iooc8wyTNSIV%2FScreenshot%202023-03-27%20at%2015.59.24.png?alt=media\&token=9489138e-716e-4bcf-abd6-1199a3df2557)
* In the Appearance tab you will have a list of all themes.
* The first theme card is the theme which is currently applied on your store, click on "**Customize"** button
* Here, click on "**Code editor"** button to build your magic\
  ![](https://869317877-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEpxvKr8371wMxhqFS6hu%2Fuploads%2FpQTkckM63S4tLDsptvtd%2FScreenshot%202023-03-27%20at%2016.07.42.png?alt=media\&token=ae238b13-2bd2-4273-aac4-83abd864f737)


# Making your first edit

Before we dive deep into folder structure, customizing components, functions and all, let's just try to make a simple change to see how it looks like.

This is how the **"Code Editor"** page looks like. Please ensure you are on this page before we proceed further.\
![](https://869317877-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEpxvKr8371wMxhqFS6hu%2Fuploads%2FBte3X3GuoNuT369pzYvK%2FScreenshot%202023-03-27%20at%2016.11.31.png?alt=media\&token=8cbe97bd-a773-4c7e-bbf8-c902557e9bc3)

### &#x20;✍️ Objective - To add the text "My custom theme" to the top of the page

1. In the left hand side, click on the file "layout.html"\
   ![](https://869317877-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEpxvKr8371wMxhqFS6hu%2Fuploads%2FNE6KQONh1mvHsxPdhviz%2FScreenshot%202023-03-27%20at%2016.27.45.png?alt=media\&token=df708991-ed16-4fe4-937e-3250c5f0b2e7)\
   This is how it would look like

2. Now in the layout.html file, just inside the `<body>` tag, below it add the code `<p>My custom theme</p>`\
   ![](https://869317877-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEpxvKr8371wMxhqFS6hu%2Fuploads%2FosR0nKP15LLe345zTT9T%2FScreenshot%202023-03-27%20at%2016.43.09.png?alt=media\&token=f46b0305-aa09-49be-8d75-dc2105c1ab78)

3. Once you have added the text, click on "**Save & Preview store"** button

4. Now your changes would be deployed to a preview site which is different from your main store website&#x20;

5. Your preview store link would be `.sh/<store-link>` \
   (Note - It's not yet deployed to your original store link, which is `mydukaan.io/<store-link>`)

   ![](https://869317877-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEpxvKr8371wMxhqFS6hu%2Fuploads%2FOQAQXSQNIS6PlNLxPJe0%2FScreenshot%202023-03-27%20at%2016.38.46.png?alt=media\&token=e93b8843-da21-4cf8-91dc-6d0c5f168c25)

6. The mobile preview is visible within the code editor itself.

   ![](https://869317877-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEpxvKr8371wMxhqFS6hu%2Fuploads%2FMdNyVDJdqWNIQLvqZ7Rh%2FScreenshot%202023-03-27%20at%2016.37.17.png?alt=media\&token=94e89970-0fac-4707-a106-c5bf93e06ed8)

7. If you can see, the text "My custom theme" is now visible on both mobile screen as well as desktop site. Awesome, you just edited your theme!

8. We can also make the text bold by changing the HTML to this. \
   `<p><b>My custom theme</b></p>`\
   Similarly, you can continue playing around with&#x20;


# Theme folder structure

A Dukaan theme primarily consists of three types of files:

1. HTML (.html)
2. CSS (.css)
3. Javascript (.js)

When you open the code editor, you can view the folder structure of a theme, which is organized as follows:

```
public/
│
├── css/
├── dist/ (ignore this folder for now, you won't need to change any files here)
├── js/
├── index.html
├── layout.html (root HTML file, also known as the parent HTML file)
├── product.html (contains code for the products page; it inherits layout.html)
├── search.html (contains code for the search page; it inherits layout.html)
├── category.html (contains code for the category products page; it inherits layout.html)
├── categories.html (contains code for the categories page; it inherits layout.html)
├── subcategories.html (contains code for the subcategories page; it inherits layout.html)
├── coupon.html (contains code for the coupons page; it inherits layout.html)
├── advance-category-templates.html
└── product-variant-templates.html
```

`layout.html` serves as the main parent file and is considered the root HTML file. All other files can be thought of as child files. The `layout.html` file is the base template that contains the common structure and elements for your website. You can use blocks in this file, which can then be customized in child templates.

For each specific page, there is a separate HTML file that extends the `layout.html` file. For example:

* For the products page, there is a `products.html` file.
* For the categories page, there is a `categories.html` file.
* Similarly, there are separate files for other pages like search, category products, subcategories, and coupons.

By organizing the theme in this manner, you can maintain a clean and modular code structure, making it easier to develop, customize, and maintain your website.

## 🤔 How is it different from frameworks like React?

In the Dukaan theme, files are organized based on pages rather than components, which is different from a component-based framework like React. In React, each component is usually defined in a separate file, allowing for reusability and a modular structure. However, in the Dukaan theme structure, **one file corresponds to one page.**

This means that the `products.html` file contains the entire code for the products page, the `categories.html` file contains the entire code for the categories page, and so on. This approach is more focused on organizing the code based on pages, rather than breaking down the code into smaller, reusable components.

Despite this page-based organization, templates can still be reused across multiple pages by using the `layout.html` file. This file serves as the base template for the entire website and contains the common structure and elements that are shared across different pages. By defining reusable templates in the `layout.html` file, you can ensure that these templates only need to be defined once and can be extended or customized by the child pages (e.g., `products.html`, `categories.html`, etc.) as needed.

In summary, while the Dukaan theme does not follow a component-based structure like React, it still allows for template reusability and modularity by utilizing the `layout.html` file as the base template for all pages.


# How does it all work?

As discussed previously, we use html files for different pages, products page has its own html file, similarly for categories page and so on.\
But how are all these pages related and linked to each other? The answer to that is a templating engine. \
We could also put all the .html into a single file layout.html but that would a horibble mess of code and a big huge difficult to read file and if you add dynamic content to it, god bless you and your coders! Hence we split it into different files for easier maintenance and understanding.\
\
However with this code could be duplicated across these files and a lot of other issues can arise.\
Hence to keep things organized, reduce repitition of code, and handle dynamic content we use a templating engine to simplify the things. \
\
Dukaan theme uses Nunjucks templating engine, we have explained about it in the [next chapter](/nunjucks-templating-language).<br>

## 🤔 How to know which file to change?

Let's understand with an example.\
Imagine the layout.html file is like the menu template for a restaurant. It defines the overall design, font, and color scheme of the menu. This template is used by all the different sections of the menu, such as appetizers, main courses, and desserts.

Now, think of the product.html file as the dessert section of the menu. It follows the same menu template (layout.html) but has its unique dessert items and descriptions listed.

In this case, Nunjucks acts like a menu designer who uses the menu template (layout.html) to create the overall look of the menu and then adds the specific items and descriptions for each section, like the desserts in the product.html file.

To customize the restaurant menu, you have two options:

1. If you want to change the overall design, font, or color scheme of the entire menu, you can edit the layout.html file (the menu template). This will affect all sections of the menu that use this template.
2. If you only want to change something specific to the dessert section, like adding a new dessert item or updating its description, you can edit the product.html file. This will only affect the dessert section and leave the rest of the menu untouched.

So, if you wanted to make the product title text bold, you have to goto the products.html page and then find the variable which contains the product title and update its css to bold.

\ <br>


# Nunjucks Templating Language

We will cover the very basics of Nunjucks that you would require while building a theme.\
You can view the complete official docs of Nunjucks here -<https://mozilla.github.io/nunjucks/>.

### 1. Variables

Variables are like containers that store information. In Nunjucks, you can use double curly braces `{{ }}` to display the content of a variable.

For example

```django
<!-- Suppose product_name = "Cookie" -->

<p>Add to bag, one {{ product_name }}!</p>
```

This will display: `Add to bag, one Cookie!`

### 2. Operators

Operators are symbols that help perform operations on variables, like simple math or comparisons.&#x20;

For example

```django
<!-- Suppose price = 10 and tax = 2 -->

<p>Total cart cost: {{ price + tax }}</p>
```

This will display: `Total cart cost: 12`

### 3. Loops&#x20;

Loops are a way to repeat actions or display a list of items. In Nunjucks, you can use the `for` loop to go through a list and perform an action for each item.&#x20;

For example:

```django
<!-- Suppose products = ["Bag", "Pen", "Paper"] -->

{% for product in products %}
  <p>{{ product }}</p>
{% endfor %}
```

This will display:

```
Bag
Pen
Paper
```

### 4. Conditional statements

Conditional statements, like `if`, `elif`, and `else`, allow you to perform different actions based on certain conditions.&#x20;

For example:

You can display a message depending on whether a user is logged in or not:

```django
<!-- Suppose user_is_logged_in = True -->
<!-- And suppose username = "Kaushik" -->

{% if user_is_logged_in %}
  Welcome, {{ username }}!
{% else %}
  Please log in.
{% endif %}
```

This will display:

`Welcome, Kaushik`

### 5. Template Inheritance

Template inheritance in Nunjucks helps you create a consistent structure for your website by allowing you to reuse a base template and customize specific parts for different pages. It's like having a blueprint that you can use to build various rooms in a house (If you remember the Menu example we explained in the previous chapter).\
\
Let's understand with a simple example.

1. Base Template - layout.html\
   It that has the common structure and elements for your website. Use the `{% block %}` tag to mark areas that can be customized in child templates.

```html
<!-- layout.html -->
<!DOCTYPE html>
<html>
<head>
  <title>
    {% block title %}
      Default Title
    {% endblock %}
  </title>
</head>
<body>
  <header>
    {% block header %}
      Header
    {% endblock %}
  </header>

  <main>
    {% block content %}
    {% endblock %}
  </main>

  <footer>
    {% block footer %}
      Footer
    {% endblock %}
  </footer>
</body>
</html>
```

2. Child Template - product-details.html\
   Create a child template (e.g., `product-details.html`) that extends the base template using the `{% extends %}` tag. Then, use the `{% block %}` tag again to override and customize the content in specific areas.

```html
<!-- product-details.html -->
{% extends "base.html" %}

{% block title %}
  Product Details - My E-commerce Website
{% endblock %}

{% block header %}
  <nav>
    <a href="/">Home</a>
    <a href="/products">Products</a>
    <a href="/about">About</a>
    <a href="/contact">Contact</a>
  </nav>
{% endblock %}

{% block content %}
  <h1>Product Name</h1>
  <img src="/images/product-image.jpg" alt="Product Image" width="300">
  <p>Product description goes here. This product is perfect for those who are looking for a high-quality, stylish, and durable item.</p>

  <h2>Product Details</h2>
  <ul>
    <li>Price: $99.99</li>
    <li>Color: Black</li>
    <li>Size: Medium</li>
  </ul>

  <button>Add to Cart</button>
{% endblock %}

{% block footer %}
  <p>Copyright &copy; 2023 - My E-commerce Website. All rights reserved.</p>
{% endblock %}

```

### 6. Include

Include allows you to insert reusable components or partial templates into your main templates. It's like using puzzle pieces to build a complete picture. This feature helps you maintain a consistent structure across your website and avoid repeating code.\
\
Here's an example.

Header & footer usually have same content across pages, say product details page, homepage and checkout page. So, it doesn't make sense to duplicate them everywhere, instead we can just define them in 1 file and then use that across all the pages.\
\
Let's create 2 files, header.html & footer.html

```html
<!-- header.html -->
<nav>
  <a href="/">Home</a>
  <a href="/products">Products</a>
  <a href="/about">About</a>
  <a href="/contact">Contact</a>
</nav>
```

```html
<!-- footer.html -->
<p>Copyright &copy; 2023 - My Website. All rights reserved.</p>
```

Now you can just use these files across all your pages. Let's see how.

```html
<!-- product-details.html -->
{% extends "layout.html" %}

{% block header %}
  {% include "header.html" %}
{% endblock %}

{% block content %}
  <!-- Product details content goes here -->
{% endblock %}

{% block footer %}
  {% include "footer.html" %}
{% endblock %}
```

Similarly we can also use it in about.html

```html
<!-- about.html -->
{% extends "layout.html" %}

{% block title %}
  About Us - My Website
{% endblock %}

{% block header %}
  {% include "header.html" %}
{% endblock %}

{% block content %}
  <h1>About Us</h1>
  <p>
    Welcome to our website! We are a company dedicated to providing the best
    products and services to our customers. Our team is passionate about
    innovation, and we work hard to ensure that we exceed your expectations.
  </p>

  <h2>Our Mission</h2>
  <p>
    Our mission is to deliver top-quality products and services that make a
    positive impact on people's lives. We strive to achieve this goal by
    constantly improving our processes, staying up-to-date with industry trends,
    and listening to our customers' feedback.
  </p>
{% endblock %}

{% block footer %}
  {% include "footer.html" %}
{% endblock %}
```

### 7. Filters

These are used to modify the output of variables or expressions before they are displayed. Think of them as tools that can tweak or transform data into the desired format. Filters are applied using the pipe symbol `|`. It can be used in the following way.

To convert a text to uppercase we can write this

```
<!-- Suppose pageTitle = "welcome" -->
{{ pageTitle | upper }}
```

This will display `WELCOME`

### 8. Comments

Comments are used to add notes or explanations to your code that will be ignored by the template engine and will not be displayed on the rendered page.

You can add a comment in Nunjucks by using `{# ... #}`. Any text within the opening and closing braces will be treated as a comment and ignored by the engine.

For example, in the code below, line 2 is a comment. Note how it starts and ends with a #.

{% code lineNumbers="true" %}

```html
<button class="without-cart-add-to-bag-button btn-outline-primary btn-lg">
          {# Add to bag #}
          {{ DUKAAN_LANGUAGE.ADD_TO_BAG }}
</button>
```

{% endcode %}

### Conclusion

With this our introduction to Nunjucks is complete and you're all set 🚀, this sums up the bare minimum Nunjucks needed for editing a Dukaan theme.\
If you want to delve deep into the official documentation [here](https://mozilla.github.io/nunjucks/)[ is the link.](https://mozilla.github.io/nunjucks/)


# Basic code editing

We shall now move into learning how to make edits into our theme to change the structure, looks and functionality.

### ✍️ Objective - To show list of categories in a carousel in layout.html page

We will divide it into 4 parts

1. [Adding the HTML](/basic-code-editing/adding-the-html) for the product card to display (If we were building a house, this step would be building the structure of the house using cement, wood, bricks)
2. [Adding the CSS](/basic-code-editing/adding-the-css) i.e. color, shadow and other visual elements to make it look appealing (painting the building, adding flooring, furniture, etc.)
3. [Adding the Javascript](/basic-code-editing/adding-the-javascript) i.e. functionality to the product card, like, what happens when someone clicks on a product, or hovers on it (Adding fans, lights, electric wiring, etc)
4. [Adding Nunjucks](/basic-code-editing/adding-nunjucks) for fetching real data and using it to display the products (Inviting people to live in the house)


# Adding the HTML

### ✍️ Objective - To display categories in homepage&#x20;

Open the layout.html file

This is how a bare minimum layout.html file would look like, it has some code which is required for a theme to function properly, avoid removing any of this code.

```html
<!-- layout.html -->

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8"/>
    <meta http-equiv="X-UA-Compatible"
          content="IE=edge"/>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    {% include './../../dukaan/common/theme-fonts.html' %}
    {{ 'splide.min.css' | css | static }}
    {{ 'layout.css' | css | static }}
    {{ 'styles.css' | css | static }}
    {% include './../../dukaan/common/seo_tags/commonSeoTags.html' %}
    {% include './../../dukaan/common/theme-colors.html' %}
    {% block head %}
    {% endblock head %}
    {{ 'head' | DukaanBlocks }}
  </head>
  {% include './../../dukaan/common/spinner-loader.html' %}
  <body class="flex d-column">
    {% include './../../dukaan/common/hellobar.html' %}
    <main class="flex flex-1 d-column">
      {% block content %}
      {% endblock content %}
    </main>
    {% include '../../dukaan/common/bxgy-sticky-footer.html' %}
    {% include '../../dukaan/common/store-open-sticky.html' %}
    {% block postfooter %}
    {% endblock postfooter %}
    {{ 'footer' | DukaanBlocks }}
    {% include './product-variant-templates.html' %}
    {{ 'variant-utils.js' | js | static }}
    {{ 'dukaan-utils.js' | js | static }}
    {{ 'layout.js' | js | static }}
    {{ 'dukaan-coupons.js' | js | static({ defer: true }) }}
    {{ 'dukaan-offers.js' | js | static({ defer: true }) }}
    {{ 'axios.min.js' | js | static({ defer: true }) }}
    {{ 'splide.min.js' | js | static }}
    {{ 'common-components.css' | css | static }}
    {% include './../../dukaan/common/auth.html' %}
    {% include '../../dukaan/common/multilanguage.html' %}
    {% include './../../dukaan/common/common-scripts.html' %}
    {% include '../../dukaan/common/snackbar.html' %}
    {% block script %}
    {% endblock script %}
  </body>
</html>
```

If we check now, our site would be completely blank. Now, we will try to display a dummy category.

We will display a category image and category name, go ahead and paste this code inside the body tag.

```html
<div class="container">
    <div class="category-card">
      <a href="#" class="category-link">
        <div class="category-image-wrapper">
          <img width="300" height="300" src="https://i.imgur.com/ordhK4e.jpg" alt="Category 1" class="category-image">
        </div>
        <div class="category-name">Category 1</div>
      </a>
    </div>
  </div>
```

This code snippet creates a simple HTML structure to display a category card within a container. The category card includes an image and the category name, for now we have hardcoded a dummy image and category name, both wrapped within a hyperlink element for navigation purposes.&#x20;

\
If you save & preview the changes, you'd see something like this

<figure><img src="https://869317877-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEpxvKr8371wMxhqFS6hu%2Fuploads%2Fgzv5JIoGS0Vzb6z2MOdW%2FScreenshot%202023-03-30%20at%2018.55.17.png?alt=media&amp;token=16e2ffce-e0e7-4dd9-b726-3b5e43117430" alt=""><figcaption></figcaption></figure>

Let's try to add some more dummy categories, the updated code would be

```html
<div class="container">
    <div class="category-card">
      <a href="#" class="category-link">
        <div class="category-image-wrapper">
          <img width="300" height="300" src="https://i.imgur.com/ordhK4e.jpg" alt="Category 1" class="category-image">
        </div>
        <div class="category-name">Category 1</div>
      </a>
    </div>
    <div class="category-card">
      <a href="#" class="category-link">
        <div class="category-image-wrapper">
          <img width="300" height="300" src="https://i.imgur.com/ordhK4e.jpg" alt="Category 1" class="category-image">
        </div>
        <div class="category-name">Category 2</div>
      </a>
    </div>
    <div class="category-card">
      <a href="#" class="category-link">
        <div class="category-image-wrapper">
          <img width="300" height="300" src="https://i.imgur.com/ordhK4e.jpg" alt="Category 1" class="category-image">
        </div>
        <div class="category-name">Category 3</div>
      </a>
    </div>
  </div>
```

This is how our site looks now

<figure><img src="https://869317877-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEpxvKr8371wMxhqFS6hu%2Fuploads%2FTF8pXHFUUuX41W9JINma%2FScreenshot%202023-03-30%20at%2018.56.19.png?alt=media&amp;token=684aa5e5-12b4-44c0-9904-f840542b0aaf" alt=""><figcaption></figcaption></figure>

Now that we can display dummy data with HTML its time to flare up the tags by spicing it up with some CSS in the next chapter.

<details>

<summary>For reference - The contents of layout.html file after the above changes</summary>

```html
<!-- layout.html -->

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8"/>
    <meta http-equiv="X-UA-Compatible"
          content="IE=edge"/>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    {% include './../../dukaan/common/theme-fonts.html' %}
    {{ 'splide.min.css' | css | static }}
    {{ 'layout.css' | css | static }}
    {{ 'styles.css' | css | static }}
    {% include './../../dukaan/common/seo_tags/commonSeoTags.html' %}
    {% include './../../dukaan/common/theme-colors.html' %}
    {% block head %}
    {% endblock head %}
    {{ 'head' | DukaanBlocks }}
  </head>
  {% include './../../dukaan/common/spinner-loader.html' %}
  <body class="flex d-column">
    {% include './../../dukaan/common/hellobar.html' %}
    <main class="flex flex-1 d-column">
        <div class="container">
        <div class="category-card">
      <a href="#" class="category-link">
        <div class="category-image-wrapper">
          <img src="https://i.imgur.com/ordhK4e.jpg" alt="Category 1" class="category-image">
        </div>
        <div class="category-name">Category 1</div>
      </a>
    </div>
    <div class="category-card">
      <a href="#" class="category-link">
        <div class="category-image-wrapper">
          <img src="https://i.imgur.com/ordhK4e.jpg" alt="Category 1" class="category-image">
        </div>
        <div class="category-name">Category 2</div>
      </a>
    </div>
    <div class="category-card">
      <a href="#" class="category-link">
        <div class="category-image-wrapper">
          <img src="https://i.imgur.com/ordhK4e.jpg" alt="Category 1" class="category-image">
        </div>
        <div class="category-name">Category 3</div>
      </a>
    </div>
      </div>
      {% block content %}
      {% endblock content %}
    </main>
    {% include '../../dukaan/common/bxgy-sticky-footer.html' %}
    {% include '../../dukaan/common/store-open-sticky.html' %}
    {% block postfooter %}
    {% endblock postfooter %}
    {{ 'footer' | DukaanBlocks }}
    {% include './product-variant-templates.html' %}
    {{ 'variant-utils.js' | js | static }}
    {{ 'dukaan-utils.js' | js | static }}
    {{ 'layout.js' | js | static }}
    {{ 'dukaan-coupons.js' | js | static({ defer: true }) }}
    {{ 'dukaan-offers.js' | js | static({ defer: true }) }}
    {{ 'axios.min.js' | js | static({ defer: true }) }}
    {{ 'splide.min.js' | js | static }}
    {{ 'common-components.css' | css | static }}
    {% include './../../dukaan/common/auth.html' %}
    {% include '../../dukaan/common/multilanguage.html' %}
    {% include './../../dukaan/common/common-scripts.html' %}
    {% include '../../dukaan/common/snackbar.html' %}
    {% block script %}
    {% endblock script %}
  </body>
</html>
```

</details>


# Adding the CSS

### ✍️ Objective - To add design to the category divs

Open the layout.css file, you would be seeing some existing code in it, for now you can ignore it.

Let's add the following css to the end of layout.css file

```css
/* layout.css */

/* ... other existing styles ... */

.container {
  display: flex;
  overflow-x: auto;
  width: 100%;
  padding: 1rem;
}

.category-card {
  flex: 0 0 auto;
  width: 200px;
  margin-right: 1rem;
  text-align: center;
  background-color: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  border-radius: 5px;
  overflow: hidden;
}

.category-link {
  text-decoration: none;
  color: inherit;
}

.category-image-wrapper {
  width: 100%;
  height: 0;
  padding-bottom: 100%;
  position: relative;
}

.category-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.category-name {
  padding: 1rem;
  font-size: 1.1rem;
  font-weight: bold;
}

/* Media queries for responsiveness */

@media (min-width: 480px) {
  .category-card {
    width: calc(50% - 1rem);
  }
}

@media (min-width: 768px) {
  .category-card {
    width: calc(33.333% - 1rem);
  }
}

@media (min-width: 992px) {
  .category-card {
    width: calc(25% - 1rem);
  }
}

@media (min-width: 1200px) {
  .category-card {
    width: 200px;
  }
}
```

This CSS code snippet provides styling for the category card HTML structure. The main container is a flex container with horizontal scrolling enabled. Each category card has a fixed width, a margin to its right, and some basic styling such as a background color, box-shadow, and border-radius.

{% hint style="info" %}
Don't remove classnames which start with "dkn-" because they are used by internal functions.
{% endhint %}

The category link has its text decoration removed and inherits the color from the parent. The category image wrapper has a square aspect ratio and uses the padding-bottom trick to achieve this. The image is positioned absolutely within the wrapper and covers the entire space, maintaining its aspect ratio.

Lastly, the category name has some padding, font size, and font weight adjustments to make it stand out more.

<figure><img src="https://869317877-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEpxvKr8371wMxhqFS6hu%2Fuploads%2FyFhOYy4WTyr8NMQWhByd%2FScreenshot%202023-03-30%20at%2018.51.05.png?alt=media&amp;token=875b07d8-7c90-4275-9a6d-98758599dde1" alt=""><figcaption></figcaption></figure>

Wohoo! It looks beautiful now, with our CEO Leo lighting up the page with his cuteness.\
\
After you've added this, its time to add some functionality to our cards, what if a user clicks on the category card? We could take it to category page, display a message or just shower confetti! <br>

\
We'll figure it out in the next chapter


# Adding the Javascript

### ✍️ Objective - When user clicks on category card, it should show the category name in a popup

Open the file layout.js and add the following code to it

```javascript
/* layout.js */

document.querySelectorAll('.category-link').forEach(link => {
  link.addEventListener('click', event => {
    event.preventDefault();
    const categoryName = event.currentTarget.querySelector('.category-name').textContent;
    alert(`You clicked on ${categoryName}`);
  });
});

```

This JavaScript code adds a click event listener to each `.category-link` element. When a user clicks on a category card, a popup appears with a message displaying the category name.\
\
Go ahead and deploy this change and see your action happening live on the preview site.

<figure><img src="https://869317877-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEpxvKr8371wMxhqFS6hu%2Fuploads%2FYcHM8o3K3xMQTb6FOINK%2FScreenshot%202023-03-30%20at%2019.12.45.png?alt=media&amp;token=4c46d6dc-1363-4bef-90b0-7ec7f8ccc855" alt=""><figcaption></figcaption></figure>

Once successfully deployed it would look something like above when a category card is clicked.\
\
Up next, its time to bundle up everything and show some real data using Nunjucks.


# Adding Nunjucks

### ✍️ Objective - To integrate dukaan categories data with the category cards we have created so far

Let's go back to our layout.html file, earlier it was just hardcoded categories, we will now display real categories from our store using Nunjucks.\
\
The categories data of our store comes from a variable called `DUKAAN_CATEGORY_LIST`. It's a list of categories, for now we just need the category name and category image.\
You can find a sample data of it and all other available variable list [here](/dukaan-data).

```html
<!-- layout.html -->

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8"/>
    <meta http-equiv="X-UA-Compatible"
          content="IE=edge"/>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    {% include './../../dukaan/common/theme-fonts.html' %}
    {{ 'splide.min.css' | css | static }}
    {{ 'layout.css' | css | static }}
    {{ 'styles.css' | css | static }}
    {% include './../../dukaan/common/seo_tags/commonSeoTags.html' %}
    {% include './../../dukaan/common/theme-colors.html' %}
    {% block head %}
    {% endblock head %}
    {{ 'head' | DukaanBlocks }}
  </head>
  {% include './../../dukaan/common/spinner-loader.html' %}
  <body class="flex d-column">
    {% include './../../dukaan/common/hellobar.html' %}
    <main class="flex flex-1 d-column">
      <div class="container">
      {% for category in DUKAAN_CATEGORY_LIST %}
        <div class="category-card">
          <a href="#" class="category-link">
            <div class="category-image-wrapper">
              <img src="{{ category.image }}" alt="{{ category.name }}" class="category-image">
            </div>
            <div class="category-name">{{ category.name }}</div>
          </a>
        </div>
      {% endfor %}
      </div>
      {% block content %}
      {% endblock content %}
    </main>
    {% include '../../dukaan/common/bxgy-sticky-footer.html' %}
    {% include '../../dukaan/common/store-open-sticky.html' %}
    {% block postfooter %}
    {% endblock postfooter %}
    {{ 'footer' | DukaanBlocks }}
    {% include './product-variant-templates.html' %}
    {{ 'variant-utils.js' | js | static }}
    {{ 'dukaan-utils.js' | js | static }}
    {{ 'layout.js' | js | static }}
    {{ 'dukaan-coupons.js' | js | static({ defer: true }) }}
    {{ 'dukaan-offers.js' | js | static({ defer: true }) }}
    {{ 'axios.min.js' | js | static({ defer: true }) }}
    {{ 'splide.min.js' | js | static }}
    {{ 'common-components.css' | css | static }}
    {% include './../../dukaan/common/auth.html' %}
    {% include '../../dukaan/common/multilanguage.html' %}
    {% include './../../dukaan/common/common-scripts.html' %}
    {% include '../../dukaan/common/snackbar.html' %}
    {% block script %}
    {% endblock script %}
  </body>
</html>
```

In this Nunjucks template, we use a `for` loop to iterate over the `DUKAAN_CATEGORY_LIST` variable and create a category card for each item. We use the `{{ }}` syntax to insert the category name and image URL from the data.\
\
You can deploy the change, you can now see your store category data visible in the homepage.

<figure><img src="https://869317877-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEpxvKr8371wMxhqFS6hu%2Fuploads%2FexF4ktKxV9siCSVMFWgQ%2FScreenshot%202023-04-02%20at%2014.21.11.png?alt=media&amp;token=a743ae49-b300-4d61-8090-f0a0760d583a" alt=""><figcaption></figcaption></figure>

\
🎉 Awesome, you just displayed your store categories in your own custom theme. You can do more changes as per your requirement, to read more about the data which Dukaan makes accessible using Nunjucks read about [Dukaan Data](/dukaan-data).


# Customising Dukaan Templates

### 🤔 How to customise custom HTML Tag content

Say, you want to customise `<add-to-bag-button>` tag content, then you need to edit the content present inside the HTML tag `<template>` having its corresponding Template id.

Similarly for other HTML tags, the tag name would be the template id.

### Add to bag button

1. `<add-to-bag-button>`

   This button is used in Product Details page & Variants Modal

   Template id - `add-to-bag-button-without-variant`
2. `<add-to-bag-button-with-variants>`

   This button is used in Product Card

   Template id - `add-to-bag-button-with-variant`
3. `<buy-now-button-load-point>`

   This button is used in Product Details page & Variants Modal

   Template id - `buy-now-button-template`

If you want to customise the styles of Out of stock button please add/modify template having the id - `out-of-stock-button`

### Product cards

Depending on your theme you can find your product card template. The template ids used in different themes are&#x20;

1. `product-card-template`&#x20;
2. `similar-product-card`&#x20;
3. `dkn-product-card-template`&#x20;
4. `advance-filter__product-card`

Now you can customise the structure and styles according to your usecase.

{% hint style="info" %}
Don't remove classnames which start with "dkn-" because they are used by internal functions.
{% endhint %}

### Category cards

To customise the category card look for the template having the id `categories-card-template.`

{% hint style="info" %}
Don't remove classnames "category-image" and "category-name".
{% endhint %}

### Variant Pills

The template ids for customising variant pills are :

`"dkn-size-variant-item-template"`- To customise text type variants.

`"dkn-color-variant-item-template"`- To customise color type variants.

### Variant Modal

To customise the structure of variant modals look for the template id `product-variant-selection-modal`

{% hint style="info" %}
Don't remove classnames which start with "product-".
{% endhint %}


# Dukaan Data

You can access your store data using these keys on server side with Nunjucks by simply mentioning the variable name. Example - `{{DUKAAN_STORE.link}}`

This data is available on client side in the window object in a key called Dukaan Data. For example  `window.DukaanData.DUKAAN_STORE`

### Variables&#x20;

`DUKAAN_STORE - Store related information like store id, store link, etc.`

`DUKAAN_CATEGORY_LIST - List of active categories`

`DUKAAN_CATALOG - This is list of Dukaan Categories with their products and other data`

`STORE_MENU - Navigation menu related data`

<details>

<summary>Sample data</summary>

```json
[
    {
        "id": 269676,
        "position": 0,
        "label": "Why to buy from us ?",
        "url": null,
        "content_type": "storepage",
        "content_object": {
            "id": 7697,
            "slug": "why-to-buy-from-us",
            "image": ""
        },
        "name": "Why to buy from us ?",
        "child": []
    },
    {
        "id": 269677,
        "position": 0,
        "label": "Harry Potter & The Philosopher's Stone",
        "url": null,
        "content_type": "product",
        "content_object": {
            "id": 38266106,
            "slug": "harry-potter-the-philosopher-s-stone-1",
            "image": "https://api.mydukaan.io/static/images/category-def.jpg"
        },
        "name": "Harry Potter & The Philosopher's Stone",
        "child": [
            {
                "id": 269678,
                "position": 0,
                "label": "TEST PRODUCT",
                "url": null,
                "content_type": "product",
                "parent_id": 269677,
                "content_object": {
                    "id": 38506255,
                    "slug": "test-product",
                    "image": "https://api.mydukaan.io/static/images/category-def.jpg"
                },
                "name": "pl",
                "child": []
            }
        ]
    },
    {
        "id": 269679,
        "position": 0,
        "label": "Harry Potter & The Philosopher's Stone",
        "url": null,
        "content_type": "product",
        "content_object": {
            "id": 38266105,
            "slug": "harry-potter-the-philosopher-s-stone",
            "image": "https://api.mydukaan.io/static/images/category-def.jpg"
        },
        "name": "Harry Potter & The Philosopher's Stone",
        "child": []
    }
]
```

</details>

`DUKAAN_THEME_DATA - Theme related data like active theme, font, primary and secondary colors & theme sections`

<details>

<summary>Sample data</summary>

```json
{
    "store": 101561150,
    "payment_done": null,
    "meta": {
        "colors": {
            "primary": "#146eb4",
            "secondary": "#ee741f"
        },
        "header": {
            "showStoreImageOnly": false
        },
        "favicon": {
            "faviconUrl": "https://mydukaan.io/favicon.png"
        },
        "advanced": {
            "product": {
                "showAddToBagOnProductCard": true
            }
        }
    },
    "store_theme_data": {
        "id": 2270035,
        "twitterUrl": "",
        "instagramUrl": "",
        "facebookUrl": "",
        "linkedinUrl": "",
        "youtubeUrl": "",
        "pinterestUrl": "",
        "cxSupport": "+91-9040826685",
        "deliveryHappensWithIn": "3-5 days"
    }
}
```

</details>

`DUKAAN_BANNERS - This is a list of top banners and their related data`

<details>

<summary>Sample data</summary>

```json
[
    {
        "id": 73413,
        "uuid": "85af7d36-904b-4eaf-8e0d-595bcf8b85cd",
        "is_active": true,
        "image": "https://dukaan-core-file-service.s3.ap-southeast-1.amazonaws.com/upload_file_service/ebaca373-2ed1-4c4e-8309-e1ca69dd7beb/image.png",
        "url": null,
        "position": 0,
        "store": "31d9141e-acc5-4bbe-ad6a-ea6ef13dccf9"
    },
    {
        "id": 25496,
        "uuid": "3e00dd26-1ea0-460b-bbd9-5ae7dbe86cb3",
        "is_active": true,
        "image": "https://dukaan-us.s3.amazonaws.com/5540936/5b45f4f7-f9f4-4358-9674-c97bed40d23b/image-86e59caa-9859-4898-94d2-d3fba32b8c79.png",
        "url": null,
        "position": 1,
        "store": "31d9141e-acc5-4bbe-ad6a-ea6ef13dccf9"
    }
]
```

</details>

Only the essential variables are mentioned above, you can view the other variables by running `console.log(window.DukaanData)`in your browser console.


# Advance code editing

### ⚠ Alert - This is a section for pro wizards only 🧙

We have listed some of the complex customisations which are required by some customers in this section.


# Customising core functionality

Say you want to customise what happens after a user clicks on "Add to bag" button, we allow you to perform your own action using a function. This function has a pre-defined name as declared by our developers and all you need to do is use that function and define what it should do.

## ✍️ Objective - Display success message after Add to bag button is clicked

The name of the function which needs to be defined in order for an action to be performed after Add to bag event is called **`afterAddToBagCall`**

The function accepts 2 parameters **`productUUID`** and **`skuUUID`**

So, let's define the function

```javascript
window.afterAddToBagCall = (productUUID, skuUUID) => {
    alert(`Add to bag button clicked`);
}
```

Let's add the above code snippet to our layout.js file. Once added, click on **Save & preview store** button.

<figure><img src="https://869317877-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEpxvKr8371wMxhqFS6hu%2Fuploads%2FHVTKvpLwdQYFX1ikQiHU%2FScreenshot%202023-04-03%20at%2021.38.59.png?alt=media&amp;token=b05a2cbe-76aa-4791-a67b-16285669ed49" alt=""><figcaption></figcaption></figure>

On clicking the Add to bag (in this case Place in bag since we changed the text) button, we get a popup.

<figure><img src="https://869317877-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEpxvKr8371wMxhqFS6hu%2Fuploads%2FuiwtO5ebV6oZxg1gsuEX%2FScreenshot%202023-04-03%20at%2021.39.07.png?alt=media&amp;token=f32545a7-ae1a-4a0f-9313-1676250fcbab" alt=""><figcaption></figcaption></figure>

Once you click on OK the message disappears and your product is added to cart, as seen in the picture below.

<figure><img src="https://869317877-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEpxvKr8371wMxhqFS6hu%2Fuploads%2FrZabru8cyfzvW14Emgt4%2FScreenshot%202023-04-03%20at%2021.39.52.png?alt=media&amp;token=3b6142f8-9b34-4388-bc06-a50d306e82bb" alt=""><figcaption></figcaption></figure>

This is how you can customise this function to do changes as per your requirement.<br>

You can view list of all such custom [Dukaan Functions here](/dukaan-functions).


# Dukaan Functions

## 1. After add to bag event

```javascript
window.afterAddToBagCall = (productUUID, skuUUID) => {
    alert(`Add to bag button clicked`);
}
```

## 2. Product card renderer

It renders the product card

mountElement is the element inside which the card is to be rendered. Mount element is the element which is targeted and inside which the current product card is to be appended.

```javascript
productCardRenderer(mountElement, product, {
      additionalRenderer: nameOfYourFunction
});
```

## 3. Category card renderer

It renders the category card

mountElement is the element inside which the card is to be rendered. It is the element which is targeted and inside which the current category card is to be appended.

```javascript
categoryCardRenderer(mountElement, category, {
      additionalRenderer: nameOfYourFunction
});
```


# Integrating Dukaan Plugins

Active plugin list can be access from window object

`window.ACTIVE_APPS_LIST` - It gives an object containing data about the status of plugins, its an object of key value pairs where the key is the plugin name and the value is boolean value representing the status.

### Sample data

```json
{
    "REVIEWS_AND_RATINGS": true,
    "COUNTDOWNTIMER": false,
    "WISHLIST": false,
    "STORE_LOCATOR": false
}
```

We will learn about how to integrate these plugins in your theme in the following chapters.


# Wishlist plugin

You can see the **Wishlist plugin** at work here, beside the Add to bag button there is a heart shape button which helps wishlist a product.

> If you're unaware of what **wishlist** does, it allows users to save products that they're interested in for future purchase or reference. It acts as a personal shopping list and helps users keep track of items they might want to buy later, without having to search for them again.

<figure><img src="https://869317877-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEpxvKr8371wMxhqFS6hu%2Fuploads%2Fg7YXnVTHS6kCDx7f7ceL%2FScreenshot%202023-04-05%20at%2016.42.48.png?alt=media&amp;token=b087984d-e939-42df-a9d5-b7e5e061d734" alt=""><figcaption></figcaption></figure>

### 🤔 How to use ?

#### 1. Implementing the appearance & functionality of the wishlist button&#x20;

Open the layout.html file and define the template and mention its id attribute such that it can be used wherever you want to place the wishlist template. In this case we are using the id **`"heart-wishlist-button-template"`**

```html
<template id="heart-wishlist-button-template">
  <div class="heart-wishlist-buttons-wrapper">
    <button class="without-wishlist-btn w-100 btn-wishlist" type="button" data-wishlist-button-state="unselected">
      <div class="d-flex justify-content-center">
        <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
          <path fill-rule="evenodd" clip-rule="evenodd" d="M14.727 3.98839C15.3899 3.72467 16.0996 3.59889 16.8128 3.61873C17.526 3.63857 18.2277 3.80361 18.8749 4.10377C19.5219 4.40382 20.101 4.83261 20.5768 5.36394C22.4987 7.50112 22.1697 10.7853 20.1983 12.7667L12.9689 19.9961L12.5391 19.5662L12.9668 19.9981C12.7177 20.2449 12.3811 20.3834 12.0304 20.3834C11.6797 20.3834 11.3432 20.2449 11.094 19.9981L11.0919 19.9961L3.67619 12.5803C3.17188 12.0757 2.77561 11.4733 2.51189 10.8104C2.24817 10.1474 2.12239 9.43769 2.14223 8.7245C2.16206 8.01132 2.3271 7.30967 2.62726 6.66242C2.92732 6.01539 3.35611 5.43631 3.88744 4.96054C6.02462 3.03866 9.30883 3.3676 11.2901 5.33901L11.2929 5.34172L12.0306 6.08514L12.9556 5.1541L12.9572 5.15253C13.4618 4.64822 14.064 4.25211 14.727 3.98839ZM12.1113 19.1343C12.1115 19.1341 12.1111 19.1345 12.1113 19.1343L19.3365 11.9091C19.3366 11.909 19.3363 11.9093 19.3365 11.9091C20.9162 10.321 21.1052 7.76931 19.6724 6.17646L19.6714 6.17538C19.3058 5.76694 18.8607 5.43733 18.3634 5.20671C17.8661 4.97608 17.327 4.84927 16.779 4.83403C16.231 4.81879 15.6857 4.91543 15.1764 5.11806C14.6673 5.32055 14.2049 5.62465 13.8173 6.01177C13.817 6.01202 13.8168 6.01227 13.8165 6.01253L12.4617 7.37631C12.3475 7.49121 12.1922 7.55581 12.0303 7.55576C11.8683 7.55572 11.713 7.49104 11.5989 7.37608L10.4326 6.20084C10.4322 6.2004 10.4317 6.19996 10.4313 6.19952C8.84314 4.62062 6.29252 4.43238 4.69996 5.86492L4.69888 5.8659C4.29044 6.23153 3.96083 6.67659 3.7302 7.17391C3.49958 7.67122 3.37277 8.21033 3.35753 8.75831C3.34229 9.30628 3.43893 9.85161 3.64156 10.361C3.84418 10.8703 4.14854 11.333 4.53602 11.7208L11.9495 19.1343C11.9497 19.1345 11.9493 19.1341 11.9495 19.1343C11.971 19.1553 12.0004 19.1676 12.0304 19.1676C12.0604 19.1676 12.0898 19.1553 12.1113 19.1343Z" fill="#FEFFFE" />
        </svg>
      </div>
    </button>
    <button class="with-wishlist-btn w-100 btn-wishlist" type="button" data-wishlist-button-state="selected">
      <div class="d-flex justify-content-center">
        <svg width="24" height="22" viewBox="0 0 24 22" fill="none" xmlns="http://www.w3.org/2000/svg">
          <path d="M8.31627 1.92939L12.1971 4.14699L14.4147 3.03819L17.1866 1.375L20.513 2.48379L22.7306 6.36458L22.1762 9.13656L20.513 11.3542L11.6427 19.6701L0.554688 8.02778L1.10909 5.25579L3.88108 1.92939H8.31627Z" fill="var(--with-wishlist-color)" />
          <path fill-rule="evenodd" clip-rule="evenodd" d="M15.1072 1.1844C15.9028 0.867877 16.7546 0.716908 17.6106 0.740717C18.4667 0.764526 19.3088 0.962614 20.0856 1.32287C20.8622 1.68302 21.5573 2.19766 22.1284 2.83539C24.435 5.40051 24.0402 9.34235 21.674 11.7204L12.9971 20.3974L12.4811 19.8815L12.9946 20.3999C12.6955 20.6961 12.2916 20.8623 11.8706 20.8623C11.4497 20.8623 11.0457 20.6961 10.7467 20.3999L10.7442 20.3974L1.84355 11.4968C1.23827 10.8911 0.762643 10.1681 0.44612 9.37239C0.129596 8.57672 -0.0213736 7.72486 0.00243543 6.86887C0.0262445 6.01287 0.224332 5.17072 0.584596 4.39388C0.944735 3.61729 1.45938 2.92226 2.09711 2.35121C4.66223 0.0444927 8.60407 0.439303 10.9821 2.80547L10.9854 2.80871L11.8709 3.701L12.981 2.58353L12.9829 2.58165C13.5887 1.97636 14.3114 1.50093 15.1072 1.1844ZM11.9677 19.3631L20.6396 10.6912C22.5356 8.78509 22.7626 5.72241 21.0428 3.81061L21.0416 3.80931C20.6028 3.31909 20.0687 2.92348 19.4717 2.64667C18.8748 2.36986 18.2278 2.21766 17.57 2.19936C16.9124 2.18108 16.2578 2.29707 15.6464 2.54027C15.0355 2.78331 14.4805 3.1483 14.0153 3.61294L14.0143 3.61384L12.3882 5.25071C12.2512 5.38862 12.0648 5.46615 11.8704 5.4661C11.676 5.46605 11.4897 5.38841 11.3527 5.25044L9.9529 3.83987L9.95129 3.83828C8.04514 1.94322 4.98378 1.71729 3.07232 3.43669L3.07103 3.43785C2.5808 3.8767 2.1852 4.41088 1.90838 5.00777C1.63158 5.60468 1.47938 6.25174 1.46108 6.90944C1.4428 7.56713 1.55879 8.22166 1.80199 8.83303C2.0452 9.44438 2.41049 9.99973 2.87556 10.4651L11.7735 19.3631C11.7993 19.3883 11.8346 19.4031 11.8706 19.4031C11.9067 19.4031 11.9419 19.3883 11.9677 19.3631Z" fill="var(--with-wishlist-color)" />
        </svg>
      </div>
    </button>
  </div>
</template>
```

#### 2. Importing the wishlist template wherever required

Now you can use it directly wherever you need the wishlist button, for example we need it in the product card listing.&#x20;

So, all you need to do is use the custom tag **`wishlist-button-load-point`**

Define this tag and in the attribute **`data-template-id`**&#x6D;ention the id you used for template, in our case it was **`"heart-wishlist-button-template"`** inside the tag you can define the UI element for the button as a default, else whatever has been defined inside the template shall be rendered.

```html
<wishlist-button-load-point data-product-uuid="" data-sku-uuid="" data-template-id="heart-wishlist-button-template" data-add-event="CATEGORY_PAGE_WISHLIST_ADDED" class="wishlist-load-point-wrapper me-3 me-lg-3 p-12 h-100 hidden" style="max-width: 100px;
              width: 100%;">
  <button type="button" class="detail-wishlist-btn btn-transparent px-0" data-wishlist-button-state="unselected">
    <span class="wishlist-svg-wrapper">
      <svg width="24" height="25" viewBox="0 0 24 25" fill="none" xmlns="http://www.w3.org/2000/svg">
        <path fill-rule="evenodd" clip-rule="evenodd" d="M14.5098 3.51143C15.2835 3.19087 16.1127 3.02588 16.9501 3.02588C17.7875 3.02588 18.6168 3.19087 19.3904 3.51143C20.1641 3.83199 20.867 4.30184 21.459 4.89413C22.0511 5.48608 22.5209 6.18889 22.8414 6.96241C23.1619 7.73605 23.3269 8.56527 23.3269 9.4027C23.3269 10.2401 23.1619 11.0694 22.8414 11.843C22.5209 12.6166 22.0511 13.3194 21.4588 13.9114C21.4588 13.9115 21.4589 13.9114 21.4588 13.9114L12.6188 22.7514C12.2771 23.0931 11.7231 23.0931 11.3814 22.7514L2.5414 13.9114C1.34561 12.7156 0.673828 11.0938 0.673828 9.4027C0.673828 7.71161 1.34561 6.08977 2.5414 4.89399C3.73719 3.6982 5.35902 3.02641 7.05012 3.02641C8.74122 3.02641 10.3631 3.6982 11.5588 4.89399L12.0001 5.33527L12.4413 4.89413C13.0333 4.30184 13.7362 3.83199 14.5098 3.51143ZM20.2213 6.13128C19.7918 5.70158 19.2818 5.36071 18.7205 5.12814C18.1593 4.89558 17.5577 4.77588 16.9501 4.77588C16.3426 4.77588 15.741 4.89558 15.1797 5.12814C14.6184 5.36071 14.1085 5.70158 13.679 6.13128L12.6188 7.19142C12.2771 7.53313 11.7231 7.53313 11.3814 7.19142L10.3214 6.13142C9.4538 5.26383 8.27709 4.77641 7.05012 4.77641C5.82315 4.77641 4.64644 5.26383 3.77884 6.13142C2.91124 6.99902 2.42383 8.17574 2.42383 9.4027C2.42383 10.6297 2.91124 11.8064 3.77884 12.674L12.0001 20.8953L20.2214 12.674C20.6511 12.2445 20.9921 11.7344 21.2247 11.1731C21.4572 10.6118 21.5769 10.0102 21.5769 9.4027C21.5769 8.79516 21.4572 8.19357 21.2247 7.63229C20.9921 7.07102 20.651 6.56078 20.2213 6.13128Z" fill="#DF6F39" />
      </svg>
    </span>
    <!-- <span>Wishlist</span> -->
  </button>
</wishlist-button-load-point>
```

{% hint style="info" %}
Please note that you need to install the **Wishlist plugin** on the seller side for the changes to reflect on the store front.
{% endhint %}


# Countdown timer plugin

An active countdown timer looks like this in the product details page.

<figure><img src="https://869317877-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEpxvKr8371wMxhqFS6hu%2Fuploads%2FLcH4KdMvD5rT3PxAExR7%2FScreenshot%202023-04-05%20at%2018.06.06.png?alt=media&amp;token=2bf3ebe4-53f7-4703-91e9-ccb94428f5d6" alt=""><figcaption></figcaption></figure>

> A countdown timer displays a visual countdown to a specific date and time, usually the end of a sale or promotion. This creates a sense of urgency for potential buyers and encourages them to take action before the timer runs out. The countdown timer can help increase conversions, drive sales, and create a sense of excitement for customers.

### 🤔 How to use ?

{% code overflow="wrap" %}

```html
<div class="dukaan_plugins-countdown_timer" id="dukaan_plugins-countdown_timer-below_price"></div>
```

{% endcode %}


# Product scarcity plugin

The product scarcity plugin draws customers' attention and creates a sense of urgency to initiate an order. It places a statement signifying ‘low stock alert’ or ‘limited availability’ below your product’s listing.

This is how the plugin looks like in the product page

<figure><img src="https://869317877-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEpxvKr8371wMxhqFS6hu%2Fuploads%2F0WgUEsJon0QFV7kRbKvZ%2FScreenshot%202023-04-12%20at%2019.09.32.png?alt=media&amp;token=e8df0f1e-cfc5-475e-99ef-065b5d9e9278" alt=""><figcaption><p>Hurry 10 order left</p></figcaption></figure>


# Testing and Deploying Your Theme

For every change you make in the code editor, there are 2 steps involved.

1. Previewing how your change would look like & testing it.&#x20;
2. Deploying the changes to your site&#x20;

## 👀 Previewing your changes

1. Once you make your changes in the code editor click on the **"Save & preview"** button on the top right corner of the code editor

<figure><img src="https://869317877-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEpxvKr8371wMxhqFS6hu%2Fuploads%2Fe7iDctxvz0tLuHfatTZD%2FScreenshot%202023-04-03%20at%2016.40.36.png?alt=media&amp;token=7d4af32e-6b9f-4291-8023-5384455231a6" alt=""><figcaption></figcaption></figure>

This deploys your changes to an **intermediate url which is not your actual site**, i.e. your customers won't be able to see the changes, so its a perfect place to experiment

The intermediate url ends with a domain **".sh"** instead of the original Dukaan domain **".io"**\
So, if your store url was **"general-store",** \
It's preview url would be - **"mydukaan.sh/general-store"** \
whereas the original store link would be - **"mydukaan.io/general-store"**

On successful deployment you'd see a message something like this

<figure><img src="https://869317877-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEpxvKr8371wMxhqFS6hu%2Fuploads%2Ffj7pTSIWsfQJMlZMWnbN%2FScreenshot%202023-04-03%20at%2016.52.48.png?alt=media&amp;token=34fd8adc-3595-4653-8133-eb16345ffb44" alt=""><figcaption></figcaption></figure>

Your changes would be visible in your preview url, and you can do all the testing you want here before you make the changes live for your customers.&#x20;

Mobile screen preview is directly visible from the code editor itself, its on the right side of the code editor

<figure><img src="https://869317877-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEpxvKr8371wMxhqFS6hu%2Fuploads%2FcjEq4myLawUWPJ1RP5wV%2FScreenshot%202023-04-03%20at%2016.57.44.png?alt=media&amp;token=e026c243-b93a-4294-a726-cd54af0cd137" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Note - You can deploy to your preview url as many times as you want, so feel free to experiment your ideas.
{% endhint %}

## 🚀 Deploying your changes

Now when you're sure that your customers must see the changes you've made you can deploy it with a single click by simply clicking on the **"Publish"** button

<div align="center"><figure><img src="https://869317877-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEpxvKr8371wMxhqFS6hu%2Fuploads%2FrTxnR5sqe6Rm5PjkZpJN%2FScreenshot%202023-04-03%20at%2016.56.01.png?alt=media&amp;token=76ba4607-0de6-4d4b-9a5a-61f9352224c2" alt=""><figcaption></figcaption></figure></div>

This makes all your changes live for your customers instantly on your original store url.


# Code Snippets

We have compiled some of the most commonly asked for customisation requests from our customers and listed it here for you.


# Changing text of Add to bag button

Say you want to update the text of **"Add to bag"** button to **"Place in bag"**.\
To replace this you need to go to the file that contains the text "Add to bag" and replace it with the new text.\
\
You can find the text in the file layout.html.\
In the file search for the text "Add to bag" and you'd find this code

<figure><img src="https://869317877-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEpxvKr8371wMxhqFS6hu%2Fuploads%2FS7EO0lJMixf5SnheC2eF%2FScreenshot%202023-04-03%20at%2018.46.24.png?alt=media&amp;token=32b34e25-921c-46bb-a9e3-48ccbd518cdc" alt=""><figcaption></figcaption></figure>

Line number 291 has Nunjucks code `DUKAAN_LANGUAGE.ADD_TO_BAG`\
It basically fetches the text equivalent for "Add to bag" from the variable DUKAAN\_LANGUAGE which contains a list of all texts as per the store language set.<br>

So, you can replace it directly with your text "Place in bag", and this is how the updated code would look like.

<figure><img src="https://869317877-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEpxvKr8371wMxhqFS6hu%2Fuploads%2FnB1t2CYWxzGkKFFPzRq8%2FScreenshot%202023-04-03%20at%2018.56.27.png?alt=media&amp;token=a8e983a2-035e-46d1-9661-0d9d4e9b380f" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
You need to replace the text for all occurrences of "Add to bag" button in the layout.html file since this button is used in multiple places, make sure you don't miss out on any else you'll see the "Add to bag" text in some places and "Place in bag" button in the remaining.
{% endhint %}

Deploy the change to see it live on your preview and main store.

## Alternative using Javascript (Not recommended)

You can use query selectors to target the Add to Bag button and replace its text.\
Place this code snippet in the layout.js file and then deploy to see the changes live.

```javascript
const buttons = document.querySelectorAll('.without-cart-add-to-bag-button');

buttons.forEach(button => {
  button.textContent = 'Place in bag';
});
```


# Adding shadow to product cards

You can make the product cards more fancy by adding some shadow to it so that it highlights and looks funky.

```css
.card {
  border-radius: 10px;
  box-shadow: 0px 5px 20px rgba(0, 0, 0, 0.5);
  padding: 20px;
  background-color: #F7F7F7;
  transition: all 0.3s ease-in-out;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0px 15px 30px rgba(0, 0, 0, 0.3);
  background-color: #FFC107;
}
```

The above CSS makes the card with rounded edges, a shadow effect, and a light grey background. When you hover over the card, it will move up slightly, the shadow effect will get stronger, and the background color will change to a yellowish color.

Add this CSS to the layout.css file and deploy the changes.

This is how the card looked previously

<figure><img src="https://869317877-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEpxvKr8371wMxhqFS6hu%2Fuploads%2Fy81fGdS66muDHh59t1P7%2FScreenshot%202023-04-03%20at%2019.49.29.png?alt=media&amp;token=3ba87774-397e-440a-9a2d-fa931baf87ec" alt=""><figcaption></figcaption></figure>

This is how it looks after adding the CSS, where the middle card is hovered upon.

<figure><img src="https://869317877-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEpxvKr8371wMxhqFS6hu%2Fuploads%2Fs1SW5cCqlTvVgv1qRISl%2FScreenshot%202023-04-03%20at%2019.49.58.png?alt=media&amp;token=25dc2454-18a9-49d7-9741-b3461ad55eec" alt=""><figcaption></figcaption></figure>


# Adding auto-scrolling text in homepage

We will try to add a non-stop horizontal scrolling banner containing a brand name on the top of our store.

Open the layout.html page and the following HTML code to it just inside the body tag or anywhere as per your requirement

```html
<div class="scroll">
  <div class="m-scroll">
    <span style="rbackground: cyan;">BRAND | BRAND | BRAND </span>
    <span style="rbackground: cyan;">BRAND | BRAND | BRAND </span>
    <span style="rbackground: cyan;">BRAND | BRAND | BRAND </span>
    <span style="rbackground: cyan;">BRAND | BRAND | BRAND </span>
    </div>
</div>
```

After this, open the layout.css file and add the following CSS to the file.

```css
.scroll {
  position: relative;
  width: 100vw;
  height: 15%;
  background-color: #252525;
  overflow: hidden;
  z-index: 1;
  margin: 0;
  padding: 0;
}

.m-scroll {
  overflow: hidden;
  height: 100%;
  white-space: nowrap;
  animation: scrollText 10s infinite linear;
  margin: 0;
  font-size: 0;
  display: inline-block;
}

span {
  font-size: 50px;
  display: inline-block;
  min-width: 100vw;
  margin: 0;
  padding: 0;
  color: white;
}

@keyframes scrollText {
  from {
    transform: translateX(0%);
  }
  to {
    transform: translateX(-50%);
  }
}
```

Once you're done, you can deploy the changes and wait for them to reflect on your store page. This is how it would look like&#x20;

<figure><img src="https://869317877-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEpxvKr8371wMxhqFS6hu%2Fuploads%2FXpzW2HeT8ZDjsXF5QrTz%2FScreenshot%202023-04-04%20at%2000.11.41.png?alt=media&amp;token=ee8219c4-483a-47d9-9281-041e0f2b35b8" alt=""><figcaption></figcaption></figure>


