-
Notifications
You must be signed in to change notification settings - Fork 53
Update API and add observables for discount function settings #3641
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@shopify/ui-extensions': minor | ||
| --- | ||
|
|
||
| Added subscribable discounts api. Update the type for `data.id` to string to fix a previously incorrect type. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,8 @@ | ||
| import type { | ||
| ReadonlySignalLike, | ||
| UpdateSignalFunction, | ||
| } from '../../../../shared'; | ||
|
|
||
| interface Metafield { | ||
| description?: string; | ||
| id: string; | ||
|
|
@@ -7,23 +12,56 @@ interface Metafield { | |
| type: string; | ||
| } | ||
|
|
||
| export enum DiscountClass { | ||
| Product = 'PRODUCT', | ||
| Order = 'ORDER', | ||
| Shipping = 'SHIPPING', | ||
| } | ||
| type DiscountClass = 'product' | 'order' | 'shipping'; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to call this out in the changset as a breaking change. We will also need to ensure backwards compatibility so that only 2026-01 and up will receive the lowercased enum.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to document this as a breaking change? This type was defined but never used. Like the input never referenced that type 🤔 It wasn't flagged as unused in CI because it is exported I assume.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah ok, we've never exposed this in the api, just added the enum so it's ok to not be a breaking change |
||
|
|
||
| type DiscountMethod = 'automatic' | 'code'; | ||
|
|
||
| type PurchaseType = 'one_time_purchase' | 'subscription' | 'both'; | ||
|
|
||
| interface Discount { | ||
| /** | ||
| * The object that exposes the validation with its settings. | ||
| */ | ||
| export interface DiscountFunctionSettingsData { | ||
| /** | ||
| * the discount's gid | ||
| * The unique identifier for the discount. | ||
| */ | ||
| id: string; | ||
| /** | ||
| * The discount metafields. | ||
| */ | ||
| metafields: Metafield[]; | ||
| } | ||
|
|
||
| /** | ||
| * The object that exposes the validation with its settings. | ||
| * Reactive Api for managing discount function configuration. | ||
| */ | ||
| export interface DiscountFunctionSettingsData { | ||
| id: Discount; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was actually wrong in the past. We never sent the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we please patch the previous release too?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It has been wrong for more than one release. I can patch all of them, do I just have to merge the branch to the non-rc one? Like 2025-10, etc. Anything else I need to do? |
||
| metafields: Metafield[]; | ||
| export interface DiscountsApi { | ||
| /** | ||
| * A signal that contains the discount classes. | ||
| */ | ||
| discountClasses: ReadonlySignalLike<DiscountClass[]>; | ||
| /** | ||
| * A function that updates the discount classes. | ||
| */ | ||
| updateDiscountClasses: UpdateSignalFunction<DiscountClass[]>; | ||
| /** | ||
| * A signal that contains the discount method. | ||
| */ | ||
| discountMethod: ReadonlySignalLike<DiscountMethod>; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. discountMethod is readonly. |
||
| /** | ||
| * A signal that contains the purchase type. | ||
| */ | ||
| purchaseType: ReadonlySignalLike<PurchaseType>; | ||
| /** | ||
| * A function that updates the purchase type. | ||
| */ | ||
| updatePurchaseType: UpdateSignalFunction<PurchaseType>; | ||
| /** | ||
| * A signal that contains the recurring cycle limit for subscriptions purchases. | ||
| */ | ||
| recurringCycleLimit: ReadonlySignalLike<number | null | undefined>; | ||
| /** | ||
| * A function that updates the recurring cycle limit for subscriptions purchases. | ||
| */ | ||
| updateRecurringCycleLimit: UpdateSignalFunction<number | null | undefined>; | ||
jonathanhamel4 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.