-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aa7b3db
commit 33d6b99
Showing
9 changed files
with
118 additions
and
86 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
...javascript/local-pickup-delivery-option-generators/default/locales/en.default.json.liquid
This file contains 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,4 @@ | ||
{ | ||
"name": "{{name}}", | ||
"description": "{{name}}" | ||
} |
This file contains 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
24 changes: 18 additions & 6 deletions
24
.../javascript/local-pickup-delivery-option-generators/default/shopify.extension.toml.liquid
This file contains 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 |
---|---|---|
@@ -1,8 +1,20 @@ | ||
name = "{{name}}" | ||
type = "local_pickup_delivery_option_generator" | ||
{% if uid %}uid = "{{ uid }}"{% endif %} | ||
api_version = "unstable" | ||
|
||
[build] | ||
command = "" | ||
path = "dist/function.wasm" | ||
[[extensions]] | ||
name = "t:name" | ||
handle = "{{handle}}" | ||
type = "function" | ||
{% if uid %}uid = "{{ uid }}"{% endif %} | ||
|
||
[[extensions.targeting]] | ||
target = "purchase.local-pickup-delivery-option-generator.run" | ||
input_query = "src/run.graphql" | ||
export = "run" | ||
|
||
[extensions.build] | ||
command = "" | ||
path = "dist/function.wasm" | ||
|
||
[extensions.ui.paths] | ||
create = "/" | ||
details = "/" |
68 changes: 1 addition & 67 deletions
68
order-routing/javascript/local-pickup-delivery-option-generators/default/src/index.liquid
This file contains 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 |
---|---|---|
@@ -1,67 +1 @@ | ||
{%- if flavor contains "vanilla-js" -%} | ||
// @ts-check | ||
|
||
/** | ||
* @typedef {import("../generated/api").InputQuery} InputQuery | ||
* @typedef {import("../generated/api").FunctionResult} FunctionResult | ||
*/ | ||
|
||
/** | ||
* @type {FunctionResult} | ||
*/ | ||
const DELIVERY_OPTION = { | ||
operations: [ | ||
{ | ||
add: { | ||
title: "Main St.", | ||
cost: 1.99, | ||
pickupLocation: { | ||
locationHandle: "2578303", | ||
pickupInstruction: "Usually ready in 24 hours." | ||
} | ||
} | ||
} | ||
], | ||
}; | ||
|
||
export default /** | ||
* @param {InputQuery} input | ||
* @returns {FunctionResult} | ||
*/ | ||
(input) => { | ||
const configuration = JSON.parse( | ||
input?.deliveryOptionGenerator?.metafield?.value ?? "{}" | ||
); | ||
|
||
return DELIVERY_OPTION; | ||
}; | ||
{%- elsif flavor contains "typescript" -%} | ||
import { | ||
InputQuery, | ||
FunctionResult, | ||
} from "../generated/api"; | ||
|
||
const DELIVERY_OPTION: FunctionResult = { | ||
operations: [ | ||
{ | ||
add: { | ||
title: "Main St.", | ||
cost: 1.99, | ||
pickupLocation: { | ||
locationHandle: "2578303", | ||
pickupInstruction: "Usually ready in 24 hours." | ||
} | ||
} | ||
} | ||
], | ||
}; | ||
|
||
type Configuration = {}; | ||
|
||
export default (input: InputQuery): FunctionResult => { | ||
const configuration: Configuration = JSON.parse( | ||
input?.deliveryOptionGenerator?.metafield?.value ?? "{}" | ||
); | ||
return DELIVERY_OPTION; | ||
}; | ||
{%- endif -%} | ||
export * from './run'; |
2 changes: 1 addition & 1 deletion
2
...n-generators/default/input.graphql.liquid → ...generators/default/src/run.graphql.liquid
This file contains 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
query Input { | ||
query RunInput { | ||
cart { | ||
lines { | ||
id | ||
|
67 changes: 67 additions & 0 deletions
67
order-routing/javascript/local-pickup-delivery-option-generators/default/src/run.liquid
This file contains 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,67 @@ | ||
{%- if flavor contains "vanilla-js" -%} | ||
// @ts-check | ||
|
||
/** | ||
* @typedef {import("../generated/api").InputQuery} InputQuery | ||
* @typedef {import("../generated/api").FunctionResult} FunctionResult | ||
*/ | ||
|
||
/** | ||
* @type {FunctionResult} | ||
*/ | ||
const DELIVERY_OPTION = { | ||
operations: [ | ||
{ | ||
add: { | ||
title: "Main St.", | ||
cost: 1.99, | ||
pickupLocation: { | ||
locationHandle: "2578303", | ||
pickupInstruction: "Usually ready in 24 hours." | ||
} | ||
} | ||
} | ||
], | ||
}; | ||
|
||
export default /** | ||
* @param {InputQuery} input | ||
* @returns {FunctionResult} | ||
*/ | ||
(input) => { | ||
const configuration = JSON.parse( | ||
input?.deliveryOptionGenerator?.metafield?.value ?? "{}" | ||
); | ||
|
||
return DELIVERY_OPTION; | ||
}; | ||
{%- elsif flavor contains "typescript" -%} | ||
import { | ||
InputQuery, | ||
FunctionResult, | ||
} from "../generated/api"; | ||
|
||
const DELIVERY_OPTION: FunctionResult = { | ||
operations: [ | ||
{ | ||
add: { | ||
title: "Main St.", | ||
cost: 1.99, | ||
pickupLocation: { | ||
locationHandle: "2578303", | ||
pickupInstruction: "Usually ready in 24 hours." | ||
} | ||
} | ||
} | ||
], | ||
}; | ||
|
||
type Configuration = {}; | ||
|
||
export default (input: InputQuery): FunctionResult => { | ||
const configuration: Configuration = JSON.parse( | ||
input?.deliveryOptionGenerator?.metafield?.value ?? "{}" | ||
); | ||
return DELIVERY_OPTION; | ||
}; | ||
{%- endif -%} |
2 changes: 1 addition & 1 deletion
2
...-generators/default/src/index.test.liquid → ...on-generators/default/src/run.test.liquid
This file contains 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
4 changes: 4 additions & 0 deletions
4
...uting/rust/local-pickup-delivery-option-generators/default/locales/en.default.json.liquid
This file contains 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,4 @@ | ||
{ | ||
"name": "{{name}}", | ||
"description": "{{name}}" | ||
} |
28 changes: 18 additions & 10 deletions
28
...outing/rust/local-pickup-delivery-option-generators/default/shopify.extension.toml.liquid
This file contains 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 |
---|---|---|
@@ -1,13 +1,21 @@ | ||
name = "{{name}}" | ||
type = "local_pickup_delivery_option_generator" | ||
{% if uid %}uid = "{{ uid }}"{% endif %} | ||
api_version = "unstable" | ||
|
||
[build] | ||
command = "cargo build --target=wasm32-wasip1 --release" | ||
path = "target/wasm32-wasip1/release/{{name | replace: " ", "-" | downcase}}.wasm" | ||
watch = [ "src/**/*.rs" ] | ||
[[extensions]] | ||
name = "t:name" | ||
handle = "{{handle}}" | ||
type = "function" | ||
{% if uid %}uid = "{{ uid }}"{% endif %} | ||
|
||
[[extensions.targeting]] | ||
target = "purchase.local-pickup-delivery-option-generator.run" | ||
input_query = "src/run.graphql" | ||
export = "run" | ||
|
||
[extensions.build] | ||
command = "cargo build --target=wasm32-wasip1 --release" | ||
path = "target/wasm32-wasip1/release/{{handle | replace: " ", "-" | downcase}}.wasm" | ||
watch = [ "src/**/*.rs" ] | ||
|
||
[ui.paths] | ||
create = "/" | ||
details = "/" | ||
[extensions.ui.paths] | ||
create = "/" | ||
details = "/" |