Skip to main content

Add Product Discount (Seller)

Adds or updates a discount on a product.

Path Parameters

productId
string (uuid)
required
Product identifier

Request Body

discountPercentage
number
required
Discount percentage (1-99)
startDate
string (datetime)
When the discount starts (optional, defaults to now)
endDate
string (datetime)
When the discount ends (optional, null for indefinite)

Response Codes

  • 204 No Content - Discount added successfully
  • 400 Bad Request - Invalid discount percentage or dates
  • 404 Not Found - Product not found or seller doesn’t own the product

Examples

curl -X POST "https://your-server.com/api/products/product/3fa85f64-5717-4562-b3fc-2c963f66afa6/discount" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "discountPercentage": 25,
    "startDate": "2024-01-20T00:00:00Z",
    "endDate": "2024-01-31T23:59:59Z"
  }'

Error Response Examples

Invalid Percentage (400 Bad Request):
"Discount percentage must be between 1 and 99"
Invalid Dates (400 Bad Request):
"End date must be after start date"
Product Not Found (404 Not Found):
"Product not found or you don't have permission to modify it"

Remove Product Discount (Seller)

Removes the active discount from a product, returning it to regular price.

Path Parameters

productId
string (uuid)
required
Product identifier

Response Codes

  • 204 No Content - Discount removed successfully
  • 400 Bad Request - Product has no active discount
  • 404 Not Found - Product not found or seller doesn’t own the product

Examples

curl -X DELETE "https://your-server.com/api/products/product/3fa85f64-5717-4562-b3fc-2c963f66afa6/discount" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Error Response Examples

No Active Discount (400 Bad Request):
"This product does not have an active discount"
Not Authorized (404 Not Found):
"Product not found or you don't have permission to modify it"

View Discounted Products

Retrieves all products currently on discount. This endpoint is documented in detail in the Products API.

Quick Example

cURL
curl -X GET "https://your-server.com/api/products/with-discount/page/1?pageSize=20"

Discount Management Guide

Discount Types

Wolfix.Server currently supports percentage-based discounts:
  • Minimum: 1%
  • Maximum: 99%
  • Applied to the base product price

Discount Calculation

Discounted Price = Original Price × (1 - Discount Percentage / 100)

Example:
Original Price: $100
Discount: 25%
Discounted Price: $100 × (1 - 0.25) = $75
Savings: $25

Scheduling Discounts

1

Set Start Date

Specify when the discount becomes active (optional, defaults to immediate)
2

Set End Date

Specify when the discount expires (optional, leave null for indefinite)
3

Automatic Activation

Discount automatically activates at the specified start date
4

Automatic Expiration

Discount automatically expires at the end date if specified

Best Practices

Flash Sales: Use short date ranges (e.g., 24-48 hours) to create urgency
Seasonal Sales: Schedule discounts for holidays or special events in advance
Clearance: Use indefinite discounts (no end date) for clearance items
Frequent or excessive discounts may devalue your products. Use strategically to drive sales during slow periods.

Discount Policies

  1. One Discount Per Product - Only one discount can be active at a time
  2. Seller-Managed - Each seller manages their own product discounts
  3. Automatic Pricing - Discounted prices are calculated and displayed automatically
  4. Override Discounts - Adding a new discount replaces any existing discount
  5. Immediate Effect - Discount changes take effect immediately (unless scheduled)

Monitoring Discount Performance

Track the effectiveness of your discounts by monitoring:
  • Product views before and during discount period
  • Conversion rates
  • Total sales volume
  • Revenue impact
  • Customer acquisition from discounted products

Common Use Cases

Holiday Sale:
{
  "discountPercentage": 20,
  "startDate": "2024-12-20T00:00:00Z",
  "endDate": "2024-12-26T23:59:59Z"
}
Flash Sale (24 hours):
{
  "discountPercentage": 50,
  "startDate": "2024-01-15T10:00:00Z",
  "endDate": "2024-01-16T10:00:00Z"
}
Permanent Clearance:
{
  "discountPercentage": 30,
  "startDate": null,
  "endDate": null
}
Upcoming Promotion:
{
  "discountPercentage": 15,
  "startDate": "2024-02-01T00:00:00Z",
  "endDate": "2024-02-14T23:59:59Z"
}

Build docs developers (and LLMs) love