# Script (Add Script)

# Overview

The **Script Info** section allows administrators to create, manage, and configure custom scripts within the application. Scripts can be used to add custom functionality, execute JavaScript code, integrate third-party services, or extend the application's behavior wherever script support is available.

---

# Add Script

To create a new script:

1. Navigate to **Scripts → Script Info**.
2. Click **Add Script**.
3. Enter the **Title**.
4. Enter a unique **Slug**.
5. Write or paste the required code in the **Editor**.
6. Preview the script if required.
7. Click **Submit** to save the script.

If no script is added, the system displays:

> **Please add a script first.**

---

# Script Details

The following fields are available while creating a script:

| Field | Description |
|--------|-------------|
| **Title** | Enter a unique and meaningful name for the script. |
| **Slug** | Enter a unique identifier used to reference the script. |
| **Preview** | Displays a preview of the script before saving. |
| **Editor** | Code editor used to write or modify the script. |
| **Code** | Displays the script content. |
| **Script** | Contains the custom script or JavaScript code to be executed. |

---

# Script Mapping

After creating a script, administrators can associate it with specific application content.

A script can be mapped to:

- Categories
- Products
- Packages (where supported)

Mapping ensures that the script executes only for the selected content instead of affecting the entire application.

For example:

- A script mapped to a **Category** will execute only when that category is accessed.
- A script mapped to a **Product** will execute only for the selected product.

This provides better control over where and how custom scripts are applied.

---

# Code Copy to Editor

The **Code Copy to Editor** option allows administrators to quickly copy the generated or existing script into the editor for further modification.

This helps simplify editing without manually copying and pasting the code.

---

# Submit

After completing the script configuration and mapping, click **Submit** to save the script.

Once submitted, the script becomes available for use within the selected Categories, Products, or other supported modules.

---

# Manage Scripts

Administrators can:

- Create new scripts.
- Edit existing scripts.
- Preview script content.
- Write custom JavaScript code.
- Copy code into the editor.
- Map scripts to Categories and Products.
- Update or remove script mappings.
- Save scripts for use within the application.

---

# Best Practices

- Use meaningful script titles.
- Keep the **Slug** unique for every script.
- Test scripts before deploying them in production.
- Map scripts only to the required Categories or Products.
- Review the script code before saving.
- Update scripts carefully to avoid affecting dependent features.

---

> **Important:**  
> A script is saved only after clicking the **Submit** button. Before saving, verify the script code and ensure it is mapped to the correct **Category** or **Product**. You can use the **Code Copy to Editor** option to quickly copy and modify existing code before submission.