Variant price campaign
General
Variant price campaign is a reduction within a campaign for a certain product variant.
You can overwrite generic price campaign with variant specific values.
If you want to reduce a product (all of its variants) by the same amount, you can use the Create or update product reductions method.
Admin API
Learn how to create, update and delete product and variant reductions.
Create or update variant reductions
This method is used to create or update product variant campaign reductions.
This method accepts a list of maximum 5,000 reductions.
await adminApi.apis.Campaigns.updateOrCreateVariantReductions({shopKey: shopKey, campaignId: campaignId}, {requestBody: reductions});
Parameter | Details |
---|---|
id | Integer READ-ONLY SCAYLE's internal reduction identifier. |
productVariantId | Integer SCAYLE's internal product variant identifier. |
productVariantReferenceKey | String Tenant provided product variant identifier. |
reduction | Integer The reduction percentage applied to this specific variant. |
Examples
Create variant reductions
let reductions = [
{
productVariantId: 1,
reduction: 10
},
{
productVariantReferenceKey: "my-reference-key",
reduction: 20
}
]
await adminApi.apis.Campaigns.updateOrCreateVariantReductions({shopKey: "ms", campaignId: 1}, {requestBody: reductions});
Create or update product reductions
Learn how to create product-specific price discounts.
When running a product-specific price campaign, all product variants will inherit the defined reduction.
This method is used to create or update product campaign reductions. Internally reductions are applied on variant level, this method is a shortcut to provide reductions for a product by setting the same reduction to all variants.
This method accepts a list of maximum 5,000 reductions.
await client.apis.Campaigns.updateOrCreateProductReductions({shopKey: shopKey, campaignId: campaignId}, {requestBody: reductions});
Parameter | Details |
---|---|
productId | Integer SCAYLE's internal product identifier. |
productReferenceKey | String Tenant provided product identifier. |
reduction | Integer The reduction percentage applied to all variants belonging to this product. |
Examples
Create product reductions
let reductions = [
{
productId: 1,
reduction: 10
},
{
productReferenceKey: "my-reference-key",
reduction: 20
}
]
await adminApi.apis.Campaigns.updateOrCreateProductReductions({shopKey: "ms", campaignId: 1}, {requestBody: reductions});
Get a collection of reductions
When requesting multiple reductions, you can paginate results and apply other parameters to narrow down your query.
This method can be used to get a collection of existing reductions. It is possible to refine the search by applying filters in the options.
As all reductions are stored internally on variant level, this method will return a collection of product variant campaign reductions.
Options
The operation can be used with optional parameters - called options:
Parameter | Details |
---|---|
limit | Integer Maximum number of items in the result. (default: |
filters[variantId] | String Comma-separated list of variant IDs that should be used for filtering. |
filters[variantReferenceKey] | String Comma-separated list of variant reference keys that should be used for filtering. |
filters[productId] | String Comma-separated list of product IDs that should be used for filtering. |
filters[productReferenceKey] | String Comma-separated list of product reference keys that should be used for filtering. |
filters[minId] | Integer Minimum reduction ID of entities that should be returned. |
filters[maxId] | Integer Maximum reduction ID of entities that should be returned. |
sort | String Sort by the provided column. Available values: id, variantId (default). |
sortDir | String Defines the sorting order: ascending or descending. Available values: asc (default), desc. |
If you do not provide filters, this method will return all product variant campaign reductions belonging to a specific campaign. You have the option to refine the results by applying filters for specific variants and/or products by using their respective IDs or reference keys.
Parameter
Parameter | Details |
---|---|
entities | ProductVariantCampaignReduction A collection of product variant campaign reductions. |
cursor | Cursor An object containing information for use in pagination. |
Examples
Get a Reduction Collection
let response = await adminApi.apis.Campaigns.getCampaignReductions({shopKey: "ms", campaignId: 1});
let reductions = response.body.entities;
reductions.forEach(
reduction => console.log(reduction.productVariantReferenceKey + ": " + reduction.reduction)
);
Read with Options
Get a reduction collection by filters:
let options = {
"shopKey": "ms",
"campaignId": 1,
"filters[variantId]": 1,
"filters[variantReferenceKey]": "myVariantReferenceKey",
"filters[productId]": 3,
"filters[productReferenceKey]": "myProductReferenceKey"
};
let response = await adminApi.apis.Campaigns.getCampaignReductions(options);
let reductions = response.body.entities;
reductions.forEach(
reduction => console.log(reduction.productVariantReferenceKey + ": " + reduction.reduction)
);
Delete campaign reductions
Delete any given price campaigns by using its ID.
You can choose to remove specific products or variants from a campaign with their reference key or ID.
This method can be used to delete existing campaign reductions. You can either call the method without any filters resulting in deletion of all reductions assigned to the provided campaign. If you only want to delete reductions for specific products or variants you can use several filter options.
Without providing any filters, ALL reductions belonging to the provided campaign will get deleted.
await adminApi.apis.Campaigns.deleteCampaignReductions({shopKey: shopKey, campaignId: campaignId});
Options
The operation can be used with optional parameters - called options:
Parameter | Details |
---|---|
filters[variantId] | String Comma-separated list of variant IDs that should get deleted. |
filters[variantReferenceKey] | String Comma-separated list of variant reference keys that should get deleted. |
filters[productId] | String Comma-separated list of product IDs that should get deleted. |
filters[productReferenceKey] | String Comma-separated list of product reference keys that should get deleted. |
Examples
Delete All Reductions
await adminApi.apis.Campaigns.deleteCampaignReductions({shopKey: "ms", campaignId: 1});
Delete with Options
Delete specific reductions:
let options = {
"shopKey": "ms",
"campaignId": 1,
"filters[variantId]": 1,
"filters[variantReferenceKey]": "myVariantReferenceKey",
"filters[productId]": 3,
"filters[productReferenceKey]": "myProductReferenceKey"
};
await adminApi.apis.Campaigns.deleteCampaignReductions(options);