# Coupon Add-on old

**Installation of Spurtcommerce coupon Addon**

This document will help you to install coupon add-on to your Spurtcommerce server for single vendor as well as multi vendor

[<mark style="color:blue;">**Setup an API (Step By Step)**</mark>](#setup-an-api-step-by-step)

For setting up the API, you need to execute the following steps:

* Installing an extension&#x20;
* Run the application&#x20;
* Make the build

**Step 1 : Installing an extension**&#x20;

These are the steps that need to be executed for installation of the extension.

Usually spurcommerce comes packed in a zip, whose name ends in <mark style="color:green;">**"coupon-addon.zip".**</mark> Extract the zip file, open api folder and open addon folder within that and copy the content of addon folder into the specified path

&#x20;                                      **Path - \<PROJECT\_ROOT>/addon**

**Step 2 : Run the application**

After you have completed the installation of the above mentioned steps, you can run the application and also view the changes.

```
$ npm start serve
```

Once you execute the above command, add-on file will get integrated into the backend API.

**Step 3 : Make the build**

These are the steps that need to be followed for generating the build.

To run the below command

```
 $ npm run build
```

Then latest built files can be deployed into the server.

## Admin Setup

&#x20;These are the steps that need to be executed for installation of the extension.

●      Installing an extension

●      Update the configuration

●      Module Detail

●      Run the application

●      Make the build&#x20;

**Step 1 : Installing an extension**

These are the steps that need to be executed for installation of the extension.

&#x20;Usually spurcommerce comes packed in a zip, whose name ends in "<mark style="color:green;">**coupon.addOn.zip**</mark>".

&#x20;Extract the zip file and copy the content of admin/add-ons folder into the specified path

&#x20;                       **Path -  admin/add-ons**

&#x20;**Note:**

1\) In add-ons folder if already a marketing folder exists.

Inside marketing folder paste coupon folder.

&#x20;In marketing routing file(<mark style="color:green;">**marketing.routing.ts**</mark>) paste the below code.

&#x20;

```
export const couponRoutes = [
 {
 path: 'coupon',
 loadChildren: () => import('../marketing/coupon/coupon.module').then(m =>
 m.CouponModule),
 canActivate: [AuthGuard],
 },
 ];
 
```

2\) Inside the addon if the marketing folder doesn’t exist.

Paste

**Step 2 : Update the configuration**

After the installation of the extension, you will have to update certain configurations into the default Spurtcommerce config files. For this, you need to follow the steps below.

&#x20;**Update Reducer Config**

1\)     Import below line into the <mark style="color:green;">**add-ons/add-ons-reducer.ts**</mark>

```
import * as fromCoupon from 
'../add-ons/marketing/coupon/core/reducer/coupon.reducer'

```

2. Add the reducer into the below object

```
	coupon:fromCoupon.reducer
```

3. After adding its looks like below

```
export const AddOnReducers: ActionReducerMap<State> = {
   coupon:fromCoupon.reducer

};

```

**Update State Config**

1\)      Import below line into the <mark style="color:green;">**add-ons/add-ons-state.ts**</mark>

```
import { CouponState } from 
'./marketing/coupon/core/reducer/coupon.state';

```

2. Add the state into the below object

```
coupon:CouponState
```

3. After adding its looks like below

**export interface AddOnAppState {**

**coupon:CouponState**

**}**

**Step 3 : Change the routing file(**<mark style="color:green;">**manage-promotions.routing.ts**</mark>**)**

<mark style="color:green;">**Inside the /src/theme/default/admin/marketing/components/manage-promotions/manage-promotions.routing.ts**</mark>

&#x20; If the point one already exists in your file, skip point one

1. Import below line

```
import * as marketingRouting from '../../../../../../../add-ons/marketing/marketing.routing';
```

2\.     Add these routes below the managePromotionRoutes array

&#x20;**managePromotionRoutes.push(marketingRouting.couponRoutes\[0]);**

&#x20;**For setting up the tab add this line in**

<mark style="color:green;">**/src/theme/default/admin/marketing/components/header/header.component.html**</mark>

<mark style="color:green;">**Below line no=11**</mark>

```
<input type="checkbox" [checked]="checked" id="check"
 (click)="$event.stopPropagation(); onClick($event)">
 <div class="dd-c"> 
<ul>
 <li > 
                    <a href="#" 
[routerLink]="['/marketing/manage-promotions/coupon']"
 [routerLinkActive]="'active'"> 
{{'Marketing.Coupons'|translate}}
 </a> 
</li> 
</ul> 
</div> 

```

**Step 4 : Run the application**

After you have integrated the catalog Module into Spurtcommerce, you can use the following command to run the application.

```
 npm run large-serve
```

Once you execute the above command you can view the installed module in Spurtcommerce, within the page in which you have integrated.

**Step 5 : Make the build**

&#x20;To run the below command

```
 npm run large-build
```

Then the latest built files can be deployed into the server.

## Vendor Setup

&#x20;These are the steps that need to be executed for installation of the extension.

* Installing an extension
* Update the configuration
* Module Detail
* Run the application
* Make the build

**Step 1 : Installing an extension**               &#x20;

These are the steps that need to be executed for installation of the extension.

Usually spurcommerce comes packed in a zip, whose name ends in ."<mark style="color:green;">**coupon.addOn.zip**</mark>"&#x20;

Extract the zip file and copy the content of <mark style="color:green;">**vendor/add-ons**</mark> folder into the specified path

&#x20;                                                         **Path -  vendor/add-ons**

**Step 2 : Update the configuration**

After the installation of the extension, you will have to update certain configurations into the default Spurtcommerce config files. For this, you need to follow the steps below.&#x20;

**Update Reducer Config**

1. Import below line into the <mark style="color:green;">**add-ons/add-ons-reducer.ts**</mark>

```
 import * as fromMarketing from './marketing/core/reducer/marketing.reducer'

```

2. Add the reducer into the below object

```
marketing: fromMarketing.reducer,

```

3. After adding its looks like below

**export const AddOnReducers: ActionReducerMap\<State> = {**

**marketing: fromMarketing.reducer,**

**};**

**Update State Config**

1. &#x20;Import below line into the <mark style="color:green;">**add-ons/add-ons-state.ts**</mark>

```
     import { MarketingState } from "./marketing/core/reducer/marketing.state";

```

2. Add the state into the below object

```
    marketing: MarketingState;
```

3. After adding its looks like below

&#x20;  **export interface AddOnAppState {**

&#x20;                  **marketing: MarketingState;**

**}**

4. &#x20;Import below line into the <mark style="color:green;">**add-ons/add-ons-effect.ts**</mark>

```
                        import { MarketingEffect } from 
                       "./marketing/core/effects/marketing.effect";

```

5. Add the effect into the below object

```
                   MarketingEffect

```

&#x20;**After adding its looks like below**

&#x20;  export const ADD\_ON\_EFFECT = \[

&#x20;  MarketingEffect,

];

**Update Component Config**

1. Import below line into the <mark style="color:green;">**add-ons/add-ons.shared.ts**</mark>

```
import { CouponComponent } from
 "./marketing/template/coupon/coupon.component";

```

```
import { CouponTrackingComponent } from "./marketing/template/coupon-tracking/coupon-tracking.component";

```

```
import { AddCouponComponent } from "./marketing/template/add-coupon/add-coupon.component";

```

2. Add the following components into the below object

&#x20;                                     **AddCouponComponent,**

&#x20;                                               **CouponTrackingComponent,**

&#x20;                                              **CouponComponent,**

3. &#x20;**After adding its looks like below**

export const ADD\_ON\_COMPONENTS = \[

&#x20;                      AddCouponComponent,

&#x20;                                               CouponTrackingComponent,

&#x20;                                               CouponComponent,

&#x20;                    ]

**Step 3 : Module Detail**

**AddCouponComponent,**

**CouponTrackingComponent,**

**CouponComponent**

&#x20;are listed below. You may use these modules, in any page of Spurtcommerce.&#x20;

Also, you can find the steps below to use the modules in marketing in Spurtcommerce pages.&#x20;

In the marketing addon having three component.

1. AddCouponComponent,
2. CouponTrackingComponent,
3. CouponComponent,

&#x20;**Add the below steps to configure routing**&#x20;

&#x20;<mark style="color:green;">**In /src/app/default/pages/component/marketing/manage-promotions/manage-promotions.module.ts**</mark>

1. &#x20;Import below line

```
import { AddCouponComponent } from '../../../../../../../add-ons/marketing/template/add-coupon/add-coupon.component';

```

```
import { CouponComponent } from '../../../../../../../add-ons/marketing/template/coupon/coupon.component';

```

```
import { CouponTrackingComponent } from '../../../../../../../add-ons/marketing/template/coupon-tracking/coupon-tracking.component';

```

&#x20; 2\)  Add these routes below the Routes array

```
                           
                  { path: 'coupon', 
component: CouponComponent, 
data: { title: 'coupons', urls: [
{ title: 'Home' , url: '/dashboard'},
 { title: 'marketing', url: 'marketing/manage-promotions' },
{ title: 'manage promotions', url: 'marketing/manage-promotions' }, 
{ title: 'Coupons' }] 
} 
},


{ path: 'add-coupon', 
component: AddCouponComponent, 
data: { title: 'Add Coupon', urls: [
{ title: 'Home', url: '/dashboard' },
{ title: 'Marketing', url: '/marketing/manage-promotions/' }, 
{ title: 'Manage-promotions', url: '/marketing/manage-promotions/' },
 { title: 'Add Coupon' }] 
} 
},


{ path: 'coupon-tracking', 
component: CouponTrackingComponent, 
data: { title: 'Settings', urls: [
{ title: 'Home', url: '/dashboard' },
{ title: 'Marketing', url: '/marketing/manage-promotions/' }, 
{ title: 'Manage-promotions', url: '/marketing/manage-promotions/' }, 
{ title: 'Coupon Tracking' }] 
}
 },


```

**For setting up the tab add this line in**

<mark style="color:green;">**/src/app/default/pages/component/marketing/layout/products.component.html**</mark>

<mark style="color:green;">**Below line = 17**</mark>

```
   <div class="dropdown-menu" aria-labelledby="dropdownMenuButton"> 
                             <a href="javascript:void(0)" [routerLink]="['/marketing/manage-promotions/coupon']" class="">
{{'Marketing.nav.Coupons'|translate}}
</a>
 </div>

```

**Step 4 : Run the application**

After you have integrated the marketing Module into Spurtcommerce, you can use the following command to run the application.

```
 ng serve

```

Once you execute the above command you can view the installed module in Spurtcommerce, within the page in which you have integrated.&#x20;

**Step 5 : Make the build**

To run the below command

```
ng build --prod

```

Then the latest built files can be deployed into the server.

<br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.spurtcommerce.com/addons/marketing-related-addons/coupon-add-on-old.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
