-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add the purchase option extensions template #142
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We actually shouldn't merge this until the targets are in GA
Yes, we have an epic with what need to be shipped first. |
"dependencies": { | ||
"react": "^18.0.0", | ||
"@shopify/ui-extensions": "unstable", | ||
"@shopify/ui-extensions-react": "unstable" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should be pointing to the latest stable calver (10-24) not to unstable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks~ Will change.
extend(PRODUCT_TARGET, (root, {i18n, close, data}) => { | ||
PurchaseOptionsAction(root, {i18n, close, data}); | ||
}); | ||
|
||
extend(PRODUCT_VARIANT_TARGET, (root, {i18n, close, data}) => { | ||
PurchaseOptionsAction(root, {i18n, close, data}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should be extension
instead of extend
(many of the other templates are wrong and will be updated soon)
Also the export default
and separate file comment applies here too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for giving all these insight, I changed the templates :)
reactExtension(PRODUCT_TARGET, () => ( | ||
<AdminSubsAction extension={PRODUCT_TARGET} /> | ||
)); | ||
|
||
reactExtension(PRODUCT_VARIANT_TARGET, () => ( | ||
<AdminSubsAction extension={PRODUCT_VARIANT_TARGET} /> | ||
)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am checking on this but I think We need two separate files, each with an export default reactExtension...
. They can both import and share a third file with the actual component if you like.
Why -- because we have a future change to our build system that uses the default export from the source files to create named exports in the build files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed the templates, thanks for catching it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
"license": "UNLICENSED", | ||
"dependencies": { | ||
"react": "^18.0.0", | ||
"@shopify/ui-extensions": "2024.10.x", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this has to be set to unstable
as the new targets weren't part of the 2024-10
release
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, good catch
import {reactExtension} from '@shopify/ui-extensions-react/admin'; | ||
import PurchaseOptionsActionExtension from './PurchaseOptionsActionExtension'; | ||
|
||
reactExtension('admin.product-purchase-option.action.render', () => ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reactExtension('admin.product-purchase-option.action.render', () => ( | |
export default reactExtension('admin.product-purchase-option.action.render', () => ( |
import {extension} from '@shopify/ui-extensions/admin'; | ||
import PurchaseOptionsActionExtension from './PurchaseOptionsActionExtension'; | ||
|
||
extension( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extension( | |
export default extension( |
import {reactExtension} from '@shopify/ui-extensions-react/admin'; | ||
import PurchaseOptionsActionExtension from './PurchaseOptionsActionExtension'; | ||
|
||
reactExtension('admin.product-variant-purchase-option.action.render', () => ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reactExtension('admin.product-variant-purchase-option.action.render', () => ( | |
export default reactExtension('admin.product-variant-purchase-option.action.render', () => ( |
import {extension} from '@shopify/ui-extensions/admin'; | ||
import PurchaseOptionsActionExtension from './PurchaseOptionsActionExtension'; | ||
|
||
extension( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extension( | |
export default extension( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a nit / question, but otherwise LGTM
}; | ||
|
||
function handleSave() { | ||
// This is where you can use the sellingPlanGroupsCreate and sellingPlanGroupsUpdate mutations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will running this for products or variants change how a dev would call these mutations? If so, should we have an example of how to tell which one we're rendering?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the sellingPlanGroupsUpdate
mutation doesn't need to know about product vs variant. You make a good point that this example isn't enough though. We'd need to actually call the mutations for adding variants and products correctly and those are different. Could we add a complete example @JulienHe ?
I wrote some pseudo code here where the extension passes in the right mutation to use.
Background
The selling strategies is introducing 2 new admin action:
admin.product-purchase-option.action.render
admin.product-variant-purchase-option.action.render
We are shipping a new template so apps partners can use it and have a first starter when they want to work with these new extensions
Solution
We are adding the new extensions to the available templates.
Checklist