Automatically mark new orders as ready for pickup
Automatically mark pickup items in new orders as ready for pickup at your configured locations. Ideal for stores that always have these items in stock and want to speed up the pickup process.
Try this taskWhen it runs
Occurs whenever an order is created
What you choose
Pickup locations
Documentation
Automatically mark pickup items in new orders as ready for pickup at your configured locations. Ideal for stores that always have these items in stock and want to speed up the pickup process.
Enter the exact names of your pickup locations in the task options. For orders containing both shipping and pickup, the task only marks pickup items as ready. It works with both existing shipping settings and market-driven shipping.
This task uses Shopify's fulfillmentOrderLineItemsPreparedForPickup mutation.
Task code and subscriptions
You can edit the Liquid code after installing this task. View on GitHub or ask a question in the Mechanic Slack community.
Subscriptions
shopify/orders/create
How task subscriptions work
Option types and flags
- Pickup locations (array, required)
Task code
{% assign pickup_locations = options.pickup_locations__array_required %}
{% assign order_id = order.admin_graphql_api_id %}
{% assign fulfillment_orders = array %}
{% assign cursor = nil %}
{% assign fulfillment_orders_loaded = false %}
{% if event.preview %}
{% assign order_id = "gid://shopify/Order/1234567890" %}
{% endif %}
{% for n in (1..100) %}
{% capture query %}
query {
order(id: {{ order_id | json }}) {
fulfillmentOrders(first: 100, after: {{ cursor | json }}) {
nodes {
id
assignedLocation {
name
}
deliveryMethod {
methodType
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
}
{% endcapture %}
{% assign result = query | shopify %}
{% if event.preview %}
{% capture result_json %}
{
"data": {
"order": {
"fulfillmentOrders": {
"nodes": [
{
"id": "gid://shopify/FulfillmentOrder/1",
"assignedLocation": {
"name": {{ pickup_locations.first | json }}
},
"deliveryMethod": {
"methodType": "PICK_UP"
}
},
{
"id": "gid://shopify/FulfillmentOrder/2",
"assignedLocation": {
"name": {{ pickup_locations.first | json }}
},
"deliveryMethod": {
"methodType": "SHIPPING"
}
},
{
"id": "gid://shopify/FulfillmentOrder/3",
"assignedLocation": {
"name": "Third Party Service"
},
"deliveryMethod": {
"methodType": "PICK_UP"
}
}
],
"pageInfo": {
"hasNextPage": false,
"endCursor": null
}
}
}
}
}
{% endcapture %}
{% assign result = result_json | parse_json %}
{% endif %}
{% assign connection = result.data.order.fulfillmentOrders %}
{% if result.errors != blank or connection == nil %}
{% error "Unable to load fulfillment orders. No items were marked ready for pickup." %}
{% break %}
{% endif %}
{% assign fulfillment_orders = fulfillment_orders | concat: connection.nodes %}
{% unless connection.pageInfo.hasNextPage %}
{% assign fulfillment_orders_loaded = true %}
{% break %}
{% endunless %}
{% assign next_cursor = connection.pageInfo.endCursor %}
{% if next_cursor == blank or next_cursor == cursor %}
{% error "Fulfillment order pagination did not advance. No items were marked ready for pickup." %}
{% break %}
{% endif %}
{% if forloop.last %}
{% error "Fulfillment order pagination limit reached. No items were marked ready for pickup." %}
{% break %}
{% endif %}
{% assign cursor = next_cursor %}
{% endfor %}
{% unless fulfillment_orders_loaded %}
{% break %}
{% endunless %}
{% comment %} A location can handle shipping and pickup for the same order. {% endcomment %}
{% for fulfillment_order in fulfillment_orders %}
{% unless fulfillment_order.deliveryMethod.methodType == "PICK_UP" %}
{% continue %}
{% endunless %}
{% unless pickup_locations contains fulfillment_order.assignedLocation.name %}
{% continue %}
{% endunless %}
{% action "shopify" %}
mutation {
fulfillmentOrderLineItemsPreparedForPickup(
input: {
lineItemsByFulfillmentOrder: [
{
fulfillmentOrderId: {{ fulfillment_order.id | json }}
}
]
}
) {
userErrors {
field
message
}
}
}
{% endaction %}
{% endfor %}
Mechanic Liquid reference
Default option values
- Pickup locations
["Your location name here"]