Skip to main content
Skip to main content

create - Promotion Module Reference

This documentation provides a reference to the create method. This belongs to the Promotion Module.

create(data, sharedContext?): Promise<PromotionDTO[]>

This method creates promotions.

Example

const promotions = await promotionModuleService.create([
{
code: "50OFF",
type: "standard",
application_method: {
type: "percentage",
target_type: "items",
value: 50,
},
},
{
code: "FREESHIPPING",
type: "standard",
application_method: {
type: "percentage",
target_type: "shipping_methods",
value: 100,
},
},
{
code: "BUY2GET1",
type: "buyget",
application_method: {
type: "fixed",
target_type: "items",
buy_rules_min_quantity: 2,
apply_to_quantity: 1,
buy_rules: [
{
attribute: "SKU",
operator: "eq",
values: ["SHIRT"],
},
],
},
},
])

Parameters

dataCreatePromotionDTO[]Required
The promotions to be created.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<PromotionDTO[]>Required
The created promotions.

create(data, sharedContext?): Promise<PromotionDTO>

This method creates a promotion.

Example

const promotionA = await promotionModuleService.create({
code: "50OFF",
type: "standard",
application_method: {
type: "percentage",
target_type: "items",
value: 50,
},
})

const promotionB = await promotionModuleService.create({
code: "FREESHIPPING",
type: "standard",
application_method: {
type: "percentage",
target_type: "shipping_methods",
value: 100,
},
})

const promotionC = await promotionModuleService.create({
code: "BUY2GET1",
type: "buyget",
application_method: {
type: "fixed",
target_type: "items",
buy_rules_min_quantity: 2,
apply_to_quantity: 1,
buy_rules: [
{
attribute: "SKU",
operator: "eq",
values: ["SHIRT"],
},
],
},
})

Parameters

dataCreatePromotionDTORequired
The promotion to be created.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<PromotionDTO>Required
The created promotion.
Was this section helpful?