Skip to content
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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
8 changes: 8 additions & 0 deletions admin-purchase-options-action/README.md.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Admin purchase options extension

Purchase options extensions allow developers to integrate custom functionality into the Shopify Admin interface,
enabling merchants to create and edit purchase options directly on product and product variant pages. These extensions
provide interactive elements that enhance the merchant's ability to manage purchase options efficiently.

Learn more about Admin action extensions in Shopify’s [developer
documentation](https://shopify.dev/docs/apps/admin/admin-actions-and-blocks).
4 changes: 4 additions & 0 deletions admin-purchase-options-action/locales/en.default.json.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "{{ name }}",
"welcome": "Welcome to the {% raw %}{{TARGET}}{% endraw %} extension!"
}
4 changes: 4 additions & 0 deletions admin-purchase-options-action/locales/fr.json.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "{{ name }}",
"welcome": "Bienvenue dans l'extension {% raw %}{{TARGET}}{% endraw %}!"
}
27 changes: 27 additions & 0 deletions admin-purchase-options-action/package.json.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{%- if flavor contains "react" -%}
{
"name": "{{ handle }}",
"private": true,
"version": "1.0.0",
"license": "UNLICENSED",
"dependencies": {
"react": "^18.0.0",
"@shopify/ui-extensions": "unstable",
"@shopify/ui-extensions-react": "unstable"
Copy link
Contributor

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

Copy link
Author

Choose a reason for hiding this comment

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

Thanks~ Will change.

},
"devDependencies": {
"@types/react": "^18.0.0",
"react-reconciler": "0.29.0"
}
}
{%- else -%}
{
"name": "{{ handle }}",
"private": true,
"version": "1.0.0",
"license": "UNLICENSED",
"dependencies": {
"@shopify/ui-extensions": "unstable"
}
}
{%- endif -%}
27 changes: 27 additions & 0 deletions admin-purchase-options-action/shopify.extension.toml.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
api_version = "unstable"

[[extensions]]
# Change the merchant-facing name of the extension in locales/en.default.json
name = "t:name"
handle = "{{ handle }}"
type = "ui_extension"
{% if uid %}uid = "{{ uid }}"{% endif %}

# Both targets need to be specified for the extensions to work
[[extensions.targeting]]
module = "./src/ProductExtension.{{ srcFileExtension }}"
# The target used here must match the target used in the module file (./src/PurchaseOptionsActionExtension.{{ srcFileExtension }})
target = "admin.product-purchase-option.action.render"

[[extensions.targeting]]
module = "./src/ProductVariantExtension.{{ srcFileExtension }}"
# The target used here must match the target used in the module file (./src/PurchaseOptionsActionExtension.{{ srcFileExtension }})
target = "admin.product-variant-purchase-option.action.render"

# Valid extension targets:

# Product index and detail pages
# - admin.product-purchase-option.action.render

# Product variant detail pages
# - admin.product-variant-purchase-option.action.render
28 changes: 28 additions & 0 deletions admin-purchase-options-action/src/ProductExtension.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{%- if flavor contains "react" -%}
import {reactExtension} from '@shopify/ui-extensions-react/admin';
import PurchaseOptionsActionExtension from './PurchaseOptionsActionExtension';

export default reactExtension('admin.product-purchase-option.action.render', () => (
<PurchaseOptionsActionExtension extension="admin.product-purchase-option.action.render" />
));

{%- else -%}
import {extension} from '@shopify/ui-extensions/admin';
import PurchaseOptionsActionExtension from './PurchaseOptionsActionExtension';

export default extension(
'admin.product-purchase-option.action.render',
(root, {i18n, close, data}) => {
PurchaseOptionsActionExtension(
'admin.product-purchase-option.action.render',
root,
{
i18n,
close,
data,
},
);
},
);

{%- endif -%}
28 changes: 28 additions & 0 deletions admin-purchase-options-action/src/ProductVariantExtension.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{%- if flavor contains "react" -%}
import {reactExtension} from '@shopify/ui-extensions-react/admin';
import PurchaseOptionsActionExtension from './PurchaseOptionsActionExtension';

export default reactExtension('admin.product-variant-purchase-option.action.render', () => (
<PurchaseOptionsActionExtension extension="admin.product-variant-purchase-option.action.render" />
));

{%- else -%}
import {extension} from '@shopify/ui-extensions/admin';
import PurchaseOptionsActionExtension from './PurchaseOptionsActionExtension';

export default extension(
'admin.product-variant-purchase-option.action.render',
(root, {i18n, close, data}) => {
PurchaseOptionsActionExtension(
'admin.product-variant-purchase-option.action.render',
root,
{
i18n,
close,
data,
},
);
},
);

{%- endif -%}
Loading