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
The promotions to be created.
Returns
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
The promotion to be created.
Returns
The created promotion.
Was this section helpful?