Skip to content

PROMO-1050 Add shipping discount action #358

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

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 43 additions & 10 deletions reference/promotions.v3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ paths:
get:
tags:
- Promotions (Bulk)
summary: Get All Promotions
summary: Get All Promotions
description: |-
Returns a list of *promotions*.

Expand Down Expand Up @@ -120,7 +120,7 @@ paths:
get:
tags:
- Promotions (Single)
summary: Get Promotion
summary: Get Promotion
description: |-
Returns a single *promotion*.

Expand Down Expand Up @@ -170,7 +170,7 @@ paths:
delete:
tags:
- Promotions (Single)
summary: Delete Promotion
summary: Delete Promotion
description: |-
Deletes a promotion.

Expand All @@ -189,7 +189,7 @@ paths:
get:
tags:
- Coupon Codes (Bulk)
summary: Get Coupon Codes
summary: Get Coupon Codes
description: |-
Get codes for a particular promotion.

Expand All @@ -204,7 +204,7 @@ paths:
post:
tags:
- Coupon Codes (Single)
summary: Create A Coupon Code
summary: Create A Coupon Code
description: |-
Create a new code for the promotion.

Expand Down Expand Up @@ -242,7 +242,7 @@ paths:
delete:
tags:
- Coupon Codes (Bulk)
summary: Delete Multiple Coupon Codes
summary: Delete Multiple Coupon Codes
description: |-
Deletes multiple coupon codes relating to the given promotion. Currently, batches are limited to 50 coupon codes.

Expand Down Expand Up @@ -819,6 +819,39 @@ components:
minimum: 1
required:
- zone_ids
ShippingDiscountAction:
title: Shipping Discount Action
type: object
description: |-
**Shipping Discount Action**
Discounts shipping, optionally restricted to specific shipping methods.
properties:
shipping_discount:
type: object
properties:
discount:
$ref: '#/components/schemas/Discount'
as_total:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't notice this during initial UX review.

I'm wondering if this can be omitted to "per destination" for the 1st iteration ? distribute as a total amount is definitely doable engineering wise, but from past experience, it's also a source of rounding bugs, so we only want to take on the additional complexity when we're sure that the demand is there.

Probably worth asking JW to confirm if this is required for WD, if not, we can reduce the scope a bit.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed! Let's see if we can limit it to per desitination then expand with this later if needed.

type: boolean
description: |-
Set this value to true to distribute the discount as a total among shipping destinations. By default, the discount applies to each destination.
Example: If set to false, the discount is $10 and you have 2 shipping destinations eligible for this discount, the shipping cost for both destinations will be discounted by $10, with a total of $20 off the order.
If set to true, $10 will be distributed among the 2 shipping destinations, weighted by their respective price. In a case where there are 2 destinations sharing the same cost, each will be discounted by $5.
method_ids:
description: ''
oneOf:
- type: string
enum:
- '*'
description: All configured shipping methods.
- type: array
uniqueItems: true
description: List of shipping method IDs to which the shipping discount can apply.
items:
type: integer
minimum: 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to enforce some sort of sanity check maximum? Just so we don't inevitably have merchants finding creative ways to abuse this and potentially listing hundreds of shipping methods? We can always increase the limit if discover a legit use case

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely!

required:
- method_ids
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

discount is probably required as well 😄

Discount:
title: Discount
description: '**Discount**'
Expand Down Expand Up @@ -928,9 +961,9 @@ components:
type: array
description: Specifies where the notification message will be displayed.
example:
- HOME_PAGE
- PRODUCT_PAGE
- CART_PAGE
- HOME_PAGE
- PRODUCT_PAGE
- CART_PAGE
- CHECKOUT_PAGE
items:
type: string
Expand Down Expand Up @@ -1338,7 +1371,7 @@ components:
success: 0
failed: 0
422 - Error Deleting:
example:
example:
errors:
- status: 422
title: Errors occurred in bulk delete action.
Expand Down
Loading