-
Notifications
You must be signed in to change notification settings - Fork 82
[Discounts] REST API #2780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
[Discounts] REST API #2780
Changes from 24 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
4a7ede4
[PHP API] Discounts (#2763)
mnocon 874c51f
Discount product guide
mnocon 71a691a
Fixed links and navigation
mnocon a347f04
Removed nav
mnocon 5291573
Fixed links
mnocon b1f437e
Fixed typo
mnocon 32ed031
Fixed badges
mnocon 093336d
Removed whitespace
mnocon e37ffdc
Fixes before review
mnocon 6ad81e4
After review fixes
mnocon 89bfa6d
Currency remark
mnocon 80fbf92
Discount migrations (#2768)
mnocon 2194538
Applied suggestions from code review (#2767)
mnocon 36a061d
[Discounts] Search overview (#2773)
mnocon c83a365
[Discounts] Event reference (#2776)
mnocon df345d6
[Discounts] Mentioned discounts in pricing and customer groups (#2775)
mnocon d290ecd
[Discounts] Discount policies (#2771)
mnocon 478faec
Discounts update (#2774)
mnocon ec4df5b
Discount codes
mnocon 23e31e3
[Discounts] REST API Reference
mnocon bed2686
Selfreview
mnocon dbe237f
Update docs/api/rest_api/rest_api_reference/input/ibexa-discounts.raml
mnocon 01e4593
Regenerated
mnocon 5378b3b
Merge remote-tracking branch 'origin/4.6' into discounts-rest
mnocon 4d2f690
Review fixes
mnocon ce8fbc5
Merge branch '4.6' into discounts-rest
adriendupuis 6e427e6
ibexa_dxp_v4.6.md: Link to Discounts REST API Ref
adriendupuis a26ec1f
Merge remote-tracking branch 'origin/discounts-rest' into discounts-rest
adriendupuis 9526b85
Generate REST API ref
adriendupuis ca47e18
[Discounts] Described Discounts API (#2783)
mnocon 78781df
[Discounts] Configuration (#2781)
mnocon 946e27b
discounts.md: Change cards layout
adriendupuis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
...api/rest_api_reference/input/examples/discount_codes/apply/POST/DiscountCode.json.example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"DiscountCode": { | ||
"code": "summer10" | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
..._api_reference/input/examples/discount_codes/apply/POST/DiscountCodeResponse.json.example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"DiscountCode": { | ||
"_media-type": "application\/vnd.ibexa.api.DiscountCode+json", | ||
"id": 1, | ||
"code": "my_secret_code", | ||
"created_at": { | ||
"date": "2025-06-10 14:14:06.000000", | ||
"timezone_type": 3, | ||
"timezone": "UTC" | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
docs/api/rest_api/rest_api_reference/input/examples/discounts/Discount.json.example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"Discount": { | ||
"_media-type": "application/vnd.ibexa.api.Discount+json", | ||
"id": 1, | ||
"identifier": "summersale2025", | ||
"name": "SummerSale2025", | ||
"type": "catalog", | ||
"label": "Summer Sale 2025", | ||
"labelDescription": "Summer Sale 2025", | ||
"priority": 1, | ||
"isEnabled": true, | ||
"createdAt": "2025-06-10T09:43:42+00:00", | ||
"updatedAt": "2025-06-10T09:48:23+00:00", | ||
"startDate": "2025-07-01T09:34:19+00:00", | ||
"endDate": "2025-07-31T12:00:00+00:00", | ||
"DiscountExpressionAware": { | ||
"_media-type": "application/vnd.ibexa.api.DiscountExpressionAware+json", | ||
"expressionValues": { | ||
"discount_amount": "10" | ||
} | ||
}, | ||
"DiscountConditions": [ | ||
{ | ||
"_media-type": "application/vnd.ibexa.api.DiscountExpressionAware+json", | ||
"expressionValues": { | ||
"currency_code": "USD" | ||
} | ||
} | ||
], | ||
"DiscountTranslations": [ | ||
{ | ||
"_media-type": "application/vnd.ibexa.api.DiscountTranslation+json", | ||
"languageCode": {}, | ||
"name": "SummerSale2025", | ||
"description": null, | ||
"label": "Summer Sale 2025", | ||
"labelDescription": "Summer Sale 2025" | ||
} | ||
] | ||
}, | ||
"isDiscountCodeAware": { | ||
"_media-type": "application/vnd.ibexa.api.isDiscountCodeAware+json", | ||
"isDiscountCodeAware": false | ||
} | ||
} |
102 changes: 102 additions & 0 deletions
102
docs/api/rest_api/rest_api_reference/input/examples/discounts/DiscountList.json.example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
{ | ||
"DiscountList": { | ||
"_media-type": "application/vnd.ibexa.api.DiscountList+json", | ||
"Discount": [ | ||
{ | ||
"_media-type": "application/vnd.ibexa.api.Discount+json", | ||
"id": 1, | ||
"identifier": "summersale2025", | ||
"name": "SummerSale2025", | ||
"type": "catalog", | ||
"label": "Summer Sale 2025", | ||
"labelDescription": "Summer Sale 2025", | ||
"priority": 1, | ||
"isEnabled": true, | ||
"createdAt": "2025-06-10T09:43:42+00:00", | ||
"updatedAt": "2025-06-10T09:48:23+00:00", | ||
"startDate": "2025-07-01T09:34:19+00:00", | ||
"endDate": "2025-07-31T12:00:00+00:00", | ||
"DiscountExpressionAware": { | ||
"_media-type": "application/vnd.ibexa.api.DiscountExpressionAware+json", | ||
"expressionValues": { | ||
"discount_amount": "10" | ||
} | ||
}, | ||
"DiscountConditions": [ | ||
{ | ||
"_media-type": "application/vnd.ibexa.api.DiscountExpressionAware+json", | ||
"expressionValues": { | ||
"currency_code": "USD" | ||
} | ||
} | ||
], | ||
"DiscountTranslations": [ | ||
{ | ||
"_media-type": "application/vnd.ibexa.api.DiscountTranslation+json", | ||
"languageCode": {}, | ||
"name": "SummerSale2025", | ||
"description": null, | ||
"label": "Summer Sale 2025", | ||
"labelDescription": "Summer Sale 2025" | ||
} | ||
] | ||
}, | ||
{ | ||
"_media-type": "application/vnd.ibexa.api.isDiscountCodeAware+json", | ||
"isDiscountCodeAware": false | ||
}, | ||
{ | ||
"_media-type": "application/vnd.ibexa.api.Discount+json", | ||
"id": 2, | ||
"identifier": "my_discount", | ||
"name": "Another discount", | ||
"type": "cart", | ||
"label": "another", | ||
"labelDescription": "another label description", | ||
"priority": 10, | ||
"isEnabled": false, | ||
"createdAt": "2025-06-10T11:03:37+00:00", | ||
"updatedAt": "2025-06-10T14:14:06+00:00", | ||
"startDate": "2025-04-01T12:12:12+00:00", | ||
"DiscountExpressionAware": { | ||
"_media-type": "application/vnd.ibexa.api.DiscountExpressionAware+json", | ||
"expressionValues": { | ||
"discount_percentage": "10" | ||
} | ||
}, | ||
"DiscountConditions": [ | ||
{ | ||
"_media-type": "application/vnd.ibexa.api.DiscountExpressionAware+json", | ||
"expressionValues": { | ||
"discount_code": "my_secret_code", | ||
"usage_count": 1 | ||
} | ||
}, | ||
{ | ||
"_media-type": "application/vnd.ibexa.api.DiscountExpressionAware+json", | ||
"expressionValues": { | ||
"categories": [ | ||
1, | ||
3 | ||
] | ||
} | ||
} | ||
], | ||
"DiscountTranslations": [ | ||
{ | ||
"_media-type": "application/vnd.ibexa.api.DiscountTranslation+json", | ||
"languageCode": {}, | ||
"name": "Another discount", | ||
"description": "another great discount", | ||
"label": "another", | ||
"labelDescription": "another label description" | ||
} | ||
] | ||
}, | ||
{ | ||
"_media-type": "application/vnd.ibexa.api.isDiscountCodeAware+json", | ||
"isDiscountCodeAware": true | ||
} | ||
] | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...api/rest_api/rest_api_reference/input/examples/discounts/POST/DiscountCreate.json.example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"DiscountCreate": { | ||
"identifier": "my_discount", | ||
"type": "cart", | ||
"priority": 10, | ||
"isEnabled": true, | ||
"userId": 14, | ||
"rule": { | ||
"type": "percentage", | ||
"amount": 10 | ||
}, | ||
"startDate": "2025-04-01 12:12:12", | ||
"translations": [ | ||
{ | ||
"languageCode": "eng-GB", | ||
"name": "Another discount", | ||
"description": "another great discount", | ||
"label": "another", | ||
"labelDescription": "another label description" | ||
} | ||
], | ||
"conditions": [ | ||
{ | ||
"class": "Ibexa\\Discounts\\Value\\DiscountCondition\\IsInCategory", | ||
"parameters": [["1", "2"]] | ||
} | ||
] | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
..._api/rest_api_reference/input/examples/discounts/POST/DiscountCreateResponse.json.example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{ | ||
"Discount": { | ||
"_media-type": "application/vnd.ibexa.api.Discount+json", | ||
"id": 2, | ||
"identifier": "my_discount", | ||
"name": "Another discount", | ||
"type": "cart", | ||
"label": "another", | ||
"labelDescription": "another label description", | ||
"priority": 10, | ||
"isEnabled": true, | ||
"createdAt": "2025-06-10T11:03:37+00:00", | ||
"updatedAt": "2025-06-10T11:03:37+00:00", | ||
"startDate": "2025-04-01T12:12:12+00:00", | ||
"DiscountExpressionAware": { | ||
"_media-type": "application/vnd.ibexa.api.DiscountExpressionAware+json", | ||
"expressionValues": { | ||
"discount_percentage": "10" | ||
} | ||
}, | ||
"DiscountConditions": [ | ||
{ | ||
"_media-type": "application/vnd.ibexa.api.DiscountExpressionAware+json", | ||
"expressionValues": { | ||
"categories": [ | ||
"1", | ||
"2" | ||
] | ||
} | ||
} | ||
], | ||
"DiscountTranslations": [ | ||
{ | ||
"_media-type": "application/vnd.ibexa.api.DiscountTranslation+json", | ||
"languageCode": {}, | ||
"name": "Another discount", | ||
"description": "another great discount", | ||
"label": "another", | ||
"labelDescription": "another label description" | ||
} | ||
] | ||
}, | ||
"isDiscountCodeAware": { | ||
"_media-type": "application/vnd.ibexa.api.isDiscountCodeAware+json", | ||
"isDiscountCodeAware": false | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
.../rest_api_reference/input/examples/discounts/identifier/PATCH/DiscountUpdate.json.example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"DiscountUpdate": { | ||
"identifier": "my_discount", | ||
"conditions": [ | ||
{ | ||
"class": "Ibexa\\Discounts\\Value\\DiscountCondition\\IsInCategory", | ||
"parameters": [["1", "3"]] | ||
} | ||
] | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...i_reference/input/examples/discounts/identifier/PATCH/DiscountUpdateResponse.json.example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{ | ||
"Discount": { | ||
"_media-type": "application/vnd.ibexa.api.Discount+json", | ||
"id": 2, | ||
"identifier": "my_discount", | ||
"name": "Another discount", | ||
"type": "cart", | ||
"label": "another", | ||
"labelDescription": "another label description", | ||
"priority": 10, | ||
"isEnabled": false, | ||
"createdAt": "2025-06-10T11:03:37+00:00", | ||
"updatedAt": "2025-06-10T13:05:56+00:00", | ||
"startDate": "2025-04-01T12:12:12+00:00", | ||
"DiscountExpressionAware": { | ||
"_media-type": "application/vnd.ibexa.api.DiscountExpressionAware+json", | ||
"expressionValues": { | ||
"discount_percentage": "10" | ||
} | ||
}, | ||
"DiscountConditions": [ | ||
{ | ||
"_media-type": "application/vnd.ibexa.api.DiscountExpressionAware+json", | ||
"expressionValues": { | ||
"categories": [ | ||
"1", | ||
"3" | ||
] | ||
} | ||
} | ||
], | ||
"DiscountTranslations": [ | ||
{ | ||
"_media-type": "application/vnd.ibexa.api.DiscountTranslation+json", | ||
"languageCode": {}, | ||
"name": "Another discount", | ||
"description": "another great discount", | ||
"label": "another", | ||
"labelDescription": "another label description" | ||
} | ||
] | ||
}, | ||
"isDiscountCodeAware": { | ||
"_media-type": "application/vnd.ibexa.api.isDiscountCodeAware+json", | ||
"isDiscountCodeAware": false | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
docs/api/rest_api/rest_api_reference/input/ibexa-discounts-codes.raml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
displayName: Discount Codes | ||
/{cartIdentifier}: | ||
/apply: | ||
post: | ||
displayName: Apply discount to cart | ||
description: Applies a discount associated with given discount code | ||
headers: | ||
Accept: | ||
description: Specifies the expected response type. Only JSON is supported. | ||
example: | | ||
application/vnd.ibexa.api.DiscountCode+json | ||
Content-Type: | ||
description: Specifies the input type. | ||
example: | | ||
application/vnd.ibexa.api.DiscountCode+json | ||
body: | ||
application/vnd.ibexa.api.DiscountCode+json: | ||
type: DiscountCode | ||
example: !include examples/discount_codes/apply/POST/DiscountCode.json.example | ||
responses: | ||
200: | ||
description: Discount applied successfully | ||
body: | ||
application/vnd.ibexa.api.DiscountCode+json: | ||
type: DiscountCode | ||
example: !include examples/discount_codes/apply/POST/DiscountCodeResponse.json.example | ||
400: | ||
description: Error - the request is invalid. | ||
404: | ||
description: Error - the given cart identifier was not found, or the discount code does not exist. | ||
429: | ||
description: Error - the request was throttled due to too many requests in a short time. | ||
|
||
/drop: | ||
post: | ||
displayName: Remove discount from cart | ||
description: Removes the discount associated with given discount code from the cart | ||
headers: | ||
Accept: | ||
description: Specifies the expected response type. Only JSON is supported. | ||
example: | | ||
application/vnd.ibexa.api.DiscountCode+json | ||
Content-Type: | ||
description: Specifies the input type. Only JSON is supported. | ||
example: | | ||
application/vnd.ibexa.api.DiscountCode+json | ||
body: | ||
application/vnd.ibexa.api.DiscountCode+json: | ||
type: DiscountCode | ||
example: !include examples/discount_codes/apply/POST/DiscountCode.json.example | ||
responses: | ||
204: | ||
description: Discount code with given discount code was removed from the cart. | ||
400: | ||
description: Error - the request is invalid. | ||
404: | ||
description: Error - the given cart identifier was not found |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.