Generate pickup points
The Pickup Points Delivery Option Generator API is a feature that's available by request to merchants on the Shopify Plus plan. Merchants must be enrolled in the Partner program in order to deploy custom solutions they have developed for themselves. To request access, contact pickup-point-generator-early-access@shopify.com. You can test the Pickup Points Delivery Option Generator API on Partner development stores without requesting access.
Customers can choose to have their order sent to a pickup point instead of to their address.
In this guide, you'll learn how to generate custom pickup point options using Shopify Functions. You'll create a starter function with some logic to support pickup points for a specific location. You'll also learn how to retrieve the pickup point that the customer selected, using the GraphQL Admin API.
Explore an end-to-end example, and consult the Pickup Point Delivery Option Generator API reference.
Anchor to What you'll learnWhat you'll learn
In this tutorial, you'll learn how to do the following tasks:
- Generate starter code for Shopify Functions
- Use GraphQL to define the input of your function
- Test the delivery option generator and review function logs
- Retrieve the selected pickup point for an order, using the GraphQL Admin API
- Deploy your function to the Shopify platform.
Anchor to RequirementsRequirements
Only custom apps that are built for stores on the Shopify Plus plan have access to the Pickup Point Delivery Option Generator API. Public apps in the Shopify App Store and custom apps built for stores on non-Plus plans don't have access.
- You've created a Partner account.
- You've created a development store.
- You've created an app that uses Shopify CLI 3.49.5 or higher. If you previously installed Shopify CLI, then make sure that you're using the latest version.
- You've installed Node.js 16 or higher.
- You've installed your app on the development store.
Anchor to Rust-specific requirementsRust-specific requirements
The following requirements are specific to Rust-based development with Shopify Functions.
-
You've installed Rust.
On Windows, Rust requires the Microsoft C++ Build Tools. Make sure to select the Desktop development with C++ workload when installing the tools.
-
You've installed the
wasm32-wasip1
target:Terminal
rustup target add wasm32-wasip1
Anchor to Step 1: Create the pickup point delivery option generator functionStep 1: Create the pickup point delivery option generator function
Use Shopify CLI to generate a pickup point delivery option generator starter function. Shopify CLI generates the function, specifies the function's inputs using an input query, and implements the function logic. Learn more about the function that's generated.
-
Navigate to your app directory:
Terminal
cd <directory> -
Create a new pickup point delivery option generator extension with the following command:
Terminal
shopify app generate extension --template pickup_point_delivery_option_generator --name pickup-points-generator -
Choose the language to use. For this tutorial, you should select either Rust or JavaScript.
For handling large data payloads, consider using Rust, as it may help avoid exceeding Shopify's instruction limit, potentially preventing an InstructionCountLimitExceededError.
TipShopify Functions support any language that compiles to WebAssembly (Wasm), such as Rust, AssemblyScript, or TinyGo. You specify the Wasm template option when you're using a language other than Rust and can conform to the Wasm API. Learn more about the Wasm API.
-
Navigate to
extensions/pickup-points-generator
:Terminal
cd extensions/pickup-points-generator
Anchor to Step 2: Preview the function on a development storeStep 2: Preview the function on a development store
To test your function, you need to make it available to your development store.
- If you're developing a function in a language other than JavaScript or TypeScript, ensure you have configured
build.watch
in your function extension configuration.
-
Navigate back to your app root:
Terminal
cd ../..
-
Use the Shopify CLI
dev
command to start app preview:Terminal
shopify app devYou can keep the preview running as you work on your function. When you make changes to a watched file, Shopify CLI rebuilds your function and updates the function extension's drafts, so you can immediately test your changes.
-
Follow the CLI prompts to preview your app, and install it on your development store.
If your app is already running, then you need to stop and restart it.
Anchor to Step 3: Set up shipping to pickup pointsStep 3: Set up shipping to pickup points
For pickup points to be available at checkout, your store needs to have at least one location with pickup points enabled.
- In the Shopify admin, go to Settings > Shipping and delivery.
- Under Shipping to pickup points, select a location.
- Enable the option to ship to pickup points from the location.
- Click Edit rate.
- Under Apply rate to pickup points provided by, select your extension.
- Click Done.
- Click Save.
Anchor to Step 4: Test the pickup point delivery option generatorStep 4: Test the pickup point delivery option generator
You can test your pickup point delivery option generator to ensure that it's working as expected.
-
In your development store, add a product to your cart and proceed to checkout.
The product must be available from the configured location.
-
In checkout, select Ship to pickup point.
-
Type an address in Canada, and click Search. If you're in Canada, then you can use your location.
-
To view available pickup points, select either Map or List.
-
Select a location.
-
Click Continue to payment.
The Payment page displays the address that you selected.
Anchor to Step 5 (Optional): Debug the functionStep 5 (Optional): Debug the function
To debug your function, or view its output, you can review its logs.
- Log in to your Partner Dashboard.
- Navigate to Apps and select your app.
- Click Extensions > pickup-points-generator.
- Click on any function run to view its input, output, and any logs written to
STDERR
.
Anchor to Step 6: Retrieve the pickup point from an orderStep 6: Retrieve the pickup point from an order
You can retrieve a pickup point from an order with the GraphQL Admin API.
To query the pickup point, you need to request access to protected customer data in the Partner Dashboard. Your app also needs to meet specific requirements to ensure customer privacy and security.
Anchor to Set access scopesSet access scopes
Add the read_orders
and read_merchant_managed_fulfillment_orders
access scopes to your app.
-
If your app is running, stop it.
-
In
shopify.app.toml
, updatescopes
to include the required access scopes. The following is an example:shopify.app.toml
scopes = "read_products,read_merchant_managed_fulfillment_orders,read_orders" -
Deploy your changes with the following command:
Terminal
shopify app deploy -
When prompted, release the new version.
-
Restart your server for the changes to take effect:
Terminal
shopify app dev
Anchor to Retrieve the pickup pointRetrieve the pickup point
Request the pickup point from the GraphQL Admin API's DeliveryMethod
object. You'll request data from the deliveryOptionGeneratorPickupPoint
field.
-
Complete the order that you started.
-
In Shopify CLI, where your server is running, press
g
to open GraphiQL in your browser. -
In GraphiQL, run the following query, with the ID of the order that you created.
This example returns the IDs of the pickup point and the function that generated the pickup point option.
POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
GraphQL query
query {order(id: "gid://shopify/Order/{ORDER_ID}") {idfulfillmentOrders(first: 10, displayable: true) {edges {node {deliveryMethod {methodTypedeliveryOptionGeneratorPickupPoint {externalIdfunctionId}}}}}}}JSON response
{"data": {"order": {"id": "gid://shopify/Order/1","fulfillmentOrders": {"edges": [{"node": {"deliveryMethod": {"methodType": "PICKUP_POINT","deliveryOptionGeneratorPickupPoint": {"externalId": "1","functionId": "f0c17828-da1a-4748-810d-3c3cab2bc977"}}}}]}}}}
Anchor to Step 7 (Optional): Edit the selected pickup pointStep 7 (Optional): Edit the selected pickup point
You can edit the selected pickup point option, either on the order or on the fulfillment page for a pickup order that's completed using pickup points functions.
-
In the Shopify admin, go to Orders page.
-
Next to Pickup point address, click the pencil icon.
In the modal that displays, edit the pickup point address.
-
After you've edited the address, click Search.
Installed pickup points functions will run and a list of pickup points will be returned.
-
Select a new pickup point delivery option.
-
Click Done.
To edit the selected pickup point option on the fulfillment page, fulfill the order and repeat the steps above.
Anchor to Next stepsNext steps
- Review the UX guidelines for pickup points, to seamlessly integrate your app into the checkout experience.
- Learn more about how Shopify Functions work and the benefits of using Shopify Functions.
- Learn how to use variables in your input query.
- Review the developer tools and resources to build for pickup points, including the Pickup Point Delivery Option Generator API reference.