Mechanic is a development and ecommerce automation platform for Shopify. :)
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.
Runs Occurs whenever an order is created. Configuration includes pickup locations.
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.
Mechanic is designed to benefit everybody: merchants, customers, developers, agencies, Shopifolks, everybody.
That’s why we make it easy to configure automation without code, why we make it easy to tweak the underlying code once tasks are installed, and why we publish it all here for everyone to learn from.
(By the way, have you seen our documentation? Have you joined the Slack community?)
shopify/orders/create
{% 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 %}["Your location name here"]