Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

feat(shopify): let AI agents manage fulfillment, shipping, discounts and gift cards (#16089)

Odai Ahmad26ba3105bce9
diff --git a/bun.lock b/bun.lock
index 33b7576f1e6..db7065c01e2 100644
--- a/bun.lock
+++ b/bun.lock
@@ -8313,7 +8313,7 @@
},
"packages/pieces/community/shopify": {
"name": "@activepieces/piece-shopify",
- "version": "0.6.0",
+ "version": "0.7.0",
"dependencies": {
"@activepieces/core-piece-types": "workspace:*",
"@activepieces/core-utils": "workspace:*",
diff --git a/packages/pieces/community/shopify/package.json b/packages/pieces/community/shopify/package.json
index 7643e7504bc..34b16a8450d 100644
--- a/packages/pieces/community/shopify/package.json
+++ b/packages/pieces/community/shopify/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-shopify",
- "version": "0.6.0",
+ "version": "0.7.0",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"scripts": {
diff --git a/packages/pieces/community/shopify/src/i18n/translation.json b/packages/pieces/community/shopify/src/i18n/translation.json
index 249b277ee60..7a99615a132 100644
--- a/packages/pieces/community/shopify/src/i18n/translation.json
+++ b/packages/pieces/community/shopify/src/i18n/translation.json
@@ -27,9 +27,11 @@
"Update Product": "Update Product",
"Upload Product Image": "Upload Product Image",
"Stock Item at Location": "Stock Item at Location",
+ "Start Adding Discount Redeem Codes": "Start Adding Discount Redeem Codes",
"Add Product Media": "Add Product Media",
"Add Products to Collection": "Add Products to Collection",
"Add Tags": "Add Tags",
+ "List Delivery Zones": "List Delivery Zones",
"Send Payment Method Update Email": "Send Payment Method Update Email",
"Resolve Requested Order Edit": "Resolve Requested Order Edit",
"Decline Requested Order Edit": "Decline Requested Order Edit",
@@ -40,27 +42,42 @@
"Archive Order": "Archive Order",
"Attach Media to Variants": "Attach Media to Variants",
"Calculate Refund": "Calculate Refund",
+ "Cancel Fulfillment Order": "Cancel Fulfillment Order",
+ "Cancel Fulfillment": "Cancel Fulfillment",
"Capture Order Payment": "Capture Order Payment",
"Complete Draft Order": "Complete Draft Order",
"Count Abandoned Checkouts": "Count Abandoned Checkouts",
"Count Collections": "Count Collections",
"Count Customer Segments": "Count Customer Segments",
"Count Customers": "Count Customers",
+ "Count Discount Codes": "Count Discount Codes",
+ "Count Discounts": "Count Discounts",
"Count Draft Orders": "Count Draft Orders",
+ "Count Gift Cards": "Count Gift Cards",
"Count Locations": "Count Locations",
"Count Products": "Count Products",
+ "Create Amount-Off Discount Code": "Create Amount-Off Discount Code",
+ "Create Buy X Get Y Discount Code": "Create Buy X Get Y Discount Code",
"Create Collection": "Create Collection",
"Create Customer Address": "Create Customer Address",
+ "Create Free Shipping Discount Code": "Create Free Shipping Discount Code",
+ "Create Fulfillment Tracking Event": "Create Fulfillment Tracking Event",
+ "Create Fulfillment": "Create Fulfillment",
+ "Create Gift Card": "Create Gift Card",
"Create Order Risk Assessment": "Create Order Risk Assessment",
"Create Product Options": "Create Product Options",
"Create Product Variants": "Create Product Variants",
"Create Refund": "Create Refund",
"Create Smart Collection": "Create Smart Collection",
+ "Deactivate Gift Card": "Deactivate Gift Card",
"Stop Stocking Item at Location": "Stop Stocking Item at Location",
"Delete Collection": "Delete Collection",
"Delete Customer Address": "Delete Customer Address",
"Delete Customer": "Delete Customer",
+ "Start Deleting Discount Redeem Codes": "Start Deleting Discount Redeem Codes",
+ "Delete Discount": "Delete Discount",
"Delete Draft Order": "Delete Draft Order",
+ "Delete Fulfillment Service": "Delete Fulfillment Service",
"Delete Order": "Delete Order",
"Remove Product Media": "Remove Product Media",
"Delete Product Options": "Delete Product Options",
@@ -68,12 +85,18 @@
"Delete Product": "Delete Product",
"Detach Media from Variants": "Detach Media from Variants",
"Duplicate Product": "Duplicate Product",
+ "Find Discount By Code": "Find Discount By Code",
"Generate Customer Activation URL": "Generate Customer Activation URL",
"Get Abandonment": "Get Abandonment",
"Get Checkout Abandonment": "Get Checkout Abandonment",
"Get Collection by Handle": "Get Collection by Handle",
"Get Collection": "Get Collection",
+ "Get Discount Redeem Code Bulk Creation": "Get Discount Redeem Code Bulk Creation",
+ "Get Discount": "Get Discount",
"Get Draft Order": "Get Draft Order",
+ "Get Fulfillment Details": "Get Fulfillment Details",
+ "Get Fulfillment Order": "Get Fulfillment Order",
+ "Get Gift Card": "Get Gift Card",
"Get Granted Access Scopes": "Get Granted Access Scopes",
"Get Inventory Item": "Get Inventory Item",
"Get Job Status": "Get Job Status",
@@ -86,14 +109,24 @@
"Get Publication": "Get Publication",
"Get Refund": "Get Refund",
"Get Shop": "Get Shop",
+ "Hold Fulfillment Order": "Hold Fulfillment Order",
"List Abandoned Checkouts": "List Abandoned Checkouts",
+ "List Carrier Services": "List Carrier Services",
"List Collection Products": "List Collection Products",
"List Customer Addresses": "List Customer Addresses",
"List Customer Orders": "List Customer Orders",
+ "List Delivery Profiles": "List Delivery Profiles",
+ "List Discount Redeem Codes": "List Discount Redeem Codes",
+ "List Discounts": "List Discounts",
"List Draft Orders": "List Draft Orders",
+ "List Fulfillment Events": "List Fulfillment Events",
+ "List Fulfillment Order Move Locations": "List Fulfillment Order Move Locations",
+ "List Fulfillment Services": "List Fulfillment Services",
"Search Inventory Items": "Search Inventory Items",
"List Inventory Levels": "List Inventory Levels",
"List Locations": "List Locations",
+ "List Order Fulfillment Orders": "List Order Fulfillment Orders",
+ "List Order Fulfillments": "List Order Fulfillments",
"List Order Refunds": "List Order Refunds",
"List Order Transactions": "List Order Transactions",
"List Product Media": "List Product Media",
@@ -102,7 +135,9 @@
"List Sales Channels": "List Sales Channels",
"List Tender Transactions": "List Tender Transactions",
"Mark Order as Paid": "Mark Order as Paid",
+ "Move Fulfillment Order": "Move Fulfillment Order",
"Publish Product or Collection": "Publish Product or Collection",
+ "Release Fulfillment Order Hold": "Release Fulfillment Order Hold",
"Remove Products from Collection": "Remove Products from Collection",
"Remove Tags": "Remove Tags",
"Start Collection Product Reorder": "Start Collection Product Reorder",
@@ -111,20 +146,26 @@
"Reorder Product Variants": "Reorder Product Variants",
"Search Collections": "Search Collections",
"Search Customers": "Search Customers",
+ "Search Gift Cards": "Search Gift Cards",
"Search Orders": "Search Orders",
"Search Product Categories": "Search Product Categories",
"Search Products": "Search Products",
"Send Customer Account Invite": "Send Customer Account Invite",
"Send Draft Order Invoice": "Send Draft Order Invoice",
"Set Default Customer Address": "Set Default Customer Address",
+ "Set Fulfillment Orders Deadline": "Set Fulfillment Orders Deadline",
"Set Inventory Quantities": "Set Inventory Quantities",
"Set Product (Full State)": "Set Product (Full State)",
"Start Order Cancellation": "Start Order Cancellation",
"Unarchive Order": "Unarchive Order",
"Unpublish Product or Collection": "Unpublish Product or Collection",
+ "Update Amount-Off Discount Code": "Update Amount-Off Discount Code",
"Update Collection": "Update Collection",
"Update Customer Address": "Update Customer Address",
"Update Draft Order": "Update Draft Order",
+ "Update Free Shipping Discount Code": "Update Free Shipping Discount Code",
+ "Update Fulfillment Tracking": "Update Fulfillment Tracking",
+ "Update Gift Card": "Update Gift Card",
"Update Inventory Item": "Update Inventory Item",
"Update Order Details": "Update Order Details",
"Update Product Media": "Update Product Media",
@@ -159,9 +200,11 @@
"Update an existing product.": "Update an existing product.",
"Upload a new product image.": "Upload a new product image.",
"Start tracking an inventory item at a location, optionally with a starting quantity.": "Start tracking an inventory item at a location, optionally with a starting quantity.",
+ "Start adding up to 250 new redeem codes to a code discount (runs in the background).": "Start adding up to 250 new redeem codes to a code discount (runs in the background).",
"Add images, videos or 3D models to a product from public URLs.": "Add images, videos or 3D models to a product from public URLs.",
"Add products to a collection by hand.": "Add products to a collection by hand.",
"Add tags to an order, draft order, customer or product.": "Add tags to an order, draft order, customer or product.",
+ "List every shipping zone of one location group in a delivery profile, with countries and rates.": "List every shipping zone of one location group in a delivery profile, with countries and rates.",
"Email a customer a secure link to add a new payment method for an order, draft order or subscription contract.": "Email a customer a secure link to add a new payment method for an order, draft order or subscription contract.",
"Mark a buyer request to edit an order as completed.": "Mark a buyer request to edit an order as completed.",
"Decline a buyer request to edit an order, with an optional note to the buyer.": "Decline a buyer request to edit an order, with an optional note to the buyer.",
@@ -172,19 +215,30 @@
"Close (archive) an order.": "Close (archive) an order.",
"Show existing product media on specific variants (for example the red photo on the red variant).": "Show existing product media on specific variants (for example the red photo on the red variant).",
"Preview the refund Shopify suggests for an order, without refunding.": "Preview the refund Shopify suggests for an order, without refunding.",
+ "Cancel a fulfillment order that was sent to a fulfillment service; a replacement is created.": "Cancel a fulfillment order that was sent to a fulfillment service; a replacement is created.",
+ "Cancel a fulfillment so its items become unfulfilled again.": "Cancel a fulfillment so its items become unfulfilled again.",
"Capture money from an authorized payment on an order.": "Capture money from an authorized payment on an order.",
"Turn a draft order into a real order.": "Turn a draft order into a real order.",
"Count abandoned checkouts, optionally filtered.": "Count abandoned checkouts, optionally filtered.",
"Count collections, optionally filtered.": "Count collections, optionally filtered.",
"Count the customer segments defined in the store.": "Count the customer segments defined in the store.",
"Count customers, optionally filtered.": "Count customers, optionally filtered.",
+ "Count the redeem codes across the store's code discounts, optionally filtered.": "Count the redeem codes across the store's code discounts, optionally filtered.",
+ "Count discounts (code and automatic), optionally filtered.": "Count discounts (code and automatic), optionally filtered.",
"Count draft orders, optionally filtered.": "Count draft orders, optionally filtered.",
+ "Count gift cards, optionally filtered.": "Count gift cards, optionally filtered.",
"Count the store's locations, optionally filtered.": "Count the store's locations, optionally filtered.",
"Count products, optionally filtered.": "Count products, optionally filtered.",
+ "Create a percentage or fixed-amount discount that customers apply with a code.": "Create a percentage or fixed-amount discount that customers apply with a code.",
+ "Create a \"buy X, get Y\" discount that customers apply with a code.": "Create a \"buy X, get Y\" discount that customers apply with a code.",
"Create a manual collection, optionally with an initial list of products.": "Create a manual collection, optionally with an initial list of products.",
"Add a new address to a customer.": "Add a new address to a customer.",
"Create a customer with contact details, tags and optional email marketing consent.": "Create a customer with contact details, tags and optional email marketing consent.",
"Create a draft order with one or more product or custom line items.": "Create a draft order with one or more product or custom line items.",
+ "Create a free shipping discount that customers apply with a code.": "Create a free shipping discount that customers apply with a code.",
+ "Add a shipment status event (in transit, out for delivery, delivered, …) to a fulfillment.": "Add a shipment status event (in transit, out for delivery, delivered, …) to a fulfillment.",
+ "Mark items of a fulfillment order as shipped, with optional tracking details.": "Mark items of a fulfillment order as shipped, with optional tracking details.",
+ "Issue a new gift card with an initial balance.": "Issue a new gift card with an initial balance.",
"Record a fraud risk assessment with supporting facts on an order.": "Record a fraud risk assessment with supporting facts on an order.",
"Create a real order with one or more line items.": "Create a real order with one or more line items.",
"Add new options (such as Size or Color) and their values to a product.": "Add new options (such as Size or Color) and their values to a product.",
@@ -192,11 +246,15 @@
"Add one or more variants to a product.": "Add one or more variants to a product.",
"Refund money and/or line items on an order.": "Refund money and/or line items on an order.",
"Create a rule-based collection that automatically includes products matching conditions.": "Create a rule-based collection that automatically includes products matching conditions.",
+ "Permanently disable a gift card so it can no longer be used.": "Permanently disable a gift card so it can no longer be used.",
"Stop tracking an inventory item at a location.": "Stop tracking an inventory item at a location.",
"Permanently delete a collection. The products in it are not deleted.": "Permanently delete a collection. The products in it are not deleted.",
"Delete a saved address from a customer.": "Delete a saved address from a customer.",
"Permanently delete a customer who has no orders.": "Permanently delete a customer who has no orders.",
+ "Start deleting redeem codes from a code discount (runs in the background).": "Start deleting redeem codes from a code discount (runs in the background).",
+ "Permanently delete a code discount or an automatic discount.": "Permanently delete a code discount or an automatic discount.",
"Permanently delete a draft order.": "Permanently delete a draft order.",
+ "Delete a fulfillment service and decide what happens to its location's inventory.": "Delete a fulfillment service and decide what happens to its location's inventory.",
"Permanently delete an archived or cancelled order.": "Permanently delete an archived or cancelled order.",
"Remove images, videos or 3D models from a product.": "Remove images, videos or 3D models from a product.",
"Delete one or more options from a product.": "Delete one or more options from a product.",
@@ -204,13 +262,19 @@
"Permanently delete a product with all its variants and media.": "Permanently delete a product with all its variants and media.",
"Stop showing specific product media on specific variants.": "Stop showing specific product media on specific variants.",
"Create a copy of a product under a new title.": "Create a copy of a product under a new title.",
+ "Look up the code discount that a redeem code belongs to.": "Look up the code discount that a redeem code belongs to.",
"Create a one-time account activation link for a customer.": "Create a one-time account activation link for a customer.",
"Get a customer abandonment (browse, cart or checkout) by id.": "Get a customer abandonment (browse, cart or checkout) by id.",
"Get the abandonment record of an abandoned checkout.": "Get the abandonment record of an abandoned checkout.",
"Get one collection by its URL handle.": "Get one collection by its URL handle.",
"Get one collection with its membership sources and conditions.": "Get one collection with its membership sources and conditions.",
"Get one customer with contact details, marketing state and default address.": "Get one customer with contact details, marketing state and default address.",
+ "Check the progress and results of a redeem code import started by add_discount_redeem_codes.": "Check the progress and results of a redeem code import started by add_discount_redeem_codes.",
+ "Get one discount (code or automatic) with its value, target, eligibility and limits.": "Get one discount (code or automatic) with its value, target, eligibility and limits.",
"Get one draft order with its line items and totals.": "Get one draft order with its line items and totals.",
+ "Get one fulfillment with its tracking, origin address and shipped line items.": "Get one fulfillment with its tracking, origin address and shipped line items.",
+ "Get one fulfillment order with its status, holds, location and line items.": "Get one fulfillment order with its status, holds, location and line items.",
+ "Get one gift card with its balance, status and owner.": "Get one gift card with its balance, status and owner.",
"List the Admin API access scopes granted to the connected app.": "List the Admin API access scopes granted to the connected app.",
"Get one inventory item with its SKU, cost, tracking and shipping details.": "Get one inventory item with its SKU, cost, tracking and shipping details.",
"Check whether an asynchronous Shopify job has finished.": "Check whether an asynchronous Shopify job has finished.",
@@ -225,14 +289,24 @@
"Get one publication (sales channel or catalog) by id.": "Get one publication (sales channel or catalog) by id.",
"Get one refund by id.": "Get one refund by id.",
"Get the store name, domain, currency, timezone and plan.": "Get the store name, domain, currency, timezone and plan.",
+ "Put a fulfillment order (or some of its items) on hold so it is not shipped yet.": "Put a fulfillment order (or some of its items) on hold so it is not shipped yet.",
"List checkouts that customers started but did not complete.": "List checkouts that customers started but did not complete.",
+ "List the carrier-calculated shipping rate services set up on the store.": "List the carrier-calculated shipping rate services set up on the store.",
"List the products in a collection, one page at a time.": "List the products in a collection, one page at a time.",
"List the saved addresses of one customer.": "List the saved addresses of one customer.",
"List the orders of one customer, one page at a time.": "List the orders of one customer, one page at a time.",
+ "List the shipping profiles with their zones, countries and rates.": "List the shipping profiles with their zones, countries and rates.",
+ "List the redeem codes of a code discount with their usage counts.": "List the redeem codes of a code discount with their usage counts.",
+ "List and search discounts (code and automatic) with their status and dates.": "List and search discounts (code and automatic) with their status and dates.",
"Search draft orders, one page at a time.": "Search draft orders, one page at a time.",
+ "List the tracking events recorded on a fulfillment.": "List the tracking events recorded on a fulfillment.",
+ "List the locations a fulfillment order could be moved to, and whether each one can take it.": "List the locations a fulfillment order could be moved to, and whether each one can take it.",
+ "List the fulfillment services installed on the store.": "List the fulfillment services installed on the store.",
"Search inventory items by SKU or id, one page at a time.": "Search inventory items by SKU or id, one page at a time.",
"List stock quantities of one item across locations, or of all items at one location.": "List stock quantities of one item across locations, or of all items at one location.",
"List the store's locations (warehouses, shops, fulfillment services), one page at a time.": "List the store's locations (warehouses, shops, fulfillment services), one page at a time.",
+ "List the fulfillment orders of an order: what still has to be shipped, from which location.": "List the fulfillment orders of an order: what still has to be shipped, from which location.",
+ "List the fulfillments (shipments) of an order with their tracking.": "List the fulfillments (shipments) of an order with their tracking.",
"List every refund made on an order.": "List every refund made on an order.",
"List every payment transaction on an order.": "List every payment transaction on an order.",
"List the images, videos and 3D models of a product, one page at a time.": "List the images, videos and 3D models of a product, one page at a time.",
@@ -241,7 +315,9 @@
"List the sales channels installed on the store.": "List the sales channels installed on the store.",
"List money actually received or paid out across all orders.": "List money actually received or paid out across all orders.",
"Record the outstanding balance of an order as paid manually.": "Record the outstanding balance of an order as paid manually.",
+ "Ship a fulfillment order (or some of its items) from a different location.": "Ship a fulfillment order (or some of its items) from a different location.",
"Publish a product or collection to one or more sales channels or catalogs.": "Publish a product or collection to one or more sales channels or catalogs.",
+ "Release holds on a fulfillment order so it can be shipped.": "Release holds on a fulfillment order so it can be shipped.",
"Remove hand-picked products from a collection.": "Remove hand-picked products from a collection.",
"Remove tags from an order, draft order, customer or product.": "Remove tags from an order, draft order, customer or product.",
"Start moving products to new positions inside a manually sorted collection (runs in the background).": "Start moving products to new positions inside a manually sorted collection (runs in the background).",
@@ -250,21 +326,27 @@
"Move variants of a product to new positions.": "Move variants of a product to new positions.",
"Search collections with Shopify search syntax, one page at a time.": "Search collections with Shopify search syntax, one page at a time.",
"Search customers with Shopify search syntax, one page at a time.": "Search customers with Shopify search syntax, one page at a time.",
+ "Search gift cards by status, balance, customer, code ending and more.": "Search gift cards by status, balance, customer, code ending and more.",
"Search orders with Shopify search syntax, one page at a time.": "Search orders with Shopify search syntax, one page at a time.",
"Search Shopify's standard product taxonomy for category ids.": "Search Shopify's standard product taxonomy for category ids.",
"Search products with Shopify search syntax, one page at a time.": "Search products with Shopify search syntax, one page at a time.",
"Email a customer an invitation to create their store account.": "Email a customer an invitation to create their store account.",
"Email the checkout invoice of a draft order to the customer.": "Email the checkout invoice of a draft order to the customer.",
"Make one of a customer's saved addresses the default.": "Make one of a customer's saved addresses the default.",
+ "Set the date by which one or more fulfillment orders must be fulfilled.": "Set the date by which one or more fulfillment orders must be fulfilled.",
"Set stock to an absolute number at one or more locations.": "Set stock to an absolute number at one or more locations.",
"Create or overwrite a whole product, including all its options and variants, in one call.": "Create or overwrite a whole product, including all its options and variants, in one call.",
"Cancel an order asynchronously and get a job to poll.": "Cancel an order asynchronously and get a job to poll.",
"Reopen a closed (archived) order.": "Reopen a closed (archived) order.",
"Remove a product or collection from one or more sales channels or catalogs.": "Remove a product or collection from one or more sales channels or catalogs.",
+ "Change an existing percentage or fixed-amount discount code.": "Change an existing percentage or fixed-amount discount code.",
"Change a collection's title, description, handle, sort order, image or SEO, and add or remove its rule conditions.": "Change a collection's title, description, handle, sort order, image or SEO, and add or remove its rule conditions.",
"Change fields of a saved customer address.": "Change fields of a saved customer address.",
"Change the name, email, phone, note, tags, locale or tax exemption of a customer.": "Change the name, email, phone, note, tags, locale or tax exemption of a customer.",
"Change the line items, customer, contact, tags or payment terms of a draft order.": "Change the line items, customer, contact, tags or payment terms of a draft order.",
+ "Change an existing free shipping discount code.": "Change an existing free shipping discount code.",
+ "Change the carrier, tracking numbers or tracking URLs of a fulfillment.": "Change the carrier, tracking numbers or tracking URLs of a fulfillment.",
+ "Change a gift card's note, expiry date, owner or recipient.": "Change a gift card's note, expiry date, owner or recipient.",
"Change the SKU, unit cost, tracking, shipping, weight or customs data of an inventory item.": "Change the SKU, unit cost, tracking, shipping, weight or customs data of an inventory item.",
"Change the email, phone, note, tags or PO number of an order.": "Change the email, phone, note, tags or PO number of an order.",
"Change the title, description, vendor, type, status, handle, tags, category, SEO or collections of a product.": "Change the title, description, vendor, type, status, handle, tags, category, SEO or collections of a product.",
@@ -319,6 +401,8 @@
"Location ID": "Location ID",
"Starting Available Quantity": "Starting Available Quantity",
"Idempotency Key": "Idempotency Key",
+ "Discount ID": "Discount ID",
+ "Codes": "Codes",
"Product ID": "Product ID",
"Media": "Media",
"Collection ID": "Collection ID",
@@ -326,14 +410,18 @@
"Source ID": "Source ID",
"Resource Type": "Resource Type",
"Resource ID": "Resource ID",
+ "Delivery Profile ID": "Delivery Profile ID",
+ "Location Group ID": "Location Group ID",
+ "Page Size": "Page Size",
+ "Cursor": "Cursor",
+ "Zone Token": "Zone Token",
+ "Rates Cursor": "Rates Cursor",
"Sender Email": "Sender Email",
"BCC Recipients": "BCC Recipients",
"Requested Order Edit ID": "Requested Order Edit ID",
"Decline Note": "Decline Note",
"Order ID": "Order ID",
"Line Items to Remove": "Line Items to Remove",
- "Page Size": "Page Size",
- "Cursor": "Cursor",
"Quantity Name": "Quantity Name",
"Reason": "Reason",
"Changes": "Changes",
@@ -343,12 +431,44 @@
"Refund All Shipping": "Refund All Shipping",
"Shipping Amount": "Shipping Amount",
"Suggest Full Refund": "Suggest Full Refund",
+ "Fulfillment Order ID": "Fulfillment Order ID",
+ "Fulfillment ID": "Fulfillment ID",
"Authorization Transaction ID": "Authorization Transaction ID",
"Final Capture": "Final Capture",
"Draft Order ID": "Draft Order ID",
"Payment Gateway ID": "Payment Gateway ID",
"Source Name": "Source Name",
"Search Query": "Search Query",
+ "Code": "Code",
+ "Value Type": "Value Type",
+ "Value": "Value",
+ "Apply Amount To Each Item": "Apply Amount To Each Item",
+ "Applies To": "Applies To",
+ "Variant IDs": "Variant IDs",
+ "Collection IDs": "Collection IDs",
+ "Eligibility": "Eligibility",
+ "Customer IDs": "Customer IDs",
+ "Segment IDs": "Segment IDs",
+ "Minimum Requirement": "Minimum Requirement",
+ "Minimum Value": "Minimum Value",
+ "Starts At": "Starts At",
+ "Ends At": "Ends At",
+ "Usage Limit": "Usage Limit",
+ "Once Per Customer": "Once Per Customer",
+ "Combines With Product Discounts": "Combines With Product Discounts",
+ "Combines With Order Discounts": "Combines With Order Discounts",
+ "Combines With Shipping Discounts": "Combines With Shipping Discounts",
+ "Customer Buys": "Customer Buys",
+ "Buys Value": "Buys Value",
+ "Buys Product IDs": "Buys Product IDs",
+ "Buys Variant IDs": "Buys Variant IDs",
+ "Buys Collection IDs": "Buys Collection IDs",
+ "Gets Quantity": "Gets Quantity",
+ "Gets Percentage Off": "Gets Percentage Off",
+ "Gets Product IDs": "Gets Product IDs",
+ "Gets Variant IDs": "Gets Variant IDs",
+ "Gets Collection IDs": "Gets Collection IDs",
+ "Uses Per Order Limit": "Uses Per Order Limit",
"Description (HTML)": "Description (HTML)",
"Handle": "Handle",
"Product Sort Order": "Product Sort Order",
@@ -379,6 +499,25 @@
"Shipping Line Title": "Shipping Line Title",
"Shipping Price": "Shipping Price",
"Reserve Inventory Until": "Reserve Inventory Until",
+ "Destination": "Destination",
+ "Country Codes": "Country Codes",
+ "Maximum Shipping Price": "Maximum Shipping Price",
+ "Happened At": "Happened At",
+ "Estimated Delivery At": "Estimated Delivery At",
+ "Province": "Province",
+ "Country": "Country",
+ "ZIP": "ZIP",
+ "Address": "Address",
+ "Tracking Company": "Tracking Company",
+ "Tracking Numbers": "Tracking Numbers",
+ "Tracking URLs": "Tracking URLs",
+ "Notify Customer": "Notify Customer",
+ "Initial Amount": "Initial Amount",
+ "Expires On": "Expires On",
+ "Recipient Customer ID": "Recipient Customer ID",
+ "Recipient Preferred Name": "Recipient Preferred Name",
+ "Recipient Message": "Recipient Message",
+ "Send Notification At": "Send Notification At",
"Risk Level": "Risk Level",
"Facts": "Facts",
"Financial Status": "Financial Status",
@@ -398,54 +537,78 @@
"Inventory Behaviour": "Inventory Behaviour",
"Send Order Receipt": "Send Order Receipt",
"Fulfilled From Location ID": "Fulfilled From Location ID",
- "Tracking Numbers": "Tracking Numbers",
- "Tracking Company": "Tracking Company",
"Options": "Options",
"Variant Strategy": "Variant Strategy",
"Category ID": "Category ID",
- "Collection IDs": "Collection IDs",
"Variants": "Variants",
"Default Variant Handling": "Default Variant Handling",
"Refund Transactions": "Refund Transactions",
- "Notify Customer": "Notify Customer",
"Match": "Match",
"Conditions": "Conditions",
+ "Gift Card ID": "Gift Card ID",
"Address ID": "Address ID",
+ "Code IDs": "Code IDs",
+ "Search": "Search",
+ "Fulfillment Service ID": "Fulfillment Service ID",
+ "Inventory Action": "Inventory Action",
+ "Destination Location ID": "Destination Location ID",
"Media IDs": "Media IDs",
"Option IDs": "Option IDs",
- "Variant IDs": "Variant IDs",
"New Title": "New Title",
"Copy Images": "Copy Images",
"Copy Translations": "Copy Translations",
"Abandonment ID": "Abandonment ID",
"Abandoned Checkout ID": "Abandoned Checkout ID",
+ "Bulk Creation ID": "Bulk Creation ID",
+ "Line Items Cursor": "Line Items Cursor",
"Job ID": "Job ID",
"Transaction ID": "Transaction ID",
"Media ID": "Media ID",
"Variant ID": "Variant ID",
"Publication ID": "Publication ID",
"Refund ID": "Refund ID",
+ "Reason Notes": "Reason Notes",
+ "External ID": "External ID",
+ "Notify Merchant": "Notify Merchant",
"Sort By": "Sort By",
"Reverse Order": "Reverse Order",
+ "Merchant Owned Only": "Merchant Owned Only",
+ "Fulfillment Order Line Item IDs": "Fulfillment Order Line Item IDs",
"Include Inactive": "Include Inactive",
"Include Legacy": "Include Legacy",
"Catalog Type": "Catalog Type",
+ "New Location ID": "New Location ID",
"Publication IDs": "Publication IDs",
"Publish Date": "Publish Date",
+ "Release Scope": "Release Scope",
+ "Hold IDs": "Hold IDs",
"Moves": "Moves",
"Options in Order": "Options in Order",
"New Positions": "New Positions",
- "Search": "Search",
"Parent Category ID": "Parent Category ID",
"Subject": "Subject",
"Custom Message": "Custom Message",
"Recipient Email": "Recipient Email",
+ "Fulfillment Order IDs": "Fulfillment Order IDs",
+ "Deadline": "Deadline",
"Quantities": "Quantities",
"Product Handle": "Product Handle",
"Restock Items": "Restock Items",
"Refund Method": "Refund Method",
"Store Credit Expiry": "Store Credit Expiry",
"Staff Note": "Staff Note",
+ "Remove End Date": "Remove End Date",
+ "Product IDs To Add": "Product IDs To Add",
+ "Product IDs To Remove": "Product IDs To Remove",
+ "Variant IDs To Add": "Variant IDs To Add",
+ "Variant IDs To Remove": "Variant IDs To Remove",
+ "Collection IDs To Add": "Collection IDs To Add",
+ "Collection IDs To Remove": "Collection IDs To Remove",
+ "Customer IDs To Add": "Customer IDs To Add",
+ "Customer IDs To Remove": "Customer IDs To Remove",
+ "Segment IDs To Add": "Segment IDs To Add",
+ "Segment IDs To Remove": "Segment IDs To Remove",
+ "Remove Usage Limit": "Remove Usage Limit",
"Redirect Old Handle": "Redirect Old Handle",
"Conditions Source ID": "Conditions Source ID",
"Condition IDs to Delete": "Condition IDs to Delete",
@@ -454,6 +617,8 @@
"Payment Terms Template ID": "Payment Terms Template ID",
"Payment Terms Issued At": "Payment Terms Issued At",
"Payment Due At": "Payment Due At",
+ "Country Codes To Add": "Country Codes To Add",
+ "Country Codes To Remove": "Country Codes To Remove",
"SKU": "SKU",
"Unit Cost": "Unit Cost",
"Track Quantity": "Track Quantity",
@@ -510,6 +675,8 @@
"The location id, numeric or \"gid://shopify/Location/…\" (from list_locations).": "The location id, numeric or \"gid://shopify/Location/…\" (from list_locations).",
"Optional whole-number available quantity to start with, for example 10.": "Optional whole-number available quantity to start with, for example 10.",
"A unique key for this operation, for example a UUID such as \"3f1c2a9e-6b1d-4c8e-9a51-2f7d0e4b8c10\". Generate your own key on the first call and pass the same key again when retrying after a timeout or error, so Shopify does not repeat the operation. If left empty a key is generated; it is returned as idempotency_key and included in any error message.": "A unique key for this operation, for example a UUID such as \"3f1c2a9e-6b1d-4c8e-9a51-2f7d0e4b8c10\". Generate your own key on the first call and pass the same key again when retrying after a timeout or error, so Shopify does not repeat the operation. If left empty a key is generated; it is returned as idempotency_key and included in any error message.",
+ "The code discount id, for example \"gid://shopify/DiscountCodeNode/123\" or \"123\". Get it from list_discounts or find_discount_by_code.": "The code discount id, for example \"gid://shopify/DiscountCodeNode/123\" or \"123\". Get it from list_discounts or find_discount_by_code.",
+ "The new codes, 1 to 250, for example \"WELCOME-A1B2\". Duplicates in the list are sent once.": "The new codes, 1 to 250, for example \"WELCOME-A1B2\". Duplicates in the list are sent once.",
"The product id, numeric or \"gid://shopify/Product/…\". Find it with search_products.": "The product id, numeric or \"gid://shopify/Product/…\". Find it with search_products.",
"The media to add, one entry per file.": "The media to add, one entry per file.",
"The collection id, numeric or \"gid://shopify/Collection/…\". Find it with search_collections.": "The collection id, numeric or \"gid://shopify/Collection/…\". Find it with search_collections.",
@@ -518,6 +685,12 @@
"What kind of record the id belongs to. Used to build the full id when a numeric id is given.": "What kind of record the id belongs to. Used to build the full id when a numeric id is given.",
"Numeric id such as \"450789469\" or a full id such as \"gid://shopify/Order/450789469\".": "Numeric id such as \"450789469\" or a full id such as \"gid://shopify/Order/450789469\".",
"Tags to add, for example [\"vip\", \"follow-up\"].": "Tags to add, for example [\"vip\", \"follow-up\"].",
+ "The profile id from list_delivery_profiles, numeric or \"gid://shopify/DeliveryProfile/…\".": "The profile id from list_delivery_profiles, numeric or \"gid://shopify/DeliveryProfile/…\".",
+ "The location_group_id from list_delivery_profiles, numeric or \"gid://shopify/DeliveryLocationGroup/…\".": "The location_group_id from list_delivery_profiles, numeric or \"gid://shopify/DeliveryLocationGroup/…\".",
+ "How many records to return, 1 to 25. Defaults to 25.": "How many records to return, 1 to 25. Defaults to 25.",
+ "The end_cursor from the previous page. Leave empty for the first page; pass it only while has_next_page is true.": "The end_cursor from the previous page. Leave empty for the first page; pass it only while has_next_page is true.",
+ "To read more rates of one zone: that zone's zone_token from a previous call. Returns only that zone.": "To read more rates of one zone: that zone's zone_token from a previous call. Returns only that zone.",
+ "With zone_token: the zone's rates_end_cursor from a previous call, to read its next 50 rates.": "With zone_token: the zone's rates_end_cursor from a previous call, to read its next 50 rates.",
"What the new payment method is for.": "What the new payment method is for.",
"The id of the order, draft order or subscription contract, numeric or a full id such as \"gid://shopify/Order/450789469\", \"gid://shopify/DraftOrder/…\" or \"gid://shopify/SubscriptionContract/…\". It must match the resource type; Shopify receives the number.": "The id of the order, draft order or subscription contract, numeric or a full id such as \"gid://shopify/Order/450789469\", \"gid://shopify/DraftOrder/…\" or \"gid://shopify/SubscriptionContract/…\". It must match the resource type; Shopify receives the number.",
"Send from this address instead of the store default, for example \"[email protected]\".": "Send from this address instead of the store default, for example \"[email protected]\".",
@@ -526,8 +699,6 @@
"Message sent to the buyer explaining the decline, at most 500 characters. Leave empty to send none.": "Message sent to the buyer explaining the decline, at most 500 characters. Leave empty to send none.",
"The order id, numeric or \"gid://shopify/Order/…\". Find it with search_orders.": "The order id, numeric or \"gid://shopify/Order/…\". Find it with search_orders.",
"The order line items the buyer wants removed and how many units of each. Line item ids come from get_order (line_items[].id). The quantity cannot exceed the unfulfilled quantity of the line item.": "The order line items the buyer wants removed and how many units of each. Line item ids come from get_order (line_items[].id). The quantity cannot exceed the unfulfilled quantity of the line item.",
- "How many records to return, 1 to 25. Defaults to 25.": "How many records to return, 1 to 25. Defaults to 25.",
- "The end_cursor from the previous page. Leave empty for the first page; pass it only while has_next_page is true.": "The end_cursor from the previous page. Leave empty for the first page; pass it only while has_next_page is true.",
"Which quantity to adjust. Anything other than \"available\" needs a ledger document URI on each change.": "Which quantity to adjust. Anything other than \"available\" needs a ledger document URI on each change.",
"Why the stock changes; shown in the inventory history.": "Why the stock changes; shown in the inventory history.",
"One entry per inventory item and location.": "One entry per inventory item and location.",
@@ -538,6 +709,8 @@
"Include the full shipping cost in the suggestion. Off by default.": "Include the full shipping cost in the suggestion. Off by default.",
"Refund only this much shipping, for example 4.50. Ignored when refunding all shipping.": "Refund only this much shipping, for example 4.50. Ignored when refunding all shipping.",
"Suggest refunding everything still refundable on the order. Off by default.": "Suggest refunding everything still refundable on the order. Off by default.",
+ "The fulfillment order to cancel, numeric or \"gid://shopify/FulfillmentOrder/…\". Find it with list_order_fulfillment_orders.": "The fulfillment order to cancel, numeric or \"gid://shopify/FulfillmentOrder/…\". Find it with list_order_fulfillment_orders.",
+ "The fulfillment to cancel, numeric or \"gid://shopify/Fulfillment/…\". Find it with list_order_fulfillments.": "The fulfillment to cancel, numeric or \"gid://shopify/Fulfillment/…\". Find it with list_order_fulfillments.",
"The order id, numeric or \"gid://shopify/Order/…\".": "The order id, numeric or \"gid://shopify/Order/…\".",
"The AUTHORIZATION transaction to capture, numeric or \"gid://shopify/OrderTransaction/…\". Find it with list_order_transactions.": "The AUTHORIZATION transaction to capture, numeric or \"gid://shopify/OrderTransaction/…\". Find it with list_order_transactions.",
"Amount to capture, for example 49.99. Cannot exceed the authorized amount still capturable.": "Amount to capture, for example 49.99. Cannot exceed the authorized amount still capturable.",
@@ -549,9 +722,48 @@
"Shopify search syntax, for example \"created_at:>=2026-09-01\". Leave empty to count all.": "Shopify search syntax, for example \"created_at:>=2026-09-01\". Leave empty to count all.",
"Shopify collection search syntax, for example \"collection_type:custom\". Leave empty to count all.": "Shopify collection search syntax, for example \"collection_type:custom\". Leave empty to count all.",
"Filter by created_at, updated_at or id, for example \"created_at:>2026-01-01\". Leave empty to count all.": "Filter by created_at, updated_at or id, for example \"created_at:>2026-01-01\". Leave empty to count all.",
+ "Optional Shopify search syntax on the codes, for example \"times_used:0\". Leave empty to count all.": "Optional Shopify search syntax on the codes, for example \"times_used:0\". Leave empty to count all.",
+ "Shopify discount search syntax, for example \"status:active method:code\". Leave empty to count all.": "Shopify discount search syntax, for example \"status:active method:code\". Leave empty to count all.",
"Shopify draft order search syntax, for example \"status:open\". Leave empty to count all.": "Shopify draft order search syntax, for example \"status:open\". Leave empty to count all.",
+ "Shopify gift card search syntax, for example \"status:enabled\". Leave empty to count all.": "Shopify gift card search syntax, for example \"status:enabled\". Leave empty to count all.",
"Shopify location search syntax, for example \"name:Warehouse*\". Leave empty to count all.": "Shopify location search syntax, for example \"name:Warehouse*\". Leave empty to count all.",
"Shopify product search syntax, for example \"status:active\" or \"tag:sale\". Leave empty to count all.": "Shopify product search syntax, for example \"status:active\" or \"tag:sale\". Leave empty to count all.",
+ "Internal title shown in the admin, for example \"Spring sale 15%\".": "Internal title shown in the admin, for example \"Spring sale 15%\".",
+ "The code customers enter at checkout, for example \"SPRING15\".": "The code customers enter at checkout, for example \"SPRING15\".",
+ "Percentage off or a fixed amount off.": "Percentage off or a fixed amount off.",
+ "For PERCENTAGE the percent, 15 means 15% off (above 0, at most 100). For FIXED_AMOUNT the amount in the shop currency, for example 10.": "For PERCENTAGE the percent, 15 means 15% off (above 0, at most 100). For FIXED_AMOUNT the amount in the shop currency, for example 10.",
+ "FIXED_AMOUNT only: Yes takes the amount off every eligible item, No takes it off once per order. Leave unset for Shopify's default.": "FIXED_AMOUNT only: Yes takes the amount off every eligible item, No takes it off once per order. Leave unset for Shopify's default.",
+ "What the discount applies to. Leave unset to infer it from the ids: PRODUCTS when product_ids or variant_ids are given, COLLECTIONS when collection_ids are given, ALL items when no ids are given.": "What the discount applies to. Leave unset to infer it from the ids: PRODUCTS when product_ids or variant_ids are given, COLLECTIONS when collection_ids are given, ALL items when no ids are given.",
+ "With applies_to PRODUCTS: product ids, numeric or \"gid://shopify/Product/…\".": "With applies_to PRODUCTS: product ids, numeric or \"gid://shopify/Product/…\".",
+ "With applies_to PRODUCTS: variant ids, numeric or \"gid://shopify/ProductVariant/…\".": "With applies_to PRODUCTS: variant ids, numeric or \"gid://shopify/ProductVariant/…\".",
+ "With applies_to COLLECTIONS: collection ids, numeric or \"gid://shopify/Collection/…\".": "With applies_to COLLECTIONS: collection ids, numeric or \"gid://shopify/Collection/…\".",
+ "Who can use the code. Leave unset to infer it from the ids: CUSTOMERS when customer_ids are given, SEGMENTS when segment_ids are given, ALL buyers when no ids are given.": "Who can use the code. Leave unset to infer it from the ids: CUSTOMERS when customer_ids are given, SEGMENTS when segment_ids are given, ALL buyers when no ids are given.",
+ "With eligibility CUSTOMERS: customer ids, numeric or \"gid://shopify/Customer/…\".": "With eligibility CUSTOMERS: customer ids, numeric or \"gid://shopify/Customer/…\".",
+ "With eligibility SEGMENTS: customer segment ids, numeric or \"gid://shopify/Segment/…\".": "With eligibility SEGMENTS: customer segment ids, numeric or \"gid://shopify/Segment/…\".",
+ "Optional minimum the cart must reach. Leave unset for none.": "Optional minimum the cart must reach. Leave unset for none.",
+ "With a minimum requirement: the subtotal (for example 50) or the whole-number item quantity (for example 3).": "With a minimum requirement: the subtotal (for example 50) or the whole-number item quantity (for example 3).",
+ "When the code becomes usable, ISO 8601. Defaults to now.": "When the code becomes usable, ISO 8601. Defaults to now.",
+ "Optional end, ISO 8601. Leave empty for no end date.": "Optional end, ISO 8601. Leave empty for no end date.",
+ "Optional total number of times the code can be used across all customers.": "Optional total number of times the code can be used across all customers.",
+ "Each customer can use the code only once. Off by default.": "Each customer can use the code only once. Off by default.",
+ "Can be combined with other product discounts. Off by default.": "Can be combined with other product discounts. Off by default.",
+ "Can be combined with order discounts. Off by default.": "Can be combined with order discounts. Off by default.",
+ "Can be combined with shipping discounts. Off by default.": "Can be combined with shipping discounts. Off by default.",
+ "Optional tags for the discount, for example \"spring\".": "Optional tags for the discount, for example \"spring\".",
+ "Internal title shown in the admin, for example \"Buy 2 shirts, get 1 cap free\".": "Internal title shown in the admin, for example \"Buy 2 shirts, get 1 cap free\".",
+ "The code customers enter at checkout, for example \"B2G1CAP\".": "The code customers enter at checkout, for example \"B2G1CAP\".",
+ "What the customer must buy to unlock the offer: a number of items or a minimum spend.": "What the customer must buy to unlock the offer: a number of items or a minimum spend.",
+ "For QUANTITY the whole number of qualifying items, for example 2. For AMOUNT the spend on qualifying items in the shop currency, for example 50.": "For QUANTITY the whole number of qualifying items, for example 2. For AMOUNT the spend on qualifying items in the shop currency, for example 50.",
+ "Products that count toward what the customer buys, numeric or \"gid://shopify/Product/…\". Use products and variants, or collections, not both.": "Products that count toward what the customer buys, numeric or \"gid://shopify/Product/…\". Use products and variants, or collections, not both.",
+ "Variants that count toward what the customer buys, numeric or \"gid://shopify/ProductVariant/…\".": "Variants that count toward what the customer buys, numeric or \"gid://shopify/ProductVariant/…\".",
+ "Collections whose products count toward what the customer buys, numeric or \"gid://shopify/Collection/…\".": "Collections whose products count toward what the customer buys, numeric or \"gid://shopify/Collection/…\".",
+ "How many discounted items the customer gets, a whole number of 1 or more, for example 1.": "How many discounted items the customer gets, a whole number of 1 or more, for example 1.",
+ "Percent off the items the customer gets, above 0 and at most 100. 100 (the default) makes them free; 50 is half price.": "Percent off the items the customer gets, above 0 and at most 100. 100 (the default) makes them free; 50 is half price.",
+ "Products the customer gets at the discount, numeric or \"gid://shopify/Product/…\". Use products and variants, or collections, not both.": "Products the customer gets at the discount, numeric or \"gid://shopify/Product/…\". Use products and variants, or collections, not both.",
+ "Variants the customer gets at the discount, numeric or \"gid://shopify/ProductVariant/…\".": "Variants the customer gets at the discount, numeric or \"gid://shopify/ProductVariant/…\".",
+ "Collections whose products the customer gets at the discount, numeric or \"gid://shopify/Collection/…\".": "Collections whose products the customer gets at the discount, numeric or \"gid://shopify/Collection/…\".",
+ "Optional: the most times the offer applies in one order, a whole number of 1 or more. Leave empty for no limit.": "Optional: the most times the offer applies in one order, a whole number of 1 or more. Leave empty for no limit.",
+ "Optional tags for the discount, for example \"bogo\".": "Optional tags for the discount, for example \"bogo\".",
"Collection title, for example \"Summer Sale\".": "Collection title, for example \"Summer Sale\".",
"Collection description, HTML allowed.": "Collection description, HTML allowed.",
"URL handle, for example \"summer-sale\". Generated from the title when empty.": "URL handle, for example \"summer-sale\". Generated from the title when empty.",
@@ -599,6 +811,41 @@
"Name of a custom shipping line, for example \"Courier\".": "Name of a custom shipping line, for example \"Courier\".",
"Price of the custom shipping line, for example 12.00. Requires a shipping title and a currency.": "Price of the custom shipping line, for example 12.00. Requires a shipping title and a currency.",
"Hold the stock for this draft until this time (ISO 8601). Leave empty to not reserve stock.": "Hold the stock for this draft until this time (ISO 8601). Leave empty to not reserve stock.",
+ "Internal title shown in the admin, for example \"Free shipping over 50\".": "Internal title shown in the admin, for example \"Free shipping over 50\".",
+ "The code customers enter at checkout, for example \"FREESHIP\".": "The code customers enter at checkout, for example \"FREESHIP\".",
+ "Where free shipping applies. Leave unset to infer it: COUNTRIES when country_codes are given, ALL countries when none are given.": "Where free shipping applies. Leave unset to infer it: COUNTRIES when country_codes are given, ALL countries when none are given.",
+ "With destination COUNTRIES: two-letter ISO country codes, for example \"US\" and \"CA\".": "With destination COUNTRIES: two-letter ISO country codes, for example \"US\" and \"CA\".",
+ "Optional: only shipping rates up to this price qualify, for example 20. Leave empty for any rate.": "Optional: only shipping rates up to this price qualify, for example 20. Leave empty for any rate.",
+ "Can be combined with product discounts. Off by default.": "Can be combined with product discounts. Off by default.",
+ "Can be combined with other shipping discounts. Off by default.": "Can be combined with other shipping discounts. Off by default.",
+ "Optional tags for the discount, for example \"shipping\".": "Optional tags for the discount, for example \"shipping\".",
+ "The fulfillment id, numeric or \"gid://shopify/Fulfillment/…\". Find it with list_order_fulfillments.": "The fulfillment id, numeric or \"gid://shopify/Fulfillment/…\". Find it with list_order_fulfillments.",
+ "The shipment status this event reports.": "The shipment status this event reports.",
+ "Optional message, for example \"Arrived at sorting facility\".": "Optional message, for example \"Arrived at sorting facility\".",
+ "When the event happened, ISO 8601. Defaults to now on Shopify's side.": "When the event happened, ISO 8601. Defaults to now on Shopify's side.",
+ "The new estimated delivery time, ISO 8601.": "The new estimated delivery time, ISO 8601.",
+ "City where the event happened, for example \"Memphis\".": "City where the event happened, for example \"Memphis\".",
+ "Province or state where the event happened, for example \"Tennessee\".": "Province or state where the event happened, for example \"Tennessee\".",
+ "Country where the event happened, for example \"United States\".": "Country where the event happened, for example \"United States\".",
+ "Postal code where the event happened.": "Postal code where the event happened.",
+ "Street address where the event happened.": "Street address where the event happened.",
+ "The fulfillment order to fulfill, numeric or \"gid://shopify/FulfillmentOrder/…\". Find it with list_order_fulfillment_orders.": "The fulfillment order to fulfill, numeric or \"gid://shopify/FulfillmentOrder/…\". Find it with list_order_fulfillment_orders.",
+ "Optional partial shipment: the fulfillment order line items and quantities to ship. Leave empty to ship all remaining items of the fulfillment order.": "Optional partial shipment: the fulfillment order line items and quantities to ship. Leave empty to ship all remaining items of the fulfillment order.",
+ "The carrier name, for example \"UPS\", \"USPS\", \"FedEx\" or \"DHL Express\". With a supported carrier Shopify builds the tracking URL itself.": "The carrier name, for example \"UPS\", \"USPS\", \"FedEx\" or \"DHL Express\". With a supported carrier Shopify builds the tracking URL itself.",
+ "One or more tracking numbers, for example \"1Z999AA10123456784\".": "One or more tracking numbers, for example \"1Z999AA10123456784\".",
+ "Tracking page URLs, one per tracking number, for example \"https://www.ups.com/track?tracknum=1Z999AA10123456784\". Only needed for carriers Shopify does not know.": "Tracking page URLs, one per tracking number, for example \"https://www.ups.com/track?tracknum=1Z999AA10123456784\". Only needed for carriers Shopify does not know.",
+ "Send the customer a shipping confirmation email. Off by default.": "Send the customer a shipping confirmation email. Off by default.",
+ "Optional internal message recorded with the fulfillment.": "Optional internal message recorded with the fulfillment.",
+ "The starting balance, for example 50 for 50.00.": "The starting balance, for example 50 for 50.00.",
+ "ISO currency code of the amount, for example \"USD\". Normally the shop currency.": "ISO currency code of the amount, for example \"USD\". Normally the shop currency.",
+ "Optional custom code customers type at checkout, letters and numbers only, for example \"WELCOME2026GIFT\". Leave empty for a random 16-character code.": "Optional custom code customers type at checkout, letters and numbers only, for example \"WELCOME2026GIFT\". Leave empty for a random 16-character code.",
+ "Optional customer who owns the card, numeric or \"gid://shopify/Customer/…\".": "Optional customer who owns the card, numeric or \"gid://shopify/Customer/…\".",
+ "Optional expiry date, YYYY-MM-DD, for example \"2027-12-31\". Leave empty for no expiry.": "Optional expiry date, YYYY-MM-DD, for example \"2027-12-31\". Leave empty for no expiry.",
+ "Optional internal note, not shown to the customer.": "Optional internal note, not shown to the customer.",
+ "Optional customer who receives the gift card notification, numeric or \"gid://shopify/Customer/…\". Needed for the recipient message and notification time.": "Optional customer who receives the gift card notification, numeric or \"gid://shopify/Customer/…\". Needed for the recipient message and notification time.",
+ "Optional name used to greet the recipient, for example \"Sam\".": "Optional name used to greet the recipient, for example \"Sam\".",
+ "Optional personal message included in the recipient notification.": "Optional personal message included in the recipient notification.",
+ "Optional time to email the recipient, ISO 8601. Leave empty to send when Shopify processes it.": "Optional time to email the recipient, ISO 8601. Leave empty to send when Shopify processes it.",
"The assessed fraud risk.": "The assessed fraud risk.",
"Reasons behind the assessment, at least one.": "Reasons behind the assessment, at least one.",
"The items to order. Give either a variant id (price comes from the product) or a title and price for a custom item.": "The items to order. Give either a variant id (price comes from the product) or a title and price for a custom item.",
@@ -653,8 +900,15 @@
"Shop currency code for price conditions, for example \"USD\".": "Shop currency code for price conditions, for example \"USD\".",
"URL handle, for example \"summer-items\". Generated from the title when empty.": "URL handle, for example \"summer-items\". Generated from the title when empty.",
"Theme template suffix, for example \"sale\".": "Theme template suffix, for example \"sale\".",
+ "The gift card to deactivate, numeric or \"gid://shopify/GiftCard/…\". Find it with search_gift_cards.": "The gift card to deactivate, numeric or \"gid://shopify/GiftCard/…\". Find it with search_gift_cards.",
"The customer id, numeric or \"gid://shopify/Customer/…\".": "The customer id, numeric or \"gid://shopify/Customer/…\".",
"The address id from list_customer_addresses, for example \"gid://shopify/MailingAddress/1053318585?model_name=CustomerAddress\" or its number.": "The address id from list_customer_addresses, for example \"gid://shopify/MailingAddress/1053318585?model_name=CustomerAddress\" or its number.",
+ "The redeem code ids to delete, for example \"gid://shopify/DiscountRedeemCode/241951653\" (from list_discount_redeem_codes). Leave empty when using search.": "The redeem code ids to delete, for example \"gid://shopify/DiscountRedeemCode/241951653\" (from list_discount_redeem_codes). Leave empty when using search.",
+ "Delete every code of this discount matching this search: \"times_used:<n>\" such as \"times_used:0\", or plain text matched against the code such as \"SUMMER\". Plain text is matched word by word, not exactly, so preview it with list_discount_redeem_codes first. Other field filters (for example \"code:\") are rejected. Leave empty when using code_ids.": "Delete every code of this discount matching this search: \"times_used:<n>\" such as \"times_used:0\", or plain text matched against the code such as \"SUMMER\". Plain text is matched word by word, not exactly, so preview it with list_discount_redeem_codes first. Other field filters (for example \"code:\") are rejected. Leave empty when using code_ids.",
+ "The full discount id, for example \"gid://shopify/DiscountCodeNode/123\" or \"gid://shopify/DiscountAutomaticNode/456\".": "The full discount id, for example \"gid://shopify/DiscountCodeNode/123\" or \"gid://shopify/DiscountAutomaticNode/456\".",
+ "The fulfillment service, numeric or \"gid://shopify/FulfillmentService/…\". Find it with list_fulfillment_services.": "The fulfillment service, numeric or \"gid://shopify/FulfillmentService/…\". Find it with list_fulfillment_services.",
+ "What happens to the service location and its inventory: TRANSFER to another location, KEEP as a regular location, or DELETE.": "What happens to the service location and its inventory: TRANSFER to another location, KEEP as a regular location, or DELETE.",
+ "Required with TRANSFER, not allowed otherwise: the active merchant-managed location that receives the inventory, numeric or \"gid://shopify/Location/…\". Find it with list_locations.": "Required with TRANSFER, not allowed otherwise: the active merchant-managed location that receives the inventory, numeric or \"gid://shopify/Location/…\". Find it with list_locations.",
"The product to remove the media from, numeric or \"gid://shopify/Product/…\".": "The product to remove the media from, numeric or \"gid://shopify/Product/…\".",
"Ids of the media to remove, for example [\"gid://shopify/MediaImage/1072273219\"].": "Ids of the media to remove, for example [\"gid://shopify/MediaImage/1072273219\"].",
"Ids of the options to delete, for example [\"gid://shopify/ProductOption/1064576516\"].": "Ids of the options to delete, for example [\"gid://shopify/ProductOption/1064576516\"].",
@@ -667,10 +921,17 @@
"Status of the copy. Leave empty to keep the status of the original.": "Status of the copy. Leave empty to keep the status of the original.",
"Also copy the product images (runs in the background). Off by default.": "Also copy the product images (runs in the background). Off by default.",
"Also copy the product translations. Off by default.": "Also copy the product translations. Off by default.",
+ "The redeem code, for example \"SPRING15\".": "The redeem code, for example \"SPRING15\".",
"The abandonment id, numeric or \"gid://shopify/Abandonment/…\".": "The abandonment id, numeric or \"gid://shopify/Abandonment/…\".",
"The abandoned checkout id, numeric or \"gid://shopify/AbandonedCheckout/…\". Find it with list_abandoned_checkouts.": "The abandoned checkout id, numeric or \"gid://shopify/AbandonedCheckout/…\". Find it with list_abandoned_checkouts.",
"The collection handle, for example \"summer-sale\".": "The collection handle, for example \"summer-sale\".",
"The customer id, numeric such as \"207119551\" or \"gid://shopify/Customer/207119551\". Find it with search_customers.": "The customer id, numeric such as \"207119551\" or \"gid://shopify/Customer/207119551\". Find it with search_customers.",
+ "The bulk_creation_id returned by add_discount_redeem_codes, for example \"gid://shopify/DiscountRedeemCodeBulkCreation/989355205\" (a plain number is accepted).": "The bulk_creation_id returned by add_discount_redeem_codes, for example \"gid://shopify/DiscountRedeemCodeBulkCreation/989355205\" (a plain number is accepted).",
+ "How many records to return, 1 to 60. Defaults to 50.": "How many records to return, 1 to 60. Defaults to 50.",
+ "The full discount id, for example \"gid://shopify/DiscountCodeNode/123\" or \"gid://shopify/DiscountAutomaticNode/456\". Get it from list_discounts or find_discount_by_code.": "The full discount id, for example \"gid://shopify/DiscountCodeNode/123\" or \"gid://shopify/DiscountAutomaticNode/456\". Get it from list_discounts or find_discount_by_code.",
+ "The fulfillment order id, numeric or \"gid://shopify/FulfillmentOrder/…\". Find it with list_order_fulfillment_orders.": "The fulfillment order id, numeric or \"gid://shopify/FulfillmentOrder/…\". Find it with list_order_fulfillment_orders.",
+ "Leave empty for the first 50 line items. To read more, pass line_items_end_cursor from the previous call.": "Leave empty for the first 50 line items. To read more, pass line_items_end_cursor from the previous call.",
+ "The gift card id, numeric or \"gid://shopify/GiftCard/…\". Find it with search_gift_cards.": "The gift card id, numeric or \"gid://shopify/GiftCard/…\". Find it with search_gift_cards.",
"The job id returned by the start action, for example \"gid://shopify/Job/dc9b2604-c73b-45c6-8942-e235bac987e8\". A bare UUID such as \"dc9b2604-c73b-45c6-8942-e235bac987e8\" is also accepted.": "The job id returned by the start action, for example \"gid://shopify/Job/dc9b2604-c73b-45c6-8942-e235bac987e8\". A bare UUID such as \"dc9b2604-c73b-45c6-8942-e235bac987e8\" is also accepted.",
"The location id, numeric or \"gid://shopify/Location/…\". Find it with list_locations.": "The location id, numeric or \"gid://shopify/Location/…\". Find it with list_locations.",
"The transaction id, numeric such as \"389404469\" or \"gid://shopify/OrderTransaction/389404469\". Find it with list_order_transactions.": "The transaction id, numeric such as \"389404469\" or \"gid://shopify/OrderTransaction/389404469\". Find it with list_order_transactions.",
@@ -681,19 +942,37 @@
"The variant id: numeric such as \"808950810\" or \"gid://shopify/ProductVariant/808950810\". Find it with list_product_variants.": "The variant id: numeric such as \"808950810\" or \"gid://shopify/ProductVariant/808950810\". Find it with list_product_variants.",
"The publication id, numeric or \"gid://shopify/Publication/…\". Find it with list_publications.": "The publication id, numeric or \"gid://shopify/Publication/…\". Find it with list_publications.",
"The refund id, numeric or \"gid://shopify/Refund/…\". Find it with list_order_refunds.": "The refund id, numeric or \"gid://shopify/Refund/…\". Find it with list_order_refunds.",
+ "The fulfillment order to hold, numeric or \"gid://shopify/FulfillmentOrder/…\". Find it with list_order_fulfillment_orders.": "The fulfillment order to hold, numeric or \"gid://shopify/FulfillmentOrder/…\". Find it with list_order_fulfillment_orders.",
+ "Why the fulfillment order is held.": "Why the fulfillment order is held.",
+ "Optional details shown with the hold, for example \"Waiting for the customer to confirm the address\".": "Optional details shown with the hold, for example \"Waiting for the customer to confirm the address\".",
+ "Optional unique name for this hold within your app, for example \"address-check\". Useful to find the hold again later.": "Optional unique name for this hold within your app, for example \"address-check\". Useful to find the hold again later.",
+ "Optional id from your own system that placed the hold.": "Optional id from your own system that placed the hold.",
+ "Notify the merchant about the hold. Off by default.": "Notify the merchant about the hold. Off by default.",
+ "Optional partial hold: the fulfillment order line items and quantities to hold. Leave empty to hold the whole fulfillment order.": "Optional partial hold: the fulfillment order line items and quantities to hold. Leave empty to hold the whole fulfillment order.",
"Shopify search syntax, for example \"created_at:>=2026-09-01\" or \"status:open\". Leave empty for all.": "Shopify search syntax, for example \"created_at:>=2026-09-01\" or \"status:open\". Leave empty for all.",
"Field to sort by. Defaults to the checkout id.": "Field to sort by. Defaults to the checkout id.",
"Return results in reverse sort order (for example newest first).": "Return results in reverse sort order (for example newest first).",
"How many records to return, 1 to 100. Defaults to 50.": "How many records to return, 1 to 100. Defaults to 50.",
+ "Optional Shopify search syntax, for example \"active:true\" or \"id:123\". Leave empty to list all.": "Optional Shopify search syntax, for example \"active:true\" or \"id:123\". Leave empty to list all.",
+ "Field to sort by. Defaults to the id.": "Field to sort by. Defaults to the id.",
+ "How many records to return, 1 to 250. Defaults to 50.": "How many records to return, 1 to 250. Defaults to 50.",
"Field to sort by. Defaults to the collection's own sort order.": "Field to sort by. Defaults to the collection's own sort order.",
"How many records to return, 1 to 80. Defaults to 50.": "How many records to return, 1 to 80. Defaults to 50.",
- "How many records to return, 1 to 250. Defaults to 50.": "How many records to return, 1 to 250. Defaults to 50.",
"Optional order search syntax to narrow the list, for example \"financial_status:paid\" or \"created_at:>=2026-01-01\".": "Optional order search syntax to narrow the list, for example \"financial_status:paid\" or \"created_at:>=2026-01-01\".",
"Field to sort by. Defaults to the order id.": "Field to sort by. Defaults to the order id.",
"How many records to return, 1 to 40. Defaults to 40.": "How many records to return, 1 to 40. Defaults to 40.",
+ "Return only profiles created by the merchant, not by apps. Off by default.": "Return only profiles created by the merchant, not by apps. Off by default.",
+ "How many records to return, 1 to 1. Defaults to 1.": "How many records to return, 1 to 1. Defaults to 1.",
+ "Optional filter: \"times_used:<n>\" such as \"times_used:0\", or plain text matched against the code such as \"SUMMER\". Other field filters (for example \"code:\") are rejected. Leave empty to list all.": "Optional filter: \"times_used:<n>\" such as \"times_used:0\", or plain text matched against the code such as \"SUMMER\". Other field filters (for example \"code:\") are rejected. Leave empty to list all.",
+ "Shopify discount search syntax, for example \"status:active method:code\" or \"title:Spring*\". Leave empty to list all.": "Shopify discount search syntax, for example \"status:active method:code\" or \"title:Spring*\". Leave empty to list all.",
+ "How many records to return, 1 to 45. Defaults to 45.": "How many records to return, 1 to 45. Defaults to 45.",
"Shopify draft order search syntax, for example \"status:open\", \"status:invoice_sent\" or \"tag:quote\". Leave empty for all.": "Shopify draft order search syntax, for example \"status:open\", \"status:invoice_sent\" or \"tag:quote\". Leave empty for all.",
"Field to sort by. Defaults to the draft id.": "Field to sort by. Defaults to the draft id.",
- "How many records to return, 1 to 60. Defaults to 50.": "How many records to return, 1 to 60. Defaults to 50.",
+ "Field to sort by. Defaults to when the event happened.": "Field to sort by. Defaults to when the event happened.",
+ "The fulfillment order to move, numeric or \"gid://shopify/FulfillmentOrder/…\". Find it with list_order_fulfillment_orders.": "The fulfillment order to move, numeric or \"gid://shopify/FulfillmentOrder/…\". Find it with list_order_fulfillment_orders.",
+ "Optional location search, for example \"name:Warehouse*\". Leave empty to list all candidates.": "Optional location search, for example \"name:Warehouse*\". Leave empty to list all candidates.",
+ "Optional: only check these fulfillment order line items (line_items[].id from get_fulfillment_order). Leave empty to check all.": "Optional: only check these fulfillment order line items (line_items[].id from get_fulfillment_order). Leave empty to check all.",
+ "How many records to return, 1 to 200. Defaults to 50.": "How many records to return, 1 to 200. Defaults to 50.",
"Shopify inventory item search syntax, for example \"sku:TSHIRT-RED-L\". Leave empty to list all.": "Shopify inventory item search syntax, for example \"sku:TSHIRT-RED-L\". Leave empty to list all.",
"List this item's levels at every location, numeric or \"gid://shopify/InventoryItem/…\". Leave empty when giving a location.": "List this item's levels at every location, numeric or \"gid://shopify/InventoryItem/…\". Leave empty when giving a location.",
"List every item stocked at this location, numeric or \"gid://shopify/Location/…\". Leave empty when giving an item.": "List every item stocked at this location, numeric or \"gid://shopify/Location/…\". Leave empty when giving an item.",
@@ -703,16 +982,23 @@
"Also return deactivated locations. Off by default.": "Also return deactivated locations. Off by default.",
"Also return legacy fulfillment-service locations. Off by default.": "Also return legacy fulfillment-service locations. Off by default.",
"Field to sort by. Defaults to the name.": "Field to sort by. Defaults to the name.",
+ "Optional Shopify search syntax on the fulfillment orders, for example \"status:open\". Leave empty to list all.": "Optional Shopify search syntax on the fulfillment orders, for example \"status:open\". Leave empty to list all.",
+ "How many records to return, 1 to 4. Defaults to 4.": "How many records to return, 1 to 4. Defaults to 4.",
"How many records to return, 1 to 50. Defaults to 50.": "How many records to return, 1 to 50. Defaults to 50.",
"Field to sort by. Defaults to position.": "Field to sort by. Defaults to position.",
"How many records to return, 1 to 130. Defaults to 50.": "How many records to return, 1 to 130. Defaults to 50.",
"Only list publications of this catalog type. Leave empty for all.": "Only list publications of this catalog type. Leave empty for all.",
"Shopify search syntax, for example \"processed_at:>=2026-09-01\" or \"test:false\". Leave empty for all.": "Shopify search syntax, for example \"processed_at:>=2026-09-01\" or \"test:false\". Leave empty for all.",
- "How many records to return, 1 to 200. Defaults to 50.": "How many records to return, 1 to 200. Defaults to 50.",
+ "The location that should ship the items, numeric or \"gid://shopify/Location/…\". Find a movable one with list_fulfillment_order_move_locations.": "The location that should ship the items, numeric or \"gid://shopify/Location/…\". Find a movable one with list_fulfillment_order_move_locations.",
+ "Optional partial move: the fulfillment order line items and quantities to move. Leave empty to move the whole fulfillment order.": "Optional partial move: the fulfillment order line items and quantities to move. Leave empty to move the whole fulfillment order.",
"Whether the id is a product or a collection.": "Whether the id is a product or a collection.",
"The product or collection id, numeric or a full id such as \"gid://shopify/Product/632910392\".": "The product or collection id, numeric or a full id such as \"gid://shopify/Product/632910392\".",
"Publications to publish to, for example [\"gid://shopify/Publication/762454635\"].": "Publications to publish to, for example [\"gid://shopify/Publication/762454635\"].",
"Optional future date and time to publish at. Leave empty to publish now.": "Optional future date and time to publish at. Leave empty to publish now.",
+ "The held fulfillment order, numeric or \"gid://shopify/FulfillmentOrder/…\". Find it with list_order_fulfillment_orders.": "The held fulfillment order, numeric or \"gid://shopify/FulfillmentOrder/…\". Find it with list_order_fulfillment_orders.",
+ "Release only the listed holds, or every hold on the fulfillment order.": "Release only the listed holds, or every hold on the fulfillment order.",
+ "The holds to release, for example \"gid://shopify/FulfillmentHold/123\". Required with LISTED_HOLDS, must be empty with ALL_HOLDS.": "The holds to release, for example \"gid://shopify/FulfillmentHold/123\". Required with LISTED_HOLDS, must be empty with ALL_HOLDS.",
+ "Optional id from your own system that releases the hold.": "Optional id from your own system that releases the hold.",
"Products to remove, numeric or \"gid://shopify/Product/…\".": "Products to remove, numeric or \"gid://shopify/Product/…\".",
"Optional conditions source to remove the picks from (from get_collection sources). Must not be a shared source. Leave empty to remove from every non-shared conditions source.": "Optional conditions source to remove the picks from (from get_collection sources). Must not be a shared source. Leave empty to remove from every non-shared conditions source.",
"Tags to remove, for example [\"follow-up\"].": "Tags to remove, for example [\"follow-up\"].",
@@ -725,6 +1011,8 @@
"Field to sort by. Defaults to the collection id.": "Field to sort by. Defaults to the collection id.",
"Shopify customer search syntax, for example \"email:[email protected]\", \"country:Canada\" or \"orders_count:>5\". Leave empty to list all customers.": "Shopify customer search syntax, for example \"email:[email protected]\", \"country:Canada\" or \"orders_count:>5\". Leave empty to list all customers.",
"Field to sort by. Defaults to the customer id.": "Field to sort by. Defaults to the customer id.",
+ "Shopify gift card search syntax, for example \"status:enabled balance_status:partial\", or a code or its last 4 characters as plain text such as \"1234\". Leave empty to list all.": "Shopify gift card search syntax, for example \"status:enabled balance_status:partial\", or a code or its last 4 characters as plain text such as \"1234\". Leave empty to list all.",
+ "How many records to return, 1 to 110. Defaults to 50.": "How many records to return, 1 to 110. Defaults to 50.",
"Shopify order search syntax, for example \"status:open financial_status:paid\", \"tag:wholesale\" or \"created_at:>=2026-01-01\". Leave empty to list all orders.": "Shopify order search syntax, for example \"status:open financial_status:paid\", \"tag:wholesale\" or \"created_at:>=2026-01-01\". Leave empty to list all orders.",
"Words to search for, for example \"t-shirts\".": "Words to search for, for example \"t-shirts\".",
"List the direct children of this category, for example \"aa-1\" or \"gid://shopify/TaxonomyCategory/aa-1\".": "List the direct children of this category, for example \"aa-1\" or \"gid://shopify/TaxonomyCategory/aa-1\".",
@@ -734,6 +1022,8 @@
"A personal message added to the invitation.": "A personal message added to the invitation.",
"Send to this address instead of the draft email, for example \"[email protected]\".": "Send to this address instead of the draft email, for example \"[email protected]\".",
"A personal message added to the invoice email.": "A personal message added to the invoice email.",
+ "The fulfillment orders, numeric or \"gid://shopify/FulfillmentOrder/…\". Find them with list_order_fulfillment_orders.": "The fulfillment orders, numeric or \"gid://shopify/FulfillmentOrder/…\". Find them with list_order_fulfillment_orders.",
+ "The date and time by which they must be fulfilled, ISO 8601, for example \"2026-10-01T17:00:00Z\".": "The date and time by which they must be fulfilled, ISO 8601, for example \"2026-10-01T17:00:00Z\".",
"Which quantity to set.": "Which quantity to set.",
"Optional URI of the document behind the change, for example \"gid://my-app/CycleCount/CC-1\".": "Optional URI of the document behind the change, for example \"gid://my-app/CycleCount/CC-1\".",
"The product to overwrite, numeric or \"gid://shopify/Product/…\". Leave empty (and no handle) to create a new product.": "The product to overwrite, numeric or \"gid://shopify/Product/…\". Leave empty (and no handle) to create a new product.",
@@ -753,6 +1043,34 @@
"Email the customer about the cancellation. Off by default.": "Email the customer about the cancellation. Off by default.",
"Internal note about the cancellation, not shown to the customer.": "Internal note about the cancellation, not shown to the customer.",
"Publications to unpublish from, for example [\"gid://shopify/Publication/762454635\"].": "Publications to unpublish from, for example [\"gid://shopify/Publication/762454635\"].",
+ "The code discount id, for example \"gid://shopify/DiscountCodeNode/123\" or \"123\". Get it from list_discounts, get_discount or find_discount_by_code.": "The code discount id, for example \"gid://shopify/DiscountCodeNode/123\" or \"123\". Get it from list_discounts, get_discount or find_discount_by_code.",
+ "New internal title. Leave empty to keep it.": "New internal title. Leave empty to keep it.",
+ "New code customers enter. Leave empty to keep it.": "New code customers enter. Leave empty to keep it.",
+ "New start, ISO 8601. Leave empty to keep it.": "New start, ISO 8601. Leave empty to keep it.",
+ "New end, ISO 8601. Leave empty to keep it. To remove the end date use remove_end_date.": "New end, ISO 8601. Leave empty to keep it. To remove the end date use remove_end_date.",
+ "Yes: clear the end date so the code no longer expires. Cannot be combined with ends_at. Leave unset to keep the end date.": "Yes: clear the end date so the code no longer expires. Cannot be combined with ends_at. Leave unset to keep the end date.",
+ "Percentage or fixed amount. Send together with value and applies_to.": "Percentage or fixed amount. Send together with value and applies_to.",
+ "For PERCENTAGE the percent (15 means 15% off). For FIXED_AMOUNT the amount in the shop currency.": "For PERCENTAGE the percent (15 means 15% off). For FIXED_AMOUNT the amount in the shop currency.",
+ "FIXED_AMOUNT only: Yes takes the amount off every eligible item, No once per order.": "FIXED_AMOUNT only: Yes takes the amount off every eligible item, No once per order.",
+ "What the discount applies to. Send together with value_type and value.": "What the discount applies to. Send together with value_type and value.",
+ "With applies_to PRODUCTS: products the discount applies to, numeric or \"gid://shopify/Product/…\".": "With applies_to PRODUCTS: products the discount applies to, numeric or \"gid://shopify/Product/…\".",
+ "With applies_to PRODUCTS: products to take out of the discount.": "With applies_to PRODUCTS: products to take out of the discount.",
+ "With applies_to PRODUCTS: variants the discount applies to, numeric or \"gid://shopify/ProductVariant/…\".": "With applies_to PRODUCTS: variants the discount applies to, numeric or \"gid://shopify/ProductVariant/…\".",
+ "With applies_to PRODUCTS: variants to take out of the discount.": "With applies_to PRODUCTS: variants to take out of the discount.",
+ "With applies_to COLLECTIONS: collections the discount applies to, numeric or \"gid://shopify/Collection/…\".": "With applies_to COLLECTIONS: collections the discount applies to, numeric or \"gid://shopify/Collection/…\".",
+ "With applies_to COLLECTIONS: collections to take out of the discount.": "With applies_to COLLECTIONS: collections to take out of the discount.",
+ "Who can use the code. Replaces the current eligibility.": "Who can use the code. Replaces the current eligibility.",
+ "With eligibility CUSTOMERS: customers who can use the code, numeric or \"gid://shopify/Customer/…\".": "With eligibility CUSTOMERS: customers who can use the code, numeric or \"gid://shopify/Customer/…\".",
+ "With eligibility CUSTOMERS: customers who should no longer be able to use it.": "With eligibility CUSTOMERS: customers who should no longer be able to use it.",
+ "With eligibility SEGMENTS: segments that can use the code, numeric or \"gid://shopify/Segment/…\".": "With eligibility SEGMENTS: segments that can use the code, numeric or \"gid://shopify/Segment/…\".",
+ "With eligibility SEGMENTS: segments that should no longer be able to use it.": "With eligibility SEGMENTS: segments that should no longer be able to use it.",
+ "New minimum, or NONE to remove it. Leave unset to keep the current one.": "New minimum, or NONE to remove it. Leave unset to keep the current one.",
+ "With SUBTOTAL or QUANTITY: the subtotal or the whole-number item quantity.": "With SUBTOTAL or QUANTITY: the subtotal or the whole-number item quantity.",
+ "New total usage limit, a whole number of 1 or more. Leave empty to keep it. To remove the limit use remove_usage_limit.": "New total usage limit, a whole number of 1 or more. Leave empty to keep it. To remove the limit use remove_usage_limit.",
+ "Yes: clear the total usage limit so the code can be used any number of times. Cannot be combined with usage_limit. Leave unset to keep the limit.": "Yes: clear the total usage limit so the code can be used any number of times. Cannot be combined with usage_limit. Leave unset to keep the limit.",
+ "Yes: each customer can use it once. No: no per-customer limit. Leave unset to keep it.": "Yes: each customer can use it once. No: no per-customer limit. Leave unset to keep it.",
+ "Set all three combines_with choices together; they replace the current combinations.": "Set all three combines_with choices together; they replace the current combinations.",
+ "The complete new tag list; replaces the current tags. Leave empty to keep them.": "The complete new tag list; replaces the current tags. Leave empty to keep them.",
"New title.": "New title.",
"New description, HTML allowed. Replaces the existing description.": "New description, HTML allowed. Replaces the existing description.",
"New URL handle.": "New URL handle.",
@@ -787,6 +1105,22 @@
"Start date for net payment terms (for example net 30), ISO 8601.": "Start date for net payment terms (for example net 30), ISO 8601.",
"Due date for fixed-date payment terms, ISO 8601.": "Due date for fixed-date payment terms, ISO 8601.",
"Hold the stock for this draft until this time (ISO 8601).": "Hold the stock for this draft until this time (ISO 8601).",
+ "Where free shipping applies; replaces the current destination. Leave unset to keep it, or to use COUNTRIES when country codes are given.": "Where free shipping applies; replaces the current destination. Leave unset to keep it, or to use COUNTRIES when country codes are given.",
+ "With destination COUNTRIES: two-letter ISO country codes where free shipping should apply, for example \"US\" and \"CA\".": "With destination COUNTRIES: two-letter ISO country codes where free shipping should apply, for example \"US\" and \"CA\".",
+ "With destination COUNTRIES: two-letter ISO country codes to take out, for example \"MX\".": "With destination COUNTRIES: two-letter ISO country codes to take out, for example \"MX\".",
+ "New cap on the shipping rate the code covers, above 0, for example 20. Leave empty to keep it.": "New cap on the shipping rate the code covers, above 0, for example 20. Leave empty to keep it.",
+ "The carrier name, for example \"UPS\", \"USPS\", \"FedEx\" or \"DHL Express\".": "The carrier name, for example \"UPS\", \"USPS\", \"FedEx\" or \"DHL Express\".",
+ "The complete list of tracking numbers. Replaces the stored list; leave empty to keep it.": "The complete list of tracking numbers. Replaces the stored list; leave empty to keep it.",
+ "The complete list of tracking page URLs, one per tracking number. Replaces the stored list; leave empty to keep it.": "The complete list of tracking page URLs, one per tracking number. Replaces the stored list; leave empty to keep it.",
+ "Send the customer a shipping update email. Off by default.": "Send the customer a shipping update email. Off by default.",
+ "New internal note. Leave empty to keep the current one.": "New internal note. Leave empty to keep the current one.",
+ "New expiry date, YYYY-MM-DD, for example \"2027-12-31\". Leave empty to keep the current one.": "New expiry date, YYYY-MM-DD, for example \"2027-12-31\". Leave empty to keep the current one.",
+ "New owner customer, numeric or \"gid://shopify/Customer/…\". Leave empty to keep the current owner.": "New owner customer, numeric or \"gid://shopify/Customer/…\". Leave empty to keep the current owner.",
+ "Theme template suffix for the gift card page, for example \"birthday\". Leave empty to keep it.": "Theme template suffix for the gift card page, for example \"birthday\". Leave empty to keep it.",
+ "Customer who receives the gift card notification, numeric or \"gid://shopify/Customer/…\". Required to change any recipient detail.": "Customer who receives the gift card notification, numeric or \"gid://shopify/Customer/…\". Required to change any recipient detail.",
+ "Name used to greet the recipient, for example \"Sam\".": "Name used to greet the recipient, for example \"Sam\".",
+ "Personal message included in the recipient notification.": "Personal message included in the recipient notification.",
+ "Time to email the recipient, ISO 8601.": "Time to email the recipient, ISO 8601.",
"New SKU, for example \"TSHIRT-RED-L\".": "New SKU, for example \"TSHIRT-RED-L\".",
"New unit cost in the shop currency, for example 7.50.": "New unit cost in the shop currency, for example 7.50.",
"Whether Shopify tracks stock for this item. Leave empty to keep the current setting.": "Whether Shopify tracks stock for this item. Leave empty to keep the current setting.",
@@ -854,6 +1188,17 @@
"Other": "Other",
"Yes": "Yes",
"No": "No",
+ "Percentage": "Percentage",
+ "Fixed amount": "Fixed amount",
+ "All items": "All items",
+ "Specific products or variants": "Specific products or variants",
+ "Specific collections": "Specific collections",
+ "All buyers": "All buyers",
+ "Specific customers": "Specific customers",
+ "Customer segments": "Customer segments",
+ "Minimum subtotal": "Minimum subtotal",
+ "Minimum quantity of items": "Minimum quantity of items",
+ "Minimum purchase amount": "Minimum purchase amount",
"Manual": "Manual",
"Best selling": "Best selling",
"Alphabetical A-Z": "Alphabetical A-Z",
@@ -870,8 +1215,19 @@
"Single opt-in": "Single opt-in",
"Confirmed opt-in": "Confirmed opt-in",
"Unknown": "Unknown",
- "Percentage": "Percentage",
- "Fixed amount": "Fixed amount",
+ "All countries": "All countries",
+ "Specific countries": "Specific countries",
+ "Label purchased": "Label purchased",
+ "Label printed": "Label printed",
+ "Confirmed": "Confirmed",
+ "Carrier picked up": "Carrier picked up",
+ "In transit": "In transit",
+ "Out for delivery": "Out for delivery",
+ "Ready for pickup": "Ready for pickup",
+ "Attempted delivery": "Attempted delivery",
+ "Delayed": "Delayed",
+ "Delivered": "Delivered",
+ "Failure": "Failure",
"High": "High",
"Medium": "Medium",
"Low": "Low",
@@ -894,26 +1250,45 @@
"Keep the standalone placeholder variant": "Keep the standalone placeholder variant",
"All conditions": "All conditions",
"Any condition": "Any condition",
+ "Transfer inventory to another location": "Transfer inventory to another location",
+ "Keep the location and its inventory": "Keep the location and its inventory",
+ "Delete the location and its inventory": "Delete the location and its inventory",
"Refuse if any variant would be deleted": "Refuse if any variant would be deleted",
"Default (only options with a single value)": "Default (only options with a single value)",
"Delete duplicate variants, keep the lowest position": "Delete duplicate variants, keep the lowest position",
+ "Awaiting payment": "Awaiting payment",
+ "High risk of fraud": "High risk of fraud",
+ "Incorrect address": "Incorrect address",
+ "Inventory out of stock": "Inventory out of stock",
+ "Unknown delivery date": "Unknown delivery date",
+ "Awaiting return items": "Awaiting return items",
"Created at": "Created at",
"Checkout id": "Checkout id",
"Customer name": "Customer name",
"Total price": "Total price",
"Relevance (with a query)": "Relevance (with a query)",
"ID": "ID",
+ "Updated at": "Updated at",
"Collection default": "Collection default",
"Created": "Created",
"Processed at": "Processed at",
- "Updated at": "Updated at",
"Order number": "Order number",
+ "Starts at": "Starts at",
+ "Ends at": "Ends at",
"Number": "Number",
+ "Happened at": "Happened at",
"Name": "Name",
"Inventory quantity": "Inventory quantity",
"App (sales channel)": "App (sales channel)",
"Market": "Market",
"Company location (B2B)": "Company location (B2B)",
+ "Only the listed holds": "Only the listed holds",
+ "All holds on the fulfillment order": "All holds on the fulfillment order",
+ "Balance": "Balance",
+ "Initial value": "Initial value",
+ "Amount spent": "Amount spent",
+ "Expires on": "Expires on",
+ "Disabled at": "Disabled at",
"Financial status": "Financial status",
"Fulfillment status": "Fulfillment status",
"Published at": "Published at",
@@ -927,6 +1302,7 @@
"Staff error": "Staff error",
"Refund to the original payment methods": "Refund to the original payment methods",
"Refund as store credit": "Refund as store credit",
+ "None (remove the minimum)": "None (remove the minimum)",
"Kilograms": "Kilograms",
"Grams": "Grams",
"Pounds": "Pounds",
diff --git a/packages/pieces/community/shopify/src/index.ts b/packages/pieces/community/shopify/src/index.ts
index 1633fb9e4e4..057d494f8e7 100644
--- a/packages/pieces/community/shopify/src/index.ts
+++ b/packages/pieces/community/shopify/src/index.ts
@@ -28,9 +28,11 @@ import { updateProductAction } from './lib/actions/update-product';
import { uploadProductImageAction } from './lib/actions/upload-product-image';
import { shopifyAuth, shopifyAuthHelpers } from './lib/common/auth';
import { shopifyAiActivateInventoryAtLocation } from './lib/actions/ai/activate-inventory-at-location';
+import { shopifyAiAddDiscountRedeemCodes } from './lib/actions/ai/add-discount-redeem-codes';
import { shopifyAiAddProductMedia } from './lib/actions/ai/add-product-media';
import { shopifyAiAddProductsToCollection } from './lib/actions/ai/add-products-to-collection';
import { shopifyAiAddTags } from './lib/actions/ai/add-tags';
+import { shopifyAiListDeliveryZones } from './lib/actions/ai/list-delivery-zones';
import { shopifyAiSendPaymentMethodUpdateEmail } from './lib/actions/ai/send-payment-method-update-email';
import { shopifyAiResolveRequestedOrderEdit } from './lib/actions/ai/resolve-requested-order-edit';
import { shopifyAiDeclineRequestedOrderEdit } from './lib/actions/ai/decline-requested-order-edit';
@@ -41,19 +43,30 @@ import { shopifyAiAdjustInventoryQuantities } from './lib/actions/ai/adjust-inve
import { shopifyAiArchiveOrder } from './lib/actions/ai/archive-order';
import { shopifyAiAttachVariantMedia } from './lib/actions/ai/attach-variant-media';
import { shopifyAiCalculateRefund } from './lib/actions/ai/calculate-refund';
+import { shopifyAiCancelFulfillmentOrder } from './lib/actions/ai/cancel-fulfillment-order';
+import { shopifyAiCancelFulfillment } from './lib/actions/ai/cancel-fulfillment';
import { shopifyAiCaptureOrderPayment } from './lib/actions/ai/capture-order-payment';
import { shopifyAiCompleteDraftOrder } from './lib/actions/ai/complete-draft-order';
import { shopifyAiCountAbandonedCheckouts } from './lib/actions/ai/count-abandoned-checkouts';
import { shopifyAiCountCollections } from './lib/actions/ai/count-collections';
import { shopifyAiCountCustomerSegments } from './lib/actions/ai/count-customer-segments';
import { shopifyAiCountCustomers } from './lib/actions/ai/count-customers';
+import { shopifyAiCountDiscountCodes } from './lib/actions/ai/count-discount-codes';
+import { shopifyAiCountDiscounts } from './lib/actions/ai/count-discounts';
import { shopifyAiCountDraftOrders } from './lib/actions/ai/count-draft-orders';
+import { shopifyAiCountGiftCards } from './lib/actions/ai/count-gift-cards';
import { shopifyAiCountLocations } from './lib/actions/ai/count-locations';
import { shopifyAiCountProducts } from './lib/actions/ai/count-products';
+import { shopifyAiCreateBasicDiscountCode } from './lib/actions/ai/create-basic-discount-code';
+import { shopifyAiCreateBxgyDiscountCode } from './lib/actions/ai/create-bxgy-discount-code';
import { shopifyAiCreateCollection } from './lib/actions/ai/create-collection';
import { shopifyAiCreateCustomerAddress } from './lib/actions/ai/create-customer-address';
import { shopifyAiCreateCustomerProfile } from './lib/actions/ai/create-customer-profile';
import { shopifyAiCreateDraftOrderWithLineItems } from './lib/actions/ai/create-draft-order-with-line-items';
+import { shopifyAiCreateFreeShippingDiscountCode } from './lib/actions/ai/create-free-shipping-discount-code';
+import { shopifyAiCreateFulfillmentTrackingEvent } from './lib/actions/ai/create-fulfillment-tracking-event';
+import { shopifyAiCreateFulfillment } from './lib/actions/ai/create-fulfillment';
+import { shopifyAiCreateGiftCard } from './lib/actions/ai/create-gift-card';
import { shopifyAiCreateOrderRiskAssessment } from './lib/actions/ai/create-order-risk-assessment';
import { shopifyAiCreateOrderWithLineItems } from './lib/actions/ai/create-order-with-line-items';
import { shopifyAiCreateProductOptions } from './lib/actions/ai/create-product-options';
@@ -61,11 +74,15 @@ import { shopifyAiCreateProductRecord } from './lib/actions/ai/create-product-re
import { shopifyAiCreateProductVariants } from './lib/actions/ai/create-product-variants';
import { shopifyAiCreateRefund } from './lib/actions/ai/create-refund';
import { shopifyAiCreateSmartCollection } from './lib/actions/ai/create-smart-collection';
+import { shopifyAiDeactivateGiftCard } from './lib/actions/ai/deactivate-gift-card';
import { shopifyAiDeactivateInventoryAtLocation } from './lib/actions/ai/deactivate-inventory-at-location';
import { shopifyAiDeleteCollection } from './lib/actions/ai/delete-collection';
import { shopifyAiDeleteCustomerAddress } from './lib/actions/ai/delete-customer-address';
import { shopifyAiDeleteCustomer } from './lib/actions/ai/delete-customer';
+import { shopifyAiDeleteDiscountRedeemCodes } from './lib/actions/ai/delete-discount-redeem-codes';
+import { shopifyAiDeleteDiscount } from './lib/actions/ai/delete-discount';
import { shopifyAiDeleteDraftOrder } from './lib/actions/ai/delete-draft-order';
+import { shopifyAiDeleteFulfillmentService } from './lib/actions/ai/delete-fulfillment-service';
import { shopifyAiDeleteOrder } from './lib/actions/ai/delete-order';
import { shopifyAiDeleteProductMedia } from './lib/actions/ai/delete-product-media';
import { shopifyAiDeleteProductOptions } from './lib/actions/ai/delete-product-options';
@@ -73,13 +90,19 @@ import { shopifyAiDeleteProductVariants } from './lib/actions/ai/delete-product-
import { shopifyAiDeleteProduct } from './lib/actions/ai/delete-product';
import { shopifyAiDetachVariantMedia } from './lib/actions/ai/detach-variant-media';
import { shopifyAiDuplicateProduct } from './lib/actions/ai/duplicate-product';
+import { shopifyAiFindDiscountByCode } from './lib/actions/ai/find-discount-by-code';
import { shopifyAiGenerateCustomerActivationUrl } from './lib/actions/ai/generate-customer-activation-url';
import { shopifyAiGetAbandonment } from './lib/actions/ai/get-abandonment';
import { shopifyAiGetCheckoutAbandonment } from './lib/actions/ai/get-checkout-abandonment';
import { shopifyAiGetCollectionByHandle } from './lib/actions/ai/get-collection-by-handle';
import { shopifyAiGetCollection } from './lib/actions/ai/get-collection';
import { shopifyAiGetCustomerProfile } from './lib/actions/ai/get-customer-profile';
+import { shopifyAiGetDiscountRedeemCodeBulkCreation } from './lib/actions/ai/get-discount-redeem-code-bulk-creation';
+import { shopifyAiGetDiscount } from './lib/actions/ai/get-discount';
import { shopifyAiGetDraftOrder } from './lib/actions/ai/get-draft-order';
+import { shopifyAiGetFulfillmentDetails } from './lib/actions/ai/get-fulfillment-details';
+import { shopifyAiGetFulfillmentOrder } from './lib/actions/ai/get-fulfillment-order';
+import { shopifyAiGetGiftCard } from './lib/actions/ai/get-gift-card';
import { shopifyAiGetGrantedAccessScopes } from './lib/actions/ai/get-granted-access-scopes';
import { shopifyAiGetInventoryItem } from './lib/actions/ai/get-inventory-item';
import { shopifyAiGetJob } from './lib/actions/ai/get-job';
@@ -94,14 +117,24 @@ import { shopifyAiGetProductVariantDetails } from './lib/actions/ai/get-product-
import { shopifyAiGetPublication } from './lib/actions/ai/get-publication';
import { shopifyAiGetRefund } from './lib/actions/ai/get-refund';
import { shopifyAiGetShop } from './lib/actions/ai/get-shop';
+import { shopifyAiHoldFulfillmentOrder } from './lib/actions/ai/hold-fulfillment-order';
import { shopifyAiListAbandonedCheckouts } from './lib/actions/ai/list-abandoned-checkouts';
+import { shopifyAiListCarrierServices } from './lib/actions/ai/list-carrier-services';
import { shopifyAiListCollectionProducts } from './lib/actions/ai/list-collection-products';
import { shopifyAiListCustomerAddresses } from './lib/actions/ai/list-customer-addresses';
import { shopifyAiListCustomerOrders } from './lib/actions/ai/list-customer-orders';
+import { shopifyAiListDeliveryProfiles } from './lib/actions/ai/list-delivery-profiles';
+import { shopifyAiListDiscountRedeemCodes } from './lib/actions/ai/list-discount-redeem-codes';
+import { shopifyAiListDiscounts } from './lib/actions/ai/list-discounts';
import { shopifyAiListDraftOrders } from './lib/actions/ai/list-draft-orders';
+import { shopifyAiListFulfillmentEvents } from './lib/actions/ai/list-fulfillment-events';
+import { shopifyAiListFulfillmentOrderMoveLocations } from './lib/actions/ai/list-fulfillment-order-move-locations';
+import { shopifyAiListFulfillmentServices } from './lib/actions/ai/list-fulfillment-services';
import { shopifyAiListInventoryItems } from './lib/actions/ai/list-inventory-items';
import { shopifyAiListInventoryLevels } from './lib/actions/ai/list-inventory-levels';
import { shopifyAiListLocations } from './lib/actions/ai/list-locations';
+import { shopifyAiListOrderFulfillmentOrders } from './lib/actions/ai/list-order-fulfillment-orders';
+import { shopifyAiListOrderFulfillments } from './lib/actions/ai/list-order-fulfillments';
import { shopifyAiListOrderRefunds } from './lib/actions/ai/list-order-refunds';
import { shopifyAiListOrderTransactions } from './lib/actions/ai/list-order-transactions';
import { shopifyAiListProductMedia } from './lib/actions/ai/list-product-media';
@@ -110,7 +143,9 @@ import { shopifyAiListPublications } from './lib/actions/ai/list-publications';
import { shopifyAiListSalesChannels } from './lib/actions/ai/list-sales-channels';
import { shopifyAiListTenderTransactions } from './lib/actions/ai/list-tender-transactions';
import { shopifyAiMarkOrderAsPaid } from './lib/actions/ai/mark-order-as-paid';
+import { shopifyAiMoveFulfillmentOrder } from './lib/actions/ai/move-fulfillment-order';
import { shopifyAiPublishResource } from './lib/actions/ai/publish-resource';
+import { shopifyAiReleaseFulfillmentOrderHold } from './lib/actions/ai/release-fulfillment-order-hold';
import { shopifyAiRemoveProductsFromCollection } from './lib/actions/ai/remove-products-from-collection';
import { shopifyAiRemoveTags } from './lib/actions/ai/remove-tags';
import { shopifyAiReorderCollectionProducts } from './lib/actions/ai/reorder-collection-products';
@@ -119,21 +154,27 @@ import { shopifyAiReorderProductOptions } from './lib/actions/ai/reorder-product
import { shopifyAiReorderProductVariants } from './lib/actions/ai/reorder-product-variants';
import { shopifyAiSearchCollections } from './lib/actions/ai/search-collections';
import { shopifyAiSearchCustomers } from './lib/actions/ai/search-customers';
+import { shopifyAiSearchGiftCards } from './lib/actions/ai/search-gift-cards';
import { shopifyAiSearchOrders } from './lib/actions/ai/search-orders';
import { shopifyAiSearchProductTaxonomy } from './lib/actions/ai/search-product-taxonomy';
import { shopifyAiSearchProducts } from './lib/actions/ai/search-products';
import { shopifyAiSendCustomerAccountInvite } from './lib/actions/ai/send-customer-account-invite';
import { shopifyAiSendDraftOrderInvoice } from './lib/actions/ai/send-draft-order-invoice';
import { shopifyAiSetDefaultCustomerAddress } from './lib/actions/ai/set-default-customer-address';
+import { shopifyAiSetFulfillmentOrdersDeadline } from './lib/actions/ai/set-fulfillment-orders-deadline';
import { shopifyAiSetInventoryQuantities } from './lib/actions/ai/set-inventory-quantities';
import { shopifyAiSetProduct } from './lib/actions/ai/set-product';
import { shopifyAiStartOrderCancellation } from './lib/actions/ai/start-order-cancellation';
import { shopifyAiUnarchiveOrder } from './lib/actions/ai/unarchive-order';
import { shopifyAiUnpublishResource } from './lib/actions/ai/unpublish-resource';
+import { shopifyAiUpdateBasicDiscountCode } from './lib/actions/ai/update-basic-discount-code';
import { shopifyAiUpdateCollection } from './lib/actions/ai/update-collection';
import { shopifyAiUpdateCustomerAddress } from './lib/actions/ai/update-customer-address';
import { shopifyAiUpdateCustomerProfile } from './lib/actions/ai/update-customer-profile';
import { shopifyAiUpdateDraftOrder } from './lib/actions/ai/update-draft-order';
+import { shopifyAiUpdateFreeShippingDiscountCode } from './lib/actions/ai/update-free-shipping-discount-code';
+import { shopifyAiUpdateFulfillmentTracking } from './lib/actions/ai/update-fulfillment-tracking';
+import { shopifyAiUpdateGiftCard } from './lib/actions/ai/update-gift-card';
import { shopifyAiUpdateInventoryItem } from './lib/actions/ai/update-inventory-item';
import { shopifyAiUpdateOrderDetails } from './lib/actions/ai/update-order-details';
import { shopifyAiUpdateProductFields } from './lib/actions/ai/update-product-fields';
@@ -186,9 +227,11 @@ export const shopify = createPiece({
updateProductAction,
uploadProductImageAction,
shopifyAiActivateInventoryAtLocation,
+ shopifyAiAddDiscountRedeemCodes,
shopifyAiAddProductMedia,
shopifyAiAddProductsToCollection,
shopifyAiAddTags,
+ shopifyAiListDeliveryZones,
shopifyAiSendPaymentMethodUpdateEmail,
shopifyAiResolveRequestedOrderEdit,
shopifyAiDeclineRequestedOrderEdit,
@@ -199,19 +242,30 @@ export const shopify = createPiece({
shopifyAiArchiveOrder,
shopifyAiAttachVariantMedia,
shopifyAiCalculateRefund,
+ shopifyAiCancelFulfillmentOrder,
+ shopifyAiCancelFulfillment,
shopifyAiCaptureOrderPayment,
shopifyAiCompleteDraftOrder,
shopifyAiCountAbandonedCheckouts,
shopifyAiCountCollections,
shopifyAiCountCustomerSegments,
shopifyAiCountCustomers,
+ shopifyAiCountDiscountCodes,
+ shopifyAiCountDiscounts,
shopifyAiCountDraftOrders,
+ shopifyAiCountGiftCards,
shopifyAiCountLocations,
shopifyAiCountProducts,
+ shopifyAiCreateBasicDiscountCode,
+ shopifyAiCreateBxgyDiscountCode,
shopifyAiCreateCollection,
shopifyAiCreateCustomerAddress,
shopifyAiCreateCustomerProfile,
shopifyAiCreateDraftOrderWithLineItems,
+ shopifyAiCreateFreeShippingDiscountCode,
+ shopifyAiCreateFulfillmentTrackingEvent,
+ shopifyAiCreateFulfillment,
+ shopifyAiCreateGiftCard,
shopifyAiCreateOrderRiskAssessment,
shopifyAiCreateOrderWithLineItems,
shopifyAiCreateProductOptions,
@@ -219,11 +273,15 @@ export const shopify = createPiece({
shopifyAiCreateProductVariants,
shopifyAiCreateRefund,
shopifyAiCreateSmartCollection,
+ shopifyAiDeactivateGiftCard,
shopifyAiDeactivateInventoryAtLocation,
shopifyAiDeleteCollection,
shopifyAiDeleteCustomerAddress,
shopifyAiDeleteCustomer,
+ shopifyAiDeleteDiscountRedeemCodes,
+ shopifyAiDeleteDiscount,
shopifyAiDeleteDraftOrder,
+ shopifyAiDeleteFulfillmentService,
shopifyAiDeleteOrder,
shopifyAiDeleteProductMedia,
shopifyAiDeleteProductOptions,
@@ -231,13 +289,19 @@ export const shopify = createPiece({
shopifyAiDeleteProduct,
shopifyAiDetachVariantMedia,
shopifyAiDuplicateProduct,
+ shopifyAiFindDiscountByCode,
shopifyAiGenerateCustomerActivationUrl,
shopifyAiGetAbandonment,
shopifyAiGetCheckoutAbandonment,
shopifyAiGetCollectionByHandle,
shopifyAiGetCollection,
shopifyAiGetCustomerProfile,
+ shopifyAiGetDiscountRedeemCodeBulkCreation,
+ shopifyAiGetDiscount,
shopifyAiGetDraftOrder,
+ shopifyAiGetFulfillmentDetails,
+ shopifyAiGetFulfillmentOrder,
+ shopifyAiGetGiftCard,
shopifyAiGetGrantedAccessScopes,
shopifyAiGetInventoryItem,
shopifyAiGetJob,
@@ -252,14 +316,24 @@ export const shopify = createPiece({
shopifyAiGetPublication,
shopifyAiGetRefund,
shopifyAiGetShop,
+ shopifyAiHoldFulfillmentOrder,
shopifyAiListAbandonedCheckouts,
+ shopifyAiListCarrierServices,
shopifyAiListCollectionProducts,
shopifyAiListCustomerAddresses,
shopifyAiListCustomerOrders,
+ shopifyAiListDeliveryProfiles,
+ shopifyAiListDiscountRedeemCodes,
+ shopifyAiListDiscounts,
shopifyAiListDraftOrders,
+ shopifyAiListFulfillmentEvents,
+ shopifyAiListFulfillmentOrderMoveLocations,
+ shopifyAiListFulfillmentServices,
shopifyAiListInventoryItems,
shopifyAiListInventoryLevels,
shopifyAiListLocations,
+ shopifyAiListOrderFulfillmentOrders,
+ shopifyAiListOrderFulfillments,
shopifyAiListOrderRefunds,
shopifyAiListOrderTransactions,
shopifyAiListProductMedia,
@@ -268,7 +342,9 @@ export const shopify = createPiece({
shopifyAiListSalesChannels,
shopifyAiListTenderTransactions,
shopifyAiMarkOrderAsPaid,
+ shopifyAiMoveFulfillmentOrder,
shopifyAiPublishResource,
+ shopifyAiReleaseFulfillmentOrderHold,
shopifyAiRemoveProductsFromCollection,
shopifyAiRemoveTags,
shopifyAiReorderCollectionProducts,
@@ -277,21 +353,27 @@ export const shopify = createPiece({
shopifyAiReorderProductVariants,
shopifyAiSearchCollections,
shopifyAiSearchCustomers,
+ shopifyAiSearchGiftCards,
shopifyAiSearchOrders,
shopifyAiSearchProductTaxonomy,
shopifyAiSearchProducts,
shopifyAiSendCustomerAccountInvite,
shopifyAiSendDraftOrderInvoice,
shopifyAiSetDefaultCustomerAddress,
+ shopifyAiSetFulfillmentOrdersDeadline,
shopifyAiSetInventoryQuantities,
shopifyAiSetProduct,
shopifyAiStartOrderCancellation,
shopifyAiUnarchiveOrder,
shopifyAiUnpublishResource,
+ shopifyAiUpdateBasicDiscountCode,
shopifyAiUpdateCollection,
shopifyAiUpdateCustomerAddress,
shopifyAiUpdateCustomerProfile,
shopifyAiUpdateDraftOrder,
+ shopifyAiUpdateFreeShippingDiscountCode,
+ shopifyAiUpdateFulfillmentTracking,
+ shopifyAiUpdateGiftCard,
shopifyAiUpdateInventoryItem,
shopifyAiUpdateOrderDetails,
shopifyAiUpdateProductFields,
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/add-discount-redeem-codes.ts b/packages/pieces/community/shopify/src/lib/actions/ai/add-discount-redeem-codes.ts
new file mode 100644
index 00000000000..d2855e9b51f
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/add-discount-redeem-codes.ts
@@ -0,0 +1,63 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlDiscountRedeemCodeBulkCreation,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyValues,
+} from '../../common/graphql';
+import { addDiscountRedeemCodesOutputSchema } from '../../output-schemas/fulfillment';
+
+export const shopifyAiAddDiscountRedeemCodes = createAction({
+ auth: shopifyAuth,
+ name: 'add_discount_redeem_codes',
+ classification: 'WRITE',
+ displayName: 'Start Adding Discount Redeem Codes',
+ description: 'Start adding up to 250 new redeem codes to a code discount (runs in the background).',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Starts adding up to 250 new redeem codes to one existing code discount, for example unique codes for an email campaign. Shopify imports them in the background and returns only a bulk creation: poll get_discount_redeem_code_bulk_creation with bulk_creation_id until done is true, then read imported_count, failed_count and the per-code errors (for example a code that already exists). Every call starts another import. Takes the code discount id (gid://shopify/DiscountCodeNode/… or its plain number). Needs the write_discounts access scope.',
+ idempotent: false,
+ },
+ outputSchema: addDiscountRedeemCodesOutputSchema,
+ props: {
+ discount_id: Property.ShortText({
+ displayName: 'Discount ID',
+ description:
+ 'The code discount id, for example "gid://shopify/DiscountCodeNode/123" or "123". Get it from list_discounts or find_discount_by_code.',
+ required: true,
+ }),
+ codes: Property.Array({
+ displayName: 'Codes',
+ description: 'The new codes, 1 to 250, for example "WELCOME-A1B2". Duplicates in the list are sent once.',
+ required: true,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const discountId = shopifyValues.toDiscountCodeNodeId(propsValue.discount_id);
+ const codes = [...new Set(shopifyValues.readStringList(propsValue.codes) ?? [])];
+ if (codes.length === 0) {
+ throw new Error('Provide at least one code. Nothing was started.');
+ }
+ if (codes.length > shopifyFields.MAX_REDEEM_CODES_PER_CALL) {
+ throw new Error(
+ `Shopify accepts at most ${shopifyFields.MAX_REDEEM_CODES_PER_CALL} codes per call; got ${codes.length}. Split them over several calls. Nothing was started.`
+ );
+ }
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ discountRedeemCodeBulkAdd: { bulkCreation: GqlDiscountRedeemCodeBulkCreation | null } | null;
+ }>({
+ auth,
+ query: `mutation AddDiscountRedeemCodes($discountId: ID!, $codes: [DiscountRedeemCodeInput!]!) { discountRedeemCodeBulkAdd(discountId: $discountId, codes: $codes) { bulkCreation { id done codesCount importedCount failedCount createdAt discountCode { id } } userErrors { field message code } } }`,
+ variables: { discountId, codes: codes.map((code) => ({ code })) },
+ });
+ return {
+ ...shopifyMappers.mapDiscountBulkCreation(data.discountRedeemCodeBulkAdd?.bulkCreation),
+ discount_id: discountId,
+ codes_sent: codes.length,
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/cancel-fulfillment-order.ts b/packages/pieces/community/shopify/src/lib/actions/ai/cancel-fulfillment-order.ts
new file mode 100644
index 00000000000..2557b18b1f2
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/cancel-fulfillment-order.ts
@@ -0,0 +1,51 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlFulfillmentOrder,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+} from '../../common/graphql';
+import { cancelFulfillmentOrderOutputSchema } from '../../output-schemas/fulfillment';
+
+export const shopifyAiCancelFulfillmentOrder = createAction({
+ auth: shopifyAuth,
+ name: 'cancel_fulfillment_order',
+ classification: 'DESTRUCTIVE',
+ displayName: 'Cancel Fulfillment Order',
+ description: 'Cancel a fulfillment order that was sent to a fulfillment service; a replacement is created.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Cancels one fulfillment order and closes it; Shopify creates replacement_fulfillment_order for the work still to be done. Works only when the fulfillment order was sent to a fulfillment service and its request_status is SUBMITTED (cancelled at once) or CANCELLATION_REQUESTED; for other states Shopify returns an error. A service that already accepted the request may still ship. This does not cancel the order itself (use start_order_cancellation for that). Cannot be undone; a repeat call fails because the fulfillment order is closed. Needs the write_merchant_managed_fulfillment_orders access scope.',
+ idempotent: false,
+ },
+ outputSchema: cancelFulfillmentOrderOutputSchema,
+ props: {
+ fulfillment_order_id: Property.ShortText({
+ displayName: 'Fulfillment Order ID',
+ description:
+ 'The fulfillment order to cancel, numeric or "gid://shopify/FulfillmentOrder/…". Find it with list_order_fulfillment_orders.',
+ required: true,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyGraphqlClient.toGid({ type: 'FulfillmentOrder', id: propsValue.fulfillment_order_id });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ fulfillmentOrderCancel: {
+ fulfillmentOrder: GqlFulfillmentOrder | null;
+ replacementFulfillmentOrder: GqlFulfillmentOrder | null;
+ } | null;
+ }>({
+ auth,
+ query: `mutation CancelFulfillmentOrder($id: ID!) { fulfillmentOrderCancel(id: $id) { fulfillmentOrder { ${shopifyFields.FULFILLMENT_ORDER_FIELDS} } replacementFulfillmentOrder { ${shopifyFields.FULFILLMENT_ORDER_FIELDS} } userErrors { field message } } }`,
+ variables: { id },
+ });
+ const payload = data.fulfillmentOrderCancel;
+ return {
+ fulfillment_order: shopifyMappers.mapFulfillmentOrderOrNull(payload?.fulfillmentOrder),
+ replacement_fulfillment_order: shopifyMappers.mapFulfillmentOrderOrNull(payload?.replacementFulfillmentOrder),
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/cancel-fulfillment.ts b/packages/pieces/community/shopify/src/lib/actions/ai/cancel-fulfillment.ts
new file mode 100644
index 00000000000..09356326514
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/cancel-fulfillment.ts
@@ -0,0 +1,50 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlFulfillment,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+} from '../../common/graphql';
+import { fulfillmentSummaryOutputSchema } from '../../output-schemas/fulfillment';
+
+export const shopifyAiCancelFulfillment = createAction({
+ auth: shopifyAuth,
+ name: 'cancel_fulfillment',
+ classification: 'DESTRUCTIVE',
+ displayName: 'Cancel Fulfillment',
+ description: 'Cancel a fulfillment so its items become unfulfilled again.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Cancels one fulfillment (a shipment already recorded) and returns it with status CANCELLED. Shopify reverses it on the fulfillment orders: the cancelled items get new fulfillment orders so they can be fulfilled again (at the original location when still stocked there, otherwise by the store\'s fulfillment priority). Tracking on the cancelled fulfillment stops being shown to the customer. Cannot be undone; a repeat call fails because the fulfillment is already cancelled. The required access scope is not documented for this mutation (write_merchant_managed_fulfillment_orders is expected).',
+ idempotent: false,
+ },
+ outputSchema: fulfillmentSummaryOutputSchema,
+ props: {
+ fulfillment_id: Property.ShortText({
+ displayName: 'Fulfillment ID',
+ description:
+ 'The fulfillment to cancel, numeric or "gid://shopify/Fulfillment/…". Find it with list_order_fulfillments.',
+ required: true,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyGraphqlClient.toGid({ type: 'Fulfillment', id: propsValue.fulfillment_id });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ fulfillmentCancel: { fulfillment: GqlFulfillment | null } | null;
+ }>({
+ auth,
+ query: `mutation CancelFulfillment($id: ID!) { fulfillmentCancel(id: $id) { fulfillment { ${shopifyFields.FULFILLMENT_SUMMARY_FIELDS} } userErrors { field message } } }`,
+ variables: { id },
+ });
+ const fulfillment = data.fulfillmentCancel?.fulfillment;
+ if (!fulfillment) {
+ throw new Error('Shopify did not return the cancelled fulfillment.');
+ }
+ return {
+ ...shopifyMappers.mapFulfillmentSummary(fulfillment),
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/count-discount-codes.ts b/packages/pieces/community/shopify/src/lib/actions/ai/count-discount-codes.ts
new file mode 100644
index 00000000000..79ba2843845
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/count-discount-codes.ts
@@ -0,0 +1,43 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlCount,
+ shopifyGraphqlClient,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { discountCountOutputSchema } from '../../output-schemas/fulfillment';
+
+export const shopifyAiCountDiscountCodes = createAction({
+ auth: shopifyAuth,
+ name: 'count_discount_codes',
+ classification: 'READ',
+ displayName: 'Count Discount Codes',
+ description: 'Count the redeem codes across the store\'s code discounts, optionally filtered.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Counts redeem codes (the strings customers type) across all code discounts, optionally filtered with search syntax such as "times_used:0". One code discount can hold many codes, so this differs from count_discounts. Shopify stops counting at 10,000 by default; precision is AT_LEAST when it did. Needs the read_discounts access scope. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: discountCountOutputSchema,
+ props: {
+ query: shopifyProps.searchQuery(
+ 'Optional Shopify search syntax on the codes, for example "times_used:0". Leave empty to count all.'
+ ),
+ },
+ async run({ auth, propsValue }) {
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ discountCodesCount: GqlCount | null;
+ }>({
+ auth,
+ query: `query CountDiscountCodes($query: String) { discountCodesCount(query: $query) { count precision } }`,
+ variables: { query: shopifyValues.nonEmpty(propsValue.query) },
+ });
+ return {
+ count: data.discountCodesCount?.count ?? 0,
+ precision: data.discountCodesCount?.precision ?? null,
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/count-discounts.ts b/packages/pieces/community/shopify/src/lib/actions/ai/count-discounts.ts
new file mode 100644
index 00000000000..737d276cda8
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/count-discounts.ts
@@ -0,0 +1,43 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlCount,
+ shopifyGraphqlClient,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { discountCountOutputSchema } from '../../output-schemas/fulfillment';
+
+export const shopifyAiCountDiscounts = createAction({
+ auth: shopifyAuth,
+ name: 'count_discounts',
+ classification: 'READ',
+ displayName: 'Count Discounts',
+ description: 'Count discounts (code and automatic), optionally filtered.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Counts the store\'s discounts, code and automatic, optionally filtered with search syntax such as "status:active" or "method:automatic". This counts discounts, not redeem codes (use count_discount_codes for codes). Shopify stops counting at 10,000 by default; precision is AT_LEAST when it did. Needs the read_discounts access scope. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: discountCountOutputSchema,
+ props: {
+ query: shopifyProps.searchQuery(
+ 'Shopify discount search syntax, for example "status:active method:code". Leave empty to count all.'
+ ),
+ },
+ async run({ auth, propsValue }) {
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ discountNodesCount: GqlCount | null;
+ }>({
+ auth,
+ query: `query CountDiscounts($query: String) { discountNodesCount(query: $query) { count precision } }`,
+ variables: { query: shopifyValues.nonEmpty(propsValue.query) },
+ });
+ return {
+ count: data.discountNodesCount?.count ?? 0,
+ precision: data.discountNodesCount?.precision ?? null,
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/count-gift-cards.ts b/packages/pieces/community/shopify/src/lib/actions/ai/count-gift-cards.ts
new file mode 100644
index 00000000000..9b7537473d8
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/count-gift-cards.ts
@@ -0,0 +1,43 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlCount,
+ shopifyGraphqlClient,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { giftCardCountOutputSchema } from '../../output-schemas/fulfillment';
+
+export const shopifyAiCountGiftCards = createAction({
+ auth: shopifyAuth,
+ name: 'count_gift_cards',
+ classification: 'READ',
+ displayName: 'Count Gift Cards',
+ description: 'Count gift cards, optionally filtered.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Counts the store\'s gift cards (enabled, disabled and fully redeemed alike), optionally filtered with search syntax such as "status:enabled". Shopify stops counting at 10,000 by default; precision is AT_LEAST when it did. Use search_gift_cards to see them. Needs the read_gift_cards access scope. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: giftCardCountOutputSchema,
+ props: {
+ query: shopifyProps.searchQuery(
+ 'Shopify gift card search syntax, for example "status:enabled". Leave empty to count all.'
+ ),
+ },
+ async run({ auth, propsValue }) {
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ giftCardsCount: GqlCount | null;
+ }>({
+ auth,
+ query: `query CountGiftCards($query: String) { giftCardsCount(query: $query) { count precision } }`,
+ variables: { query: shopifyValues.nonEmpty(propsValue.query) },
+ });
+ return {
+ count: data.giftCardsCount?.count ?? 0,
+ precision: data.giftCardsCount?.precision ?? null,
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/create-basic-discount-code.ts b/packages/pieces/community/shopify/src/lib/actions/ai/create-basic-discount-code.ts
new file mode 100644
index 00000000000..1cfbe14d169
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/create-basic-discount-code.ts
@@ -0,0 +1,236 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlDiscountNode,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { discountOutputSchema } from '../../output-schemas/fulfillment';
+
+export const shopifyAiCreateBasicDiscountCode = createAction({
+ auth: shopifyAuth,
+ name: 'create_basic_discount_code',
+ classification: 'WRITE',
+ displayName: 'Create Amount-Off Discount Code',
+ description: 'Create a percentage or fixed-amount discount that customers apply with a code.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Creates an amount-off discount code (percentage or fixed amount) and returns it with its id (gid://shopify/DiscountCodeNode/…). value_type PERCENTAGE takes the percent as a number (15 means 15% off); FIXED_AMOUNT takes an amount in the shop currency. applies_to decides what it discounts: ALL items, specific PRODUCTS (product or variant ids) or COLLECTIONS; left unset it follows the ids given, and is ALL only when no ids are given. eligibility decides who can use it: ALL buyers, specific CUSTOMERS or customer SEGMENTS; left unset it follows the ids given, and is ALL only when no ids are given. Optional minimum subtotal or quantity, usage limit, once per customer, end date, tags and which other discount classes it combines with (all off by default). starts_at defaults to now, so the code is live immediately unless a later start is given. Each call creates another discount; a code that already exists is rejected by Shopify. Needs the write_discounts access scope.',
+ idempotent: false,
+ },
+ outputSchema: discountOutputSchema,
+ props: {
+ title: Property.ShortText({
+ displayName: 'Title',
+ description: 'Internal title shown in the admin, for example "Spring sale 15%".',
+ required: true,
+ }),
+ code: Property.ShortText({
+ displayName: 'Code',
+ description: 'The code customers enter at checkout, for example "SPRING15".',
+ required: true,
+ }),
+ value_type: Property.StaticDropdown({
+ displayName: 'Value Type',
+ description: 'Percentage off or a fixed amount off.',
+ required: true,
+ options: {
+ options: [
+ { label: 'Percentage', value: 'PERCENTAGE' },
+ { label: 'Fixed amount', value: 'FIXED_AMOUNT' },
+ ],
+ },
+ }),
+ value: Property.Number({
+ displayName: 'Value',
+ description: 'For PERCENTAGE the percent, 15 means 15% off (above 0, at most 100). For FIXED_AMOUNT the amount in the shop currency, for example 10.',
+ required: true,
+ }),
+ applies_on_each_item: shopifyProps.booleanChoice({
+ displayName: 'Apply Amount To Each Item',
+ description: 'FIXED_AMOUNT only: Yes takes the amount off every eligible item, No takes it off once per order. Leave unset for Shopify\'s default.',
+ }),
+ applies_to: Property.StaticDropdown({
+ displayName: 'Applies To',
+ description: 'What the discount applies to. Leave unset to infer it from the ids: PRODUCTS when product_ids or variant_ids are given, COLLECTIONS when collection_ids are given, ALL items when no ids are given.',
+ required: false,
+ options: {
+ options: [
+ { label: 'All items', value: 'ALL' },
+ { label: 'Specific products or variants', value: 'PRODUCTS' },
+ { label: 'Specific collections', value: 'COLLECTIONS' },
+ ],
+ },
+ }),
+ product_ids: shopifyProps.idList({
+ displayName: 'Product IDs',
+ description: 'With applies_to PRODUCTS: product ids, numeric or "gid://shopify/Product/…".',
+ }),
+ variant_ids: shopifyProps.idList({
+ displayName: 'Variant IDs',
+ description: 'With applies_to PRODUCTS: variant ids, numeric or "gid://shopify/ProductVariant/…".',
+ }),
+ collection_ids: shopifyProps.idList({
+ displayName: 'Collection IDs',
+ description: 'With applies_to COLLECTIONS: collection ids, numeric or "gid://shopify/Collection/…".',
+ }),
+ eligibility: Property.StaticDropdown({
+ displayName: 'Eligibility',
+ description: 'Who can use the code. Leave unset to infer it from the ids: CUSTOMERS when customer_ids are given, SEGMENTS when segment_ids are given, ALL buyers when no ids are given.',
+ required: false,
+ options: {
+ options: [
+ { label: 'All buyers', value: 'ALL' },
+ { label: 'Specific customers', value: 'CUSTOMERS' },
+ { label: 'Customer segments', value: 'SEGMENTS' },
+ ],
+ },
+ }),
+ customer_ids: shopifyProps.idList({
+ displayName: 'Customer IDs',
+ description: 'With eligibility CUSTOMERS: customer ids, numeric or "gid://shopify/Customer/…".',
+ }),
+ segment_ids: shopifyProps.idList({
+ displayName: 'Segment IDs',
+ description: 'With eligibility SEGMENTS: customer segment ids, numeric or "gid://shopify/Segment/…".',
+ }),
+ minimum_requirement: Property.StaticDropdown({
+ displayName: 'Minimum Requirement',
+ description: 'Optional minimum the cart must reach. Leave unset for none.',
+ required: false,
+ options: {
+ options: [
+ { label: 'Minimum subtotal', value: 'SUBTOTAL' },
+ { label: 'Minimum quantity of items', value: 'QUANTITY' },
+ ],
+ },
+ }),
+ minimum_value: Property.Number({
+ displayName: 'Minimum Value',
+ description: 'With a minimum requirement: the subtotal (for example 50) or the whole-number item quantity (for example 3).',
+ required: false,
+ }),
+ starts_at: Property.DateTime({
+ displayName: 'Starts At',
+ description: 'When the code becomes usable, ISO 8601. Defaults to now.',
+ required: false,
+ }),
+ ends_at: Property.DateTime({
+ displayName: 'Ends At',
+ description: 'Optional end, ISO 8601. Leave empty for no end date.',
+ required: false,
+ }),
+ usage_limit: Property.Number({
+ displayName: 'Usage Limit',
+ description: 'Optional total number of times the code can be used across all customers.',
+ required: false,
+ }),
+ applies_once_per_customer: Property.Checkbox({
+ displayName: 'Once Per Customer',
+ description: 'Each customer can use the code only once. Off by default.',
+ required: false,
+ defaultValue: false,
+ }),
+ combines_with_product_discounts: Property.Checkbox({
+ displayName: 'Combines With Product Discounts',
+ description: 'Can be combined with other product discounts. Off by default.',
+ required: false,
+ defaultValue: false,
+ }),
+ combines_with_order_discounts: Property.Checkbox({
+ displayName: 'Combines With Order Discounts',
+ description: 'Can be combined with order discounts. Off by default.',
+ required: false,
+ defaultValue: false,
+ }),
+ combines_with_shipping_discounts: Property.Checkbox({
+ displayName: 'Combines With Shipping Discounts',
+ description: 'Can be combined with shipping discounts. Off by default.',
+ required: false,
+ defaultValue: false,
+ }),
+ tags: Property.Array({
+ displayName: 'Tags',
+ description: 'Optional tags for the discount, for example "spring".',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const title = shopifyValues.nonEmpty(propsValue.title);
+ const code = shopifyValues.nonEmpty(propsValue.code);
+ if (!title || !code) {
+ throw new Error('Provide both title and code. Nothing was created.');
+ }
+ const basicCodeDiscount = shopifyValues.compact({
+ title,
+ code,
+ startsAt: shopifyValues.nonEmpty(propsValue.starts_at) ?? new Date().toISOString(),
+ endsAt: shopifyValues.nonEmpty(propsValue.ends_at),
+ customerGets: {
+ value: shopifyValues.buildDiscountValue({
+ valueType: propsValue.value_type,
+ value: propsValue.value,
+ appliesOnEachItem: shopifyValues.toBooleanChoice(propsValue.applies_on_each_item),
+ }),
+ items: shopifyValues.buildDiscountItems({
+ appliesTo: propsValue.applies_to,
+ productIdsToAdd: propsValue.product_ids,
+ productIdsToRemove: undefined,
+ variantIdsToAdd: propsValue.variant_ids,
+ variantIdsToRemove: undefined,
+ collectionIdsToAdd: propsValue.collection_ids,
+ collectionIdsToRemove: undefined,
+ }) ?? { all: true },
+ },
+ context: shopifyValues.buildDiscountContext({
+ eligibility: propsValue.eligibility,
+ customerIdsToAdd: propsValue.customer_ids,
+ customerIdsToRemove: undefined,
+ segmentIdsToAdd: propsValue.segment_ids,
+ segmentIdsToRemove: undefined,
+ }) ?? { all: 'ALL' },
+ minimumRequirement: shopifyValues.buildMinimumRequirement({
+ kind: propsValue.minimum_requirement,
+ value: shopifyValues.readNumber(propsValue.minimum_value),
+ }),
+ usageLimit: readUsageLimit(propsValue.usage_limit),
+ appliesOncePerCustomer: propsValue.applies_once_per_customer ?? false,
+ combinesWith: shopifyValues.buildCombinesWith({
+ productDiscounts: propsValue.combines_with_product_discounts ?? false,
+ orderDiscounts: propsValue.combines_with_order_discounts ?? false,
+ shippingDiscounts: propsValue.combines_with_shipping_discounts ?? false,
+ }),
+ tags: shopifyValues.nonEmptyList(propsValue.tags),
+ });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ discountCodeBasicCreate: { codeDiscountNode: GqlDiscountNode | null } | null;
+ }>({
+ auth,
+ query: `mutation CreateBasicDiscountCode($basicCodeDiscount: DiscountCodeBasicInput!) { discountCodeBasicCreate(basicCodeDiscount: $basicCodeDiscount) { codeDiscountNode { id discount: codeDiscount { ${shopifyFields.CODE_DISCOUNT_DETAIL_FIELDS} } } userErrors { field message code } } }`,
+ variables: { basicCodeDiscount },
+ });
+ const node = data.discountCodeBasicCreate?.codeDiscountNode;
+ if (!node) {
+ throw new Error('Shopify did not return the new discount.');
+ }
+ return {
+ ...shopifyMappers.mapDiscountNode(node),
+ redacted_fields: redactedFields,
+ };
+ },
+});
+
+function readUsageLimit(value: number | undefined | null): number | undefined {
+ const limit = shopifyValues.readNumber(value);
+ if (limit === undefined) {
+ return undefined;
+ }
+ if (!Number.isInteger(limit) || limit < 1) {
+ throw new Error('usage_limit must be a whole number of 1 or more. Nothing was changed.');
+ }
+ return limit;
+}
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/create-bxgy-discount-code.ts b/packages/pieces/community/shopify/src/lib/actions/ai/create-bxgy-discount-code.ts
new file mode 100644
index 00000000000..8686a824be8
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/create-bxgy-discount-code.ts
@@ -0,0 +1,297 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlDiscountNode,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { discountOutputSchema } from '../../output-schemas/fulfillment';
+
+export const shopifyAiCreateBxgyDiscountCode = createAction({
+ auth: shopifyAuth,
+ name: 'create_bxgy_discount_code',
+ classification: 'WRITE',
+ displayName: 'Create Buy X Get Y Discount Code',
+ description: 'Create a "buy X, get Y" discount that customers apply with a code.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Creates a Buy X Get Y discount code and returns it with its id (gid://shopify/DiscountCodeNode/…). What the customer must buy: buys_type QUANTITY (buys_value is a whole number of items) or AMOUNT (buys_value is a spend in the shop currency), from specific products or variants (buys_product_ids / buys_variant_ids) or collections (buys_collection_ids). What the customer gets: gets_quantity items from gets_product_ids / gets_variant_ids or gets_collection_ids, discounted by gets_percentage (100 means free, the default; 50 means half price). Products and collections cannot be mixed on one side, and each side needs at least one id because Buy X Get Y cannot apply to all items. uses_per_order_limit caps how many times the offer applies in one order. eligibility decides who can use it: ALL buyers, specific CUSTOMERS or customer SEGMENTS; left unset it follows the ids given, and is ALL only when no ids are given. Optional usage limit, once per customer, end date, tags and which other discount classes it combines with (all off by default). starts_at defaults to now, so the code is live immediately unless a later start is given. Each call creates another discount; a code that already exists is rejected by Shopify. Needs the write_discounts access scope.',
+ idempotent: false,
+ },
+ outputSchema: discountOutputSchema,
+ props: {
+ title: Property.ShortText({
+ displayName: 'Title',
+ description: 'Internal title shown in the admin, for example "Buy 2 shirts, get 1 cap free".',
+ required: true,
+ }),
+ code: Property.ShortText({
+ displayName: 'Code',
+ description: 'The code customers enter at checkout, for example "B2G1CAP".',
+ required: true,
+ }),
+ buys_type: Property.StaticDropdown({
+ displayName: 'Customer Buys',
+ description: 'What the customer must buy to unlock the offer: a number of items or a minimum spend.',
+ required: true,
+ options: {
+ options: [
+ { label: 'Minimum quantity of items', value: 'QUANTITY' },
+ { label: 'Minimum purchase amount', value: 'AMOUNT' },
+ ],
+ },
+ }),
+ buys_value: Property.Number({
+ displayName: 'Buys Value',
+ description: 'For QUANTITY the whole number of qualifying items, for example 2. For AMOUNT the spend on qualifying items in the shop currency, for example 50.',
+ required: true,
+ }),
+ buys_product_ids: shopifyProps.idList({
+ displayName: 'Buys Product IDs',
+ description: 'Products that count toward what the customer buys, numeric or "gid://shopify/Product/…". Use products and variants, or collections, not both.',
+ }),
+ buys_variant_ids: shopifyProps.idList({
+ displayName: 'Buys Variant IDs',
+ description: 'Variants that count toward what the customer buys, numeric or "gid://shopify/ProductVariant/…".',
+ }),
+ buys_collection_ids: shopifyProps.idList({
+ displayName: 'Buys Collection IDs',
+ description: 'Collections whose products count toward what the customer buys, numeric or "gid://shopify/Collection/…".',
+ }),
+ gets_quantity: Property.Number({
+ displayName: 'Gets Quantity',
+ description: 'How many discounted items the customer gets, a whole number of 1 or more, for example 1.',
+ required: true,
+ }),
+ gets_percentage: Property.Number({
+ displayName: 'Gets Percentage Off',
+ description: 'Percent off the items the customer gets, above 0 and at most 100. 100 (the default) makes them free; 50 is half price.',
+ required: false,
+ }),
+ gets_product_ids: shopifyProps.idList({
+ displayName: 'Gets Product IDs',
+ description: 'Products the customer gets at the discount, numeric or "gid://shopify/Product/…". Use products and variants, or collections, not both.',
+ }),
+ gets_variant_ids: shopifyProps.idList({
+ displayName: 'Gets Variant IDs',
+ description: 'Variants the customer gets at the discount, numeric or "gid://shopify/ProductVariant/…".',
+ }),
+ gets_collection_ids: shopifyProps.idList({
+ displayName: 'Gets Collection IDs',
+ description: 'Collections whose products the customer gets at the discount, numeric or "gid://shopify/Collection/…".',
+ }),
+ uses_per_order_limit: Property.Number({
+ displayName: 'Uses Per Order Limit',
+ description: 'Optional: the most times the offer applies in one order, a whole number of 1 or more. Leave empty for no limit.',
+ required: false,
+ }),
+ eligibility: Property.StaticDropdown({
+ displayName: 'Eligibility',
+ description: 'Who can use the code. Leave unset to infer it from the ids: CUSTOMERS when customer_ids are given, SEGMENTS when segment_ids are given, ALL buyers when no ids are given.',
+ required: false,
+ options: {
+ options: [
+ { label: 'All buyers', value: 'ALL' },
+ { label: 'Specific customers', value: 'CUSTOMERS' },
+ { label: 'Customer segments', value: 'SEGMENTS' },
+ ],
+ },
+ }),
+ customer_ids: shopifyProps.idList({
+ displayName: 'Customer IDs',
+ description: 'With eligibility CUSTOMERS: customer ids, numeric or "gid://shopify/Customer/…".',
+ }),
+ segment_ids: shopifyProps.idList({
+ displayName: 'Segment IDs',
+ description: 'With eligibility SEGMENTS: customer segment ids, numeric or "gid://shopify/Segment/…".',
+ }),
+ starts_at: Property.DateTime({
+ displayName: 'Starts At',
+ description: 'When the code becomes usable, ISO 8601. Defaults to now.',
+ required: false,
+ }),
+ ends_at: Property.DateTime({
+ displayName: 'Ends At',
+ description: 'Optional end, ISO 8601. Leave empty for no end date.',
+ required: false,
+ }),
+ usage_limit: Property.Number({
+ displayName: 'Usage Limit',
+ description: 'Optional total number of times the code can be used across all customers.',
+ required: false,
+ }),
+ applies_once_per_customer: Property.Checkbox({
+ displayName: 'Once Per Customer',
+ description: 'Each customer can use the code only once. Off by default.',
+ required: false,
+ defaultValue: false,
+ }),
+ combines_with_product_discounts: Property.Checkbox({
+ displayName: 'Combines With Product Discounts',
+ description: 'Can be combined with other product discounts. Off by default.',
+ required: false,
+ defaultValue: false,
+ }),
+ combines_with_order_discounts: Property.Checkbox({
+ displayName: 'Combines With Order Discounts',
+ description: 'Can be combined with order discounts. Off by default.',
+ required: false,
+ defaultValue: false,
+ }),
+ combines_with_shipping_discounts: Property.Checkbox({
+ displayName: 'Combines With Shipping Discounts',
+ description: 'Can be combined with shipping discounts. Off by default.',
+ required: false,
+ defaultValue: false,
+ }),
+ tags: Property.Array({
+ displayName: 'Tags',
+ description: 'Optional tags for the discount, for example "bogo".',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const title = shopifyValues.nonEmpty(propsValue.title);
+ const code = shopifyValues.nonEmpty(propsValue.code);
+ if (!title || !code) {
+ throw new Error('Provide both title and code. Nothing was created.');
+ }
+ const buysItems = shopifyValues.buildDiscountItems({
+ appliesTo: undefined,
+ productIdsToAdd: propsValue.buys_product_ids,
+ productIdsToRemove: undefined,
+ variantIdsToAdd: propsValue.buys_variant_ids,
+ variantIdsToRemove: undefined,
+ collectionIdsToAdd: propsValue.buys_collection_ids,
+ collectionIdsToRemove: undefined,
+ });
+ if (!buysItems) {
+ throw new Error(
+ 'Say what the customer must buy: give buys_product_ids / buys_variant_ids or buys_collection_ids (Buy X Get Y cannot apply to all items). Nothing was created.'
+ );
+ }
+ const getsItems = shopifyValues.buildDiscountItems({
+ appliesTo: undefined,
+ productIdsToAdd: propsValue.gets_product_ids,
+ productIdsToRemove: undefined,
+ variantIdsToAdd: propsValue.gets_variant_ids,
+ variantIdsToRemove: undefined,
+ collectionIdsToAdd: propsValue.gets_collection_ids,
+ collectionIdsToRemove: undefined,
+ });
+ if (!getsItems) {
+ throw new Error(
+ 'Say what the customer gets: give gets_product_ids / gets_variant_ids or gets_collection_ids (Buy X Get Y cannot apply to all items). Nothing was created.'
+ );
+ }
+ const bxgyCodeDiscount = shopifyValues.compact({
+ title,
+ code,
+ startsAt: shopifyValues.nonEmpty(propsValue.starts_at) ?? new Date().toISOString(),
+ endsAt: shopifyValues.nonEmpty(propsValue.ends_at),
+ customerBuys: {
+ value: buildBuysValue({
+ buysType: propsValue.buys_type,
+ buysValue: shopifyValues.readNumber(propsValue.buys_value),
+ }),
+ items: buysItems,
+ },
+ customerGets: {
+ value: {
+ discountOnQuantity: {
+ quantity: String(readWholeNumber({ value: propsValue.gets_quantity, name: 'gets_quantity' })),
+ effect: { percentage: readPercentage(propsValue.gets_percentage) },
+ },
+ },
+ items: getsItems,
+ },
+ usesPerOrderLimit: readOptionalWholeNumber({ value: propsValue.uses_per_order_limit, name: 'uses_per_order_limit' }),
+ context:
+ shopifyValues.buildDiscountContext({
+ eligibility: propsValue.eligibility,
+ customerIdsToAdd: propsValue.customer_ids,
+ customerIdsToRemove: undefined,
+ segmentIdsToAdd: propsValue.segment_ids,
+ segmentIdsToRemove: undefined,
+ }) ?? { all: 'ALL' },
+ usageLimit: readOptionalWholeNumber({ value: propsValue.usage_limit, name: 'usage_limit' }),
+ appliesOncePerCustomer: propsValue.applies_once_per_customer ?? false,
+ combinesWith: shopifyValues.buildCombinesWith({
+ productDiscounts: propsValue.combines_with_product_discounts ?? false,
+ orderDiscounts: propsValue.combines_with_order_discounts ?? false,
+ shippingDiscounts: propsValue.combines_with_shipping_discounts ?? false,
+ }),
+ tags: shopifyValues.nonEmptyList(propsValue.tags),
+ });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ discountCodeBxgyCreate: { codeDiscountNode: GqlDiscountNode | null } | null;
+ }>({
+ auth,
+ query: `mutation CreateBxgyDiscountCode($bxgyCodeDiscount: DiscountCodeBxgyInput!) { discountCodeBxgyCreate(bxgyCodeDiscount: $bxgyCodeDiscount) { codeDiscountNode { id discount: codeDiscount { ${shopifyFields.CODE_DISCOUNT_DETAIL_FIELDS} } } userErrors { field message code } } }`,
+ variables: { bxgyCodeDiscount },
+ });
+ const node = data.discountCodeBxgyCreate?.codeDiscountNode;
+ if (!node) {
+ throw new Error('Shopify did not return the new discount.');
+ }
+ return {
+ ...shopifyMappers.mapDiscountNode(node),
+ redacted_fields: redactedFields,
+ };
+ },
+});
+
+function buildBuysValue({
+ buysType,
+ buysValue,
+}: {
+ buysType: string | undefined;
+ buysValue: number | undefined;
+}): Record<string, string> {
+ if (buysValue === undefined) {
+ throw new Error('Provide buys_value. Nothing was created.');
+ }
+ if (buysType === 'QUANTITY') {
+ return { quantity: String(readWholeNumber({ value: buysValue, name: 'buys_value' })) };
+ }
+ if (buysType === 'AMOUNT') {
+ if (!(buysValue > 0)) {
+ throw new Error('With buys_type AMOUNT, buys_value must be above 0, for example 50. Nothing was created.');
+ }
+ return { amount: String(buysValue) };
+ }
+ throw new Error(`Unknown buys_type "${buysType}". Use QUANTITY or AMOUNT. Nothing was created.`);
+}
+
+function readPercentage(value: number | undefined | null): number {
+ const percent = shopifyValues.readNumber(value) ?? 100;
+ if (!(percent > 0 && percent <= 100)) {
+ throw new Error('gets_percentage must be above 0 and at most 100 (100 means free). Nothing was created.');
+ }
+ return Math.round(percent * 100) / 10000;
+}
+
+function readWholeNumber({ value, name }: { value: number | undefined | null; name: string }): number {
+ const number = shopifyValues.readNumber(value);
+ if (number === undefined || !Number.isInteger(number) || number < 1) {
+ throw new Error(`${name} must be a whole number of 1 or more. Nothing was created.`);
+ }
+ return number;
+}
+
+function readOptionalWholeNumber({
+ value,
+ name,
+}: {
+ value: number | undefined | null;
+ name: string;
+}): number | undefined {
+ if (shopifyValues.readNumber(value) === undefined) {
+ return undefined;
+ }
+ return readWholeNumber({ value, name });
+}
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/create-free-shipping-discount-code.ts b/packages/pieces/community/shopify/src/lib/actions/ai/create-free-shipping-discount-code.ts
new file mode 100644
index 00000000000..a9d04fe18e2
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/create-free-shipping-discount-code.ts
@@ -0,0 +1,221 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlDiscountNode,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { discountOutputSchema } from '../../output-schemas/fulfillment';
+
+export const shopifyAiCreateFreeShippingDiscountCode = createAction({
+ auth: shopifyAuth,
+ name: 'create_free_shipping_discount_code',
+ classification: 'WRITE',
+ displayName: 'Create Free Shipping Discount Code',
+ description: 'Create a free shipping discount that customers apply with a code.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Creates a free shipping discount code and returns it with its id (gid://shopify/DiscountCodeNode/…). Choose where it applies (all countries, or a list of ISO country codes; left unset it follows country_codes, and is all countries only when none are given), optionally cap the shipping rate it covers (maximum_shipping_price), and who can use it: ALL buyers, specific CUSTOMERS or customer SEGMENTS (left unset it follows the ids given, and is ALL only when no ids are given). Optional minimum subtotal or quantity, usage limit, once per customer, end date, tags and which other discount classes it combines with (all off by default). starts_at defaults to now, so the code is live immediately unless a later start is given. Each call creates another discount; a code that already exists is rejected by Shopify. Needs the write_discounts access scope.',
+ idempotent: false,
+ },
+ outputSchema: discountOutputSchema,
+ props: {
+ title: Property.ShortText({
+ displayName: 'Title',
+ description: 'Internal title shown in the admin, for example "Free shipping over 50".',
+ required: true,
+ }),
+ code: Property.ShortText({
+ displayName: 'Code',
+ description: 'The code customers enter at checkout, for example "FREESHIP".',
+ required: true,
+ }),
+ destination: Property.StaticDropdown({
+ displayName: 'Destination',
+ description: 'Where free shipping applies. Leave unset to infer it: COUNTRIES when country_codes are given, ALL countries when none are given.',
+ required: false,
+ options: {
+ options: [
+ { label: 'All countries', value: 'ALL' },
+ { label: 'Specific countries', value: 'COUNTRIES' },
+ ],
+ },
+ }),
+ country_codes: Property.Array({
+ displayName: 'Country Codes',
+ description: 'With destination COUNTRIES: two-letter ISO country codes, for example "US" and "CA".',
+ required: false,
+ }),
+ maximum_shipping_price: Property.Number({
+ displayName: 'Maximum Shipping Price',
+ description: 'Optional: only shipping rates up to this price qualify, for example 20. Leave empty for any rate.',
+ required: false,
+ }),
+ eligibility: Property.StaticDropdown({
+ displayName: 'Eligibility',
+ description: 'Who can use the code. Leave unset to infer it from the ids: CUSTOMERS when customer_ids are given, SEGMENTS when segment_ids are given, ALL buyers when no ids are given.',
+ required: false,
+ options: {
+ options: [
+ { label: 'All buyers', value: 'ALL' },
+ { label: 'Specific customers', value: 'CUSTOMERS' },
+ { label: 'Customer segments', value: 'SEGMENTS' },
+ ],
+ },
+ }),
+ customer_ids: shopifyProps.idList({
+ displayName: 'Customer IDs',
+ description: 'With eligibility CUSTOMERS: customer ids, numeric or "gid://shopify/Customer/…".',
+ }),
+ segment_ids: shopifyProps.idList({
+ displayName: 'Segment IDs',
+ description: 'With eligibility SEGMENTS: customer segment ids, numeric or "gid://shopify/Segment/…".',
+ }),
+ minimum_requirement: Property.StaticDropdown({
+ displayName: 'Minimum Requirement',
+ description: 'Optional minimum the cart must reach. Leave unset for none.',
+ required: false,
+ options: {
+ options: [
+ { label: 'Minimum subtotal', value: 'SUBTOTAL' },
+ { label: 'Minimum quantity of items', value: 'QUANTITY' },
+ ],
+ },
+ }),
+ minimum_value: Property.Number({
+ displayName: 'Minimum Value',
+ description: 'With a minimum requirement: the subtotal (for example 50) or the whole-number item quantity (for example 3).',
+ required: false,
+ }),
+ starts_at: Property.DateTime({
+ displayName: 'Starts At',
+ description: 'When the code becomes usable, ISO 8601. Defaults to now.',
+ required: false,
+ }),
+ ends_at: Property.DateTime({
+ displayName: 'Ends At',
+ description: 'Optional end, ISO 8601. Leave empty for no end date.',
+ required: false,
+ }),
+ usage_limit: Property.Number({
+ displayName: 'Usage Limit',
+ description: 'Optional total number of times the code can be used across all customers.',
+ required: false,
+ }),
+ applies_once_per_customer: Property.Checkbox({
+ displayName: 'Once Per Customer',
+ description: 'Each customer can use the code only once. Off by default.',
+ required: false,
+ defaultValue: false,
+ }),
+ combines_with_product_discounts: Property.Checkbox({
+ displayName: 'Combines With Product Discounts',
+ description: 'Can be combined with product discounts. Off by default.',
+ required: false,
+ defaultValue: false,
+ }),
+ combines_with_order_discounts: Property.Checkbox({
+ displayName: 'Combines With Order Discounts',
+ description: 'Can be combined with order discounts. Off by default.',
+ required: false,
+ defaultValue: false,
+ }),
+ combines_with_shipping_discounts: Property.Checkbox({
+ displayName: 'Combines With Shipping Discounts',
+ description: 'Can be combined with other shipping discounts. Off by default.',
+ required: false,
+ defaultValue: false,
+ }),
+ tags: Property.Array({
+ displayName: 'Tags',
+ description: 'Optional tags for the discount, for example "shipping".',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const title = shopifyValues.nonEmpty(propsValue.title);
+ const code = shopifyValues.nonEmpty(propsValue.code);
+ if (!title || !code) {
+ throw new Error('Provide both title and code. Nothing was created.');
+ }
+ const maximumShippingPrice = shopifyValues.readNumber(propsValue.maximum_shipping_price);
+ if (maximumShippingPrice !== undefined && !(maximumShippingPrice > 0)) {
+ throw new Error('maximum_shipping_price must be above 0. Nothing was created.');
+ }
+ const usageLimit = shopifyValues.readNumber(propsValue.usage_limit);
+ if (usageLimit !== undefined && (!Number.isInteger(usageLimit) || usageLimit < 1)) {
+ throw new Error('usage_limit must be a whole number of 1 or more. Nothing was created.');
+ }
+ const freeShippingCodeDiscount = shopifyValues.compact({
+ title,
+ code,
+ startsAt: shopifyValues.nonEmpty(propsValue.starts_at) ?? new Date().toISOString(),
+ endsAt: shopifyValues.nonEmpty(propsValue.ends_at),
+ destination: buildDestination({ destination: propsValue.destination, countryCodes: propsValue.country_codes }),
+ maximumShippingPrice: maximumShippingPrice === undefined ? undefined : String(maximumShippingPrice),
+ context: shopifyValues.buildDiscountContext({
+ eligibility: propsValue.eligibility,
+ customerIdsToAdd: propsValue.customer_ids,
+ customerIdsToRemove: undefined,
+ segmentIdsToAdd: propsValue.segment_ids,
+ segmentIdsToRemove: undefined,
+ }) ?? { all: 'ALL' },
+ minimumRequirement: shopifyValues.buildMinimumRequirement({
+ kind: propsValue.minimum_requirement,
+ value: shopifyValues.readNumber(propsValue.minimum_value),
+ }),
+ usageLimit,
+ appliesOncePerCustomer: propsValue.applies_once_per_customer ?? false,
+ combinesWith: shopifyValues.buildCombinesWith({
+ productDiscounts: propsValue.combines_with_product_discounts ?? false,
+ orderDiscounts: propsValue.combines_with_order_discounts ?? false,
+ shippingDiscounts: propsValue.combines_with_shipping_discounts ?? false,
+ }),
+ tags: shopifyValues.nonEmptyList(propsValue.tags),
+ });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ discountCodeFreeShippingCreate: { codeDiscountNode: GqlDiscountNode | null } | null;
+ }>({
+ auth,
+ query: `mutation CreateFreeShippingDiscountCode($freeShippingCodeDiscount: DiscountCodeFreeShippingInput!) { discountCodeFreeShippingCreate(freeShippingCodeDiscount: $freeShippingCodeDiscount) { codeDiscountNode { id discount: codeDiscount { ${shopifyFields.CODE_DISCOUNT_DETAIL_FIELDS} } } userErrors { field message code } } }`,
+ variables: { freeShippingCodeDiscount },
+ });
+ const node = data.discountCodeFreeShippingCreate?.codeDiscountNode;
+ if (!node) {
+ throw new Error('Shopify did not return the new discount.');
+ }
+ return {
+ ...shopifyMappers.mapDiscountNode(node),
+ redacted_fields: redactedFields,
+ };
+ },
+});
+
+function buildDestination({
+ destination,
+ countryCodes,
+}: {
+ destination: string | undefined;
+ countryCodes: unknown;
+}): Record<string, unknown> {
+ const codes = (shopifyValues.nonEmptyList(countryCodes) ?? []).map((code) => code.toUpperCase());
+ const target = destination ?? (codes.length > 0 ? 'COUNTRIES' : 'ALL');
+ if (target === 'ALL') {
+ if (codes.length > 0) {
+ throw new Error('destination ALL cannot be combined with country_codes; choose COUNTRIES. Nothing was created.');
+ }
+ return { all: true };
+ }
+ if (codes.length === 0) {
+ throw new Error('destination COUNTRIES needs at least one country code such as "US". Nothing was created.');
+ }
+ const invalid = codes.filter((code) => !/^[A-Z]{2}$/.test(code));
+ if (invalid.length > 0) {
+ throw new Error(`Country codes must be two letters, got: ${invalid.join(', ')}. Nothing was created.`);
+ }
+ return { countries: { add: codes } };
+}
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/create-fulfillment-tracking-event.ts b/packages/pieces/community/shopify/src/lib/actions/ai/create-fulfillment-tracking-event.ts
new file mode 100644
index 00000000000..920ebaa7765
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/create-fulfillment-tracking-event.ts
@@ -0,0 +1,124 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlFulfillmentEvent,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyValues,
+} from '../../common/graphql';
+import { createFulfillmentTrackingEventOutputSchema } from '../../output-schemas/fulfillment';
+
+export const shopifyAiCreateFulfillmentTrackingEvent = createAction({
+ auth: shopifyAuth,
+ name: 'create_fulfillment_tracking_event',
+ classification: 'WRITE',
+ displayName: 'Create Fulfillment Tracking Event',
+ description: 'Add a shipment status event (in transit, out for delivery, delivered, …) to a fulfillment.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Adds one tracking event to a fulfillment, such as IN_TRANSIT, OUT_FOR_DELIVERY, DELIVERED or FAILURE, with an optional message, time, estimated delivery and place. The event updates the shipment status the customer sees. Each call adds another event, so do not repeat it after a success; list_fulfillment_events shows what is already recorded. Needs the write_fulfillments access scope.',
+ idempotent: false,
+ },
+ outputSchema: createFulfillmentTrackingEventOutputSchema,
+ props: {
+ fulfillment_id: Property.ShortText({
+ displayName: 'Fulfillment ID',
+ description:
+ 'The fulfillment id, numeric or "gid://shopify/Fulfillment/…". Find it with list_order_fulfillments.',
+ required: true,
+ }),
+ status: Property.StaticDropdown({
+ displayName: 'Status',
+ description: 'The shipment status this event reports.',
+ required: true,
+ options: {
+ options: [
+ { label: 'Label purchased', value: 'LABEL_PURCHASED' },
+ { label: 'Label printed', value: 'LABEL_PRINTED' },
+ { label: 'Confirmed', value: 'CONFIRMED' },
+ { label: 'Carrier picked up', value: 'CARRIER_PICKED_UP' },
+ { label: 'In transit', value: 'IN_TRANSIT' },
+ { label: 'Out for delivery', value: 'OUT_FOR_DELIVERY' },
+ { label: 'Ready for pickup', value: 'READY_FOR_PICKUP' },
+ { label: 'Attempted delivery', value: 'ATTEMPTED_DELIVERY' },
+ { label: 'Delayed', value: 'DELAYED' },
+ { label: 'Delivered', value: 'DELIVERED' },
+ { label: 'Failure', value: 'FAILURE' },
+ ],
+ },
+ }),
+ message: Property.ShortText({
+ displayName: 'Message',
+ description: 'Optional message, for example "Arrived at sorting facility".',
+ required: false,
+ }),
+ happened_at: Property.DateTime({
+ displayName: 'Happened At',
+ description: 'When the event happened, ISO 8601. Defaults to now on Shopify\'s side.',
+ required: false,
+ }),
+ estimated_delivery_at: Property.DateTime({
+ displayName: 'Estimated Delivery At',
+ description: 'The new estimated delivery time, ISO 8601.',
+ required: false,
+ }),
+ city: Property.ShortText({
+ displayName: 'City',
+ description: 'City where the event happened, for example "Memphis".',
+ required: false,
+ }),
+ province: Property.ShortText({
+ displayName: 'Province',
+ description: 'Province or state where the event happened, for example "Tennessee".',
+ required: false,
+ }),
+ country: Property.ShortText({
+ displayName: 'Country',
+ description: 'Country where the event happened, for example "United States".',
+ required: false,
+ }),
+ zip: Property.ShortText({
+ displayName: 'ZIP',
+ description: 'Postal code where the event happened.',
+ required: false,
+ }),
+ address1: Property.ShortText({
+ displayName: 'Address',
+ description: 'Street address where the event happened.',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const fulfillmentId = shopifyGraphqlClient.toGid({ type: 'Fulfillment', id: propsValue.fulfillment_id });
+ const fulfillmentEvent = shopifyValues.compact({
+ fulfillmentId,
+ status: propsValue.status,
+ message: shopifyValues.nonEmpty(propsValue.message),
+ happenedAt: shopifyValues.nonEmpty(propsValue.happened_at),
+ estimatedDeliveryAt: shopifyValues.nonEmpty(propsValue.estimated_delivery_at),
+ city: shopifyValues.nonEmpty(propsValue.city),
+ province: shopifyValues.nonEmpty(propsValue.province),
+ country: shopifyValues.nonEmpty(propsValue.country),
+ zip: shopifyValues.nonEmpty(propsValue.zip),
+ address1: shopifyValues.nonEmpty(propsValue.address1),
+ });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ fulfillmentEventCreate: { fulfillmentEvent: GqlFulfillmentEvent | null } | null;
+ }>({
+ auth,
+ query: `mutation CreateFulfillmentEvent($fulfillmentEvent: FulfillmentEventInput!) { fulfillmentEventCreate(fulfillmentEvent: $fulfillmentEvent) { fulfillmentEvent { ${shopifyFields.FULFILLMENT_EVENT_FIELDS} } userErrors { field message } } }`,
+ variables: { fulfillmentEvent },
+ });
+ const event = data.fulfillmentEventCreate?.fulfillmentEvent;
+ if (!event) {
+ throw new Error('Shopify did not return the new fulfillment event.');
+ }
+ return {
+ ...shopifyMappers.mapFulfillmentEvent(event),
+ fulfillment_id: fulfillmentId,
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/create-fulfillment.ts b/packages/pieces/community/shopify/src/lib/actions/ai/create-fulfillment.ts
new file mode 100644
index 00000000000..08473f6549a
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/create-fulfillment.ts
@@ -0,0 +1,107 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlFulfillment,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { createFulfillmentOutputSchema } from '../../output-schemas/fulfillment';
+
+export const shopifyAiCreateFulfillment = createAction({
+ auth: shopifyAuth,
+ name: 'create_fulfillment',
+ classification: 'WRITE',
+ displayName: 'Create Fulfillment',
+ description: 'Mark items of a fulfillment order as shipped, with optional tracking details.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Fulfills (ships) items of one fulfillment order and returns the new fulfillment. Get the fulfillment order id and its line item ids from list_order_fulfillment_orders first. Leave line_items empty to fulfill everything still remaining on the fulfillment order, or list fulfillment order line items with quantities for a partial shipment. Tracking company, numbers and URLs are optional. notify_customer is sent explicitly and defaults to false; set it to true only when the customer should get the shipping confirmation email. Each call creates another fulfillment, so do not repeat it after a success. Needs the write_merchant_managed_fulfillment_orders access scope.',
+ idempotent: false,
+ },
+ outputSchema: createFulfillmentOutputSchema,
+ props: {
+ fulfillment_order_id: Property.ShortText({
+ displayName: 'Fulfillment Order ID',
+ description:
+ 'The fulfillment order to fulfill, numeric or "gid://shopify/FulfillmentOrder/…". Find it with list_order_fulfillment_orders.',
+ required: true,
+ }),
+ line_items: shopifyProps.fulfillmentOrderLineItems({
+ description:
+ 'Optional partial shipment: the fulfillment order line items and quantities to ship. Leave empty to ship all remaining items of the fulfillment order.',
+ }),
+ tracking_company: Property.ShortText({
+ displayName: 'Tracking Company',
+ description:
+ 'The carrier name, for example "UPS", "USPS", "FedEx" or "DHL Express". With a supported carrier Shopify builds the tracking URL itself.',
+ required: false,
+ }),
+ tracking_numbers: Property.Array({
+ displayName: 'Tracking Numbers',
+ description: 'One or more tracking numbers, for example "1Z999AA10123456784".',
+ required: false,
+ }),
+ tracking_urls: Property.Array({
+ displayName: 'Tracking URLs',
+ description:
+ 'Tracking page URLs, one per tracking number, for example "https://www.ups.com/track?tracknum=1Z999AA10123456784". Only needed for carriers Shopify does not know.',
+ required: false,
+ }),
+ notify_customer: Property.Checkbox({
+ displayName: 'Notify Customer',
+ description: 'Send the customer a shipping confirmation email. Off by default.',
+ required: false,
+ defaultValue: false,
+ }),
+ message: Property.ShortText({
+ displayName: 'Message',
+ description: 'Optional internal message recorded with the fulfillment.',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const fulfillmentOrderId = shopifyGraphqlClient.toGid({
+ type: 'FulfillmentOrder',
+ id: propsValue.fulfillment_order_id,
+ });
+ const trackingInfo = shopifyValues.compact({
+ company: shopifyValues.nonEmpty(propsValue.tracking_company),
+ numbers: shopifyValues.nonEmptyList(propsValue.tracking_numbers),
+ urls: shopifyValues.nonEmptyList(propsValue.tracking_urls),
+ });
+ const fulfillment = shopifyValues.compact({
+ lineItemsByFulfillmentOrder: [
+ shopifyValues.compact({
+ fulfillmentOrderId,
+ fulfillmentOrderLineItems: shopifyValues.buildFulfillmentOrderLineItems(propsValue.line_items),
+ }),
+ ],
+ trackingInfo: Object.keys(trackingInfo).length > 0 ? trackingInfo : undefined,
+ notifyCustomer: propsValue.notify_customer ?? false,
+ });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ fulfillmentCreate: { fulfillment: GqlFulfillment | null } | null;
+ }>({
+ auth,
+ query: `mutation CreateFulfillment($fulfillment: FulfillmentInput!, $message: String) { fulfillmentCreate(fulfillment: $fulfillment, message: $message) { fulfillment { ${shopifyFields.FULFILLMENT_FIELDS} } userErrors { field message } } }`,
+ variables: {
+ fulfillment,
+ message: shopifyValues.nonEmpty(propsValue.message),
+ },
+ });
+ const created = data.fulfillmentCreate?.fulfillment;
+ if (!created) {
+ throw new Error('Shopify did not return the new fulfillment.');
+ }
+ return {
+ ...shopifyMappers.mapFulfillment(created),
+ fulfillment_order_id: fulfillmentOrderId,
+ redacted_fields: redactedFields,
+ };
+ },
+});
+
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/create-gift-card.ts b/packages/pieces/community/shopify/src/lib/actions/ai/create-gift-card.ts
new file mode 100644
index 00000000000..3b6a806838a
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/create-gift-card.ts
@@ -0,0 +1,164 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlGiftCard,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyValues,
+} from '../../common/graphql';
+import { createGiftCardOutputSchema } from '../../output-schemas/fulfillment';
+
+export const shopifyAiCreateGiftCard = createAction({
+ auth: shopifyAuth,
+ name: 'create_gift_card',
+ classification: 'WRITE',
+ displayName: 'Create Gift Card',
+ description: 'Issue a new gift card with an initial balance.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Issues a new gift card with an initial amount and returns it. The full redeemable code is returned ONLY by this call (as gift_card_code); every later read shows just the last characters, so hand the code to whoever needs it now. Leave code empty to let Shopify generate a random 16-character code. Optionally assign it to a customer, set an expiry date and an internal note, or schedule a notification email to a recipient customer with a message. Each call issues another gift card with real store value, so do not repeat it after a success (also when the output has a warning: the card exists and gift_card_code holds its code). Plan availability of gift cards is to be confirmed on the store. Needs the write_gift_cards access scope.',
+ idempotent: false,
+ },
+ outputSchema: createGiftCardOutputSchema,
+ props: {
+ amount: Property.Number({
+ displayName: 'Initial Amount',
+ description: 'The starting balance, for example 50 for 50.00.',
+ required: true,
+ }),
+ currency: Property.ShortText({
+ displayName: 'Currency',
+ description: 'ISO currency code of the amount, for example "USD". Normally the shop currency.',
+ required: true,
+ }),
+ code: Property.ShortText({
+ displayName: 'Code',
+ description:
+ 'Optional custom code customers type at checkout, letters and numbers only, for example "WELCOME2026GIFT". Leave empty for a random 16-character code.',
+ required: false,
+ }),
+ customer_id: Property.ShortText({
+ displayName: 'Customer ID',
+ description: 'Optional customer who owns the card, numeric or "gid://shopify/Customer/…".',
+ required: false,
+ }),
+ expires_on: Property.ShortText({
+ displayName: 'Expires On',
+ description: 'Optional expiry date, YYYY-MM-DD, for example "2027-12-31". Leave empty for no expiry.',
+ required: false,
+ }),
+ note: Property.LongText({
+ displayName: 'Note',
+ description: 'Optional internal note, not shown to the customer.',
+ required: false,
+ }),
+ recipient_customer_id: Property.ShortText({
+ displayName: 'Recipient Customer ID',
+ description:
+ 'Optional customer who receives the gift card notification, numeric or "gid://shopify/Customer/…". Needed for the recipient message and notification time.',
+ required: false,
+ }),
+ recipient_preferred_name: Property.ShortText({
+ displayName: 'Recipient Preferred Name',
+ description: 'Optional name used to greet the recipient, for example "Sam".',
+ required: false,
+ }),
+ recipient_message: Property.LongText({
+ displayName: 'Recipient Message',
+ description: 'Optional personal message included in the recipient notification.',
+ required: false,
+ }),
+ send_notification_at: Property.DateTime({
+ displayName: 'Send Notification At',
+ description: 'Optional time to email the recipient, ISO 8601. Leave empty to send when Shopify processes it.',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ if (!(propsValue.amount > 0)) {
+ throw new Error('The initial amount must be above 0. Nothing was created.');
+ }
+ const currency = shopifyValues.nonEmpty(propsValue.currency)?.toUpperCase();
+ if (!currency || !/^[A-Z]{3}$/.test(currency)) {
+ throw new Error('Set currency to a 3-letter ISO code such as "USD". Nothing was created.');
+ }
+ const recipient = buildRecipient({
+ recipientCustomerId: propsValue.recipient_customer_id,
+ preferredName: propsValue.recipient_preferred_name,
+ message: propsValue.recipient_message,
+ sendNotificationAt: propsValue.send_notification_at,
+ });
+ const customerId = shopifyValues.nonEmpty(propsValue.customer_id);
+ const input = shopifyValues.compact({
+ initialAmount: { amount: String(propsValue.amount), currencyCode: currency },
+ code: shopifyValues.nonEmpty(propsValue.code),
+ customerId: customerId ? shopifyGraphqlClient.toGid({ type: 'Customer', id: customerId }) : undefined,
+ expiresOn: shopifyValues.readIsoDate(propsValue.expires_on),
+ note: shopifyValues.nonEmpty(propsValue.note),
+ recipientAttributes: recipient,
+ });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ giftCardCreate: { giftCard: GqlGiftCard | null; giftCardCode?: string | null } | null;
+ }>({
+ auth,
+ query: `mutation CreateGiftCard($input: GiftCardCreateInput!) { giftCardCreate(input: $input) { giftCard { ${shopifyFields.GIFT_CARD_FIELDS} } giftCardCode userErrors { field message code } } }`,
+ variables: { input },
+ });
+ const card = data.giftCardCreate?.giftCard;
+ const giftCardCode = data.giftCardCreate?.giftCardCode ?? null;
+ if (!card) {
+ if (giftCardCode) {
+ return {
+ ...shopifyMappers.mapGiftCard({ id: '' }),
+ id: null,
+ gift_card_code: giftCardCode,
+ warning:
+ 'Shopify CREATED the gift card but withheld its record because this app is not approved to read GiftCard objects (protected customer data). Store gift_card_code now and do not retry: another call issues another gift card with real store value.',
+ redacted_fields: redactedFields,
+ };
+ }
+ if (redactedFields.includes('giftCardCreate.giftCard')) {
+ throw new Error(
+ 'Shopify CREATED the gift card, but withheld the new record because this app is not approved to read GiftCard objects (protected customer data). Do not retry: another call issues another gift card with real store value. To read gift cards, grant the app protected customer data access (Partner Dashboard > App > API access > Protected customer data).'
+ );
+ }
+ throw new Error('Shopify did not return the new gift card.');
+ }
+ return {
+ ...shopifyMappers.mapGiftCard(card),
+ gift_card_code: giftCardCode,
+ warning: null,
+ redacted_fields: redactedFields,
+ };
+ },
+});
+
+function buildRecipient({
+ recipientCustomerId,
+ preferredName,
+ message,
+ sendNotificationAt,
+}: {
+ recipientCustomerId: string | undefined;
+ preferredName: string | undefined;
+ message: string | undefined;
+ sendNotificationAt: string | undefined;
+}): Record<string, unknown> | undefined {
+ const id = shopifyValues.nonEmpty(recipientCustomerId);
+ const details = shopifyValues.compact({
+ preferredName: shopifyValues.nonEmpty(preferredName),
+ message: shopifyValues.nonEmpty(message),
+ sendNotificationAt: shopifyValues.nonEmpty(sendNotificationAt),
+ });
+ if (!id) {
+ if (Object.keys(details).length > 0) {
+ throw new Error(
+ 'recipient_preferred_name, recipient_message and send_notification_at need recipient_customer_id. Nothing was changed.'
+ );
+ }
+ return undefined;
+ }
+ return { id: shopifyGraphqlClient.toGid({ type: 'Customer', id }), ...details };
+}
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/deactivate-gift-card.ts b/packages/pieces/community/shopify/src/lib/actions/ai/deactivate-gift-card.ts
new file mode 100644
index 00000000000..8af3074d242
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/deactivate-gift-card.ts
@@ -0,0 +1,49 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlGiftCard,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+} from '../../common/graphql';
+import { giftCardOutputSchema } from '../../output-schemas/fulfillment';
+
+export const shopifyAiDeactivateGiftCard = createAction({
+ auth: shopifyAuth,
+ name: 'deactivate_gift_card',
+ classification: 'DESTRUCTIVE',
+ displayName: 'Deactivate Gift Card',
+ description: 'Permanently disable a gift card so it can no longer be used.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Deactivates one gift card and returns it with enabled=false and deactivated_at set. IRREVERSIBLE: a deactivated gift card can never be re-enabled and its remaining balance can no longer be spent. Confirm the card (get_gift_card) before calling. A repeat call does not restore anything. Needs the write_gift_cards access scope.',
+ idempotent: false,
+ },
+ outputSchema: giftCardOutputSchema,
+ props: {
+ gift_card_id: Property.ShortText({
+ displayName: 'Gift Card ID',
+ description: 'The gift card to deactivate, numeric or "gid://shopify/GiftCard/…". Find it with search_gift_cards.',
+ required: true,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyGraphqlClient.toGid({ type: 'GiftCard', id: propsValue.gift_card_id });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ giftCardDeactivate: { giftCard: GqlGiftCard | null } | null;
+ }>({
+ auth,
+ query: `mutation DeactivateGiftCard($id: ID!) { giftCardDeactivate(id: $id) { giftCard { ${shopifyFields.GIFT_CARD_FIELDS} } userErrors { field message code } } }`,
+ variables: { id },
+ });
+ const card = data.giftCardDeactivate?.giftCard;
+ if (!card) {
+ throw new Error('Shopify did not return the deactivated gift card.');
+ }
+ return {
+ ...shopifyMappers.mapGiftCard(card),
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/delete-discount-redeem-codes.ts b/packages/pieces/community/shopify/src/lib/actions/ai/delete-discount-redeem-codes.ts
new file mode 100644
index 00000000000..136ceb49765
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/delete-discount-redeem-codes.ts
@@ -0,0 +1,60 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import { GqlJob, shopifyGraphqlClient, shopifyValues } from '../../common/graphql';
+import { deleteDiscountRedeemCodesOutputSchema } from '../../output-schemas/fulfillment';
+
+export const shopifyAiDeleteDiscountRedeemCodes = createAction({
+ auth: shopifyAuth,
+ name: 'delete_discount_redeem_codes',
+ classification: 'DESTRUCTIVE',
+ displayName: 'Start Deleting Discount Redeem Codes',
+ description: 'Start deleting redeem codes from a code discount (runs in the background).',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Starts deleting redeem codes from one code discount, either the listed code ids (from list_discount_redeem_codes) or every code matching a search: "times_used:<n>" (for example "times_used:0") or plain text matched against the code (for example "SUMMER"). Other field filters such as "code:" are rejected, because Shopify ignores them and would delete EVERY code of the discount, including its main code. Shopify splits plain text into words, so "APTEST-A" also matches "APTEST-B1"; for an exact code, find its id with list_discount_redeem_codes and pass code_ids instead. Preview what a search matches with list_discount_redeem_codes (same search) before deleting. Exactly one of code_ids or search is required, so nothing is deleted by accident. The discount itself stays (use delete_discount to remove it). Shopify deletes in the background and returns only a job: poll get_job with job_id until done is true. Deleted codes stop working at checkout and cannot be restored. Takes the code discount id (gid://shopify/DiscountCodeNode/… or its plain number). Needs the write_discounts access scope.',
+ idempotent: false,
+ },
+ outputSchema: deleteDiscountRedeemCodesOutputSchema,
+ props: {
+ discount_id: Property.ShortText({
+ displayName: 'Discount ID',
+ description:
+ 'The code discount id, for example "gid://shopify/DiscountCodeNode/123" or "123". Get it from list_discounts or find_discount_by_code.',
+ required: true,
+ }),
+ code_ids: Property.Array({
+ displayName: 'Code IDs',
+ description:
+ 'The redeem code ids to delete, for example "gid://shopify/DiscountRedeemCode/241951653" (from list_discount_redeem_codes). Leave empty when using search.',
+ required: false,
+ }),
+ search: Property.ShortText({
+ displayName: 'Search',
+ description:
+ 'Delete every code of this discount matching this search: "times_used:<n>" such as "times_used:0", or plain text matched against the code such as "SUMMER". Plain text is matched word by word, not exactly, so preview it with list_discount_redeem_codes first. Other field filters (for example "code:") are rejected. Leave empty when using code_ids.',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const discountId = shopifyValues.toDiscountCodeNodeId(propsValue.discount_id);
+ const ids = shopifyValues.toGidList({ type: 'DiscountRedeemCode', value: propsValue.code_ids });
+ const search = shopifyValues.readRedeemCodeSearch(propsValue.search);
+ if ((ids === undefined) === (search === undefined)) {
+ throw new Error('Provide exactly one of code_ids or search. Nothing was deleted.');
+ }
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ discountCodeRedeemCodeBulkDelete: { job: GqlJob | null } | null;
+ }>({
+ auth,
+ query: `mutation DeleteDiscountRedeemCodes($discountId: ID!, $ids: [ID!], $search: String) { discountCodeRedeemCodeBulkDelete(discountId: $discountId, ids: $ids, search: $search) { job { id done } userErrors { field message code } } }`,
+ variables: { discountId, ids, search },
+ });
+ return {
+ discount_id: discountId,
+ job_id: data.discountCodeRedeemCodeBulkDelete?.job?.id ?? null,
+ done: data.discountCodeRedeemCodeBulkDelete?.job?.done ?? false,
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/delete-discount.ts b/packages/pieces/community/shopify/src/lib/actions/ai/delete-discount.ts
new file mode 100644
index 00000000000..721549d4d1c
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/delete-discount.ts
@@ -0,0 +1,87 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import { shopifyGraphqlClient, shopifyValues } from '../../common/graphql';
+import { ShopifyAuth } from '../../common/types';
+import { deleteDiscountOutputSchema } from '../../output-schemas/fulfillment';
+
+export const shopifyAiDeleteDiscount = createAction({
+ auth: shopifyAuth,
+ name: 'delete_discount',
+ classification: 'DESTRUCTIVE',
+ displayName: 'Delete Discount',
+ description: 'Permanently delete a code discount or an automatic discount.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Permanently deletes one discount, code or automatic, with all its redeem codes. Takes the full discount id: gid://shopify/DiscountCodeNode/… deletes a code discount, gid://shopify/DiscountAutomaticNode/… deletes an automatic discount (a gid://shopify/DiscountNode/… id is looked up first to find which kind it is). A plain number is rejected because code and automatic discounts are different objects; get the id from list_discounts, get_discount or find_discount_by_code. Orders that already used the discount keep it. Cannot be undone; a repeat call fails because the discount is gone. Needs the write_discounts access scope.',
+ idempotent: false,
+ },
+ outputSchema: deleteDiscountOutputSchema,
+ props: {
+ discount_id: Property.ShortText({
+ displayName: 'Discount ID',
+ description:
+ 'The full discount id, for example "gid://shopify/DiscountCodeNode/123" or "gid://shopify/DiscountAutomaticNode/456".',
+ required: true,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const parsed = shopifyValues.readDiscountId({
+ value: propsValue.discount_id,
+ allow: ['code', 'automatic', 'node'],
+ });
+ const target = parsed.kind === 'node' ? await resolveNodeKind({ auth, id: parsed.id, numericId: parsed.numericId }) : parsed;
+ if (target.kind === 'code') {
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ discountCodeDelete: { deletedCodeDiscountId?: string | null } | null;
+ }>({
+ auth,
+ query: `mutation DeleteCodeDiscount($id: ID!) { discountCodeDelete(id: $id) { deletedCodeDiscountId userErrors { field message code } } }`,
+ variables: { id: target.id },
+ });
+ return {
+ deleted_discount_id: data.discountCodeDelete?.deletedCodeDiscountId ?? target.id,
+ method: 'code',
+ redacted_fields: redactedFields,
+ };
+ }
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ discountAutomaticDelete: { deletedAutomaticDiscountId?: string | null } | null;
+ }>({
+ auth,
+ query: `mutation DeleteAutomaticDiscount($id: ID!) { discountAutomaticDelete(id: $id) { deletedAutomaticDiscountId userErrors { field message code } } }`,
+ variables: { id: target.id },
+ });
+ return {
+ deleted_discount_id: data.discountAutomaticDelete?.deletedAutomaticDiscountId ?? target.id,
+ method: 'automatic',
+ redacted_fields: redactedFields,
+ };
+ },
+});
+
+async function resolveNodeKind({
+ auth,
+ id,
+ numericId,
+}: {
+ auth: ShopifyAuth;
+ id: string;
+ numericId: string;
+}): Promise<{ id: string; kind: 'code' | 'automatic' }> {
+ const { data } = await shopifyGraphqlClient.request<{
+ discountNode: { id: string; discount?: { __typename?: string } | null } | null;
+ }>({
+ auth,
+ query: `query ResolveDiscountKind($id: ID!) { discountNode(id: $id) { id discount { __typename } } }`,
+ variables: { id },
+ });
+ const typename = data.discountNode?.discount?.__typename ?? '';
+ if (typename.startsWith('DiscountCode')) {
+ return { id: `gid://shopify/DiscountCodeNode/${numericId}`, kind: 'code' };
+ }
+ if (typename.startsWith('DiscountAutomatic')) {
+ return { id: `gid://shopify/DiscountAutomaticNode/${numericId}`, kind: 'automatic' };
+ }
+ throw new Error(`Discount ${id} was not found. Nothing was deleted.`);
+}
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/delete-fulfillment-service.ts b/packages/pieces/community/shopify/src/lib/actions/ai/delete-fulfillment-service.ts
new file mode 100644
index 00000000000..d7085b92cd6
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/delete-fulfillment-service.ts
@@ -0,0 +1,79 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import { shopifyGraphqlClient, shopifyValues } from '../../common/graphql';
+import { deleteFulfillmentServiceOutputSchema } from '../../output-schemas/fulfillment';
+
+export const shopifyAiDeleteFulfillmentService = createAction({
+ auth: shopifyAuth,
+ name: 'delete_fulfillment_service',
+ classification: 'DESTRUCTIVE',
+ displayName: 'Delete Fulfillment Service',
+ description: 'Delete a fulfillment service and decide what happens to its location\'s inventory.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Deletes one fulfillment service. Only services created by this app can be deleted. inventory_action is required and always sent (Shopify\'s silent default would be TRANSFER): TRANSFER moves the service location\'s inventory and commitments to destination_location_id (required, an active merchant-managed location); KEEP keeps the location and its inventory; DELETE removes the location together with its inventory records (the saved docs give no per-value detail for KEEP and DELETE, so prefer TRANSFER when stock must survive). Cannot be undone; a repeat call fails because the service is gone. Needs the write_fulfillments access scope.',
+ idempotent: false,
+ },
+ outputSchema: deleteFulfillmentServiceOutputSchema,
+ props: {
+ fulfillment_service_id: Property.ShortText({
+ displayName: 'Fulfillment Service ID',
+ description:
+ 'The fulfillment service, numeric or "gid://shopify/FulfillmentService/…". Find it with list_fulfillment_services.',
+ required: true,
+ }),
+ inventory_action: Property.StaticDropdown({
+ displayName: 'Inventory Action',
+ description:
+ 'What happens to the service location and its inventory: TRANSFER to another location, KEEP as a regular location, or DELETE.',
+ required: true,
+ options: {
+ options: [
+ { label: 'Transfer inventory to another location', value: 'TRANSFER' },
+ { label: 'Keep the location and its inventory', value: 'KEEP' },
+ { label: 'Delete the location and its inventory', value: 'DELETE' },
+ ],
+ },
+ }),
+ destination_location_id: Property.ShortText({
+ displayName: 'Destination Location ID',
+ description:
+ 'Required with TRANSFER, not allowed otherwise: the active merchant-managed location that receives the inventory, numeric or "gid://shopify/Location/…". Find it with list_locations.',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyGraphqlClient.toGid({ type: 'FulfillmentService', id: propsValue.fulfillment_service_id });
+ const inventoryAction = propsValue.inventory_action;
+ const destination = shopifyValues.nonEmpty(propsValue.destination_location_id);
+ if (inventoryAction === 'TRANSFER' && !destination) {
+ throw new Error(
+ 'inventory_action TRANSFER needs destination_location_id (the location that receives the inventory). Nothing was changed.'
+ );
+ }
+ if (inventoryAction !== 'TRANSFER' && destination) {
+ throw new Error(
+ `destination_location_id applies only to TRANSFER; with ${inventoryAction} leave it empty. Nothing was changed.`
+ );
+ }
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ fulfillmentServiceDelete: { deletedId?: string | null } | null;
+ }>({
+ auth,
+ query: `mutation DeleteFulfillmentService($id: ID!, $inventoryAction: FulfillmentServiceDeleteInventoryAction!, $destinationLocationId: ID) { fulfillmentServiceDelete(id: $id, inventoryAction: $inventoryAction, destinationLocationId: $destinationLocationId) { deletedId userErrors { field message } } }`,
+ variables: {
+ id,
+ inventoryAction,
+ destinationLocationId: destination
+ ? shopifyGraphqlClient.toGid({ type: 'Location', id: destination })
+ : undefined,
+ },
+ });
+ return {
+ deleted_id: data.fulfillmentServiceDelete?.deletedId ?? id,
+ inventory_action: inventoryAction,
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/find-discount-by-code.ts b/packages/pieces/community/shopify/src/lib/actions/ai/find-discount-by-code.ts
new file mode 100644
index 00000000000..d146f74af80
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/find-discount-by-code.ts
@@ -0,0 +1,53 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlDiscountNode,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyValues,
+} from '../../common/graphql';
+import { findDiscountByCodeOutputSchema } from '../../output-schemas/fulfillment';
+
+export const shopifyAiFindDiscountByCode = createAction({
+ auth: shopifyAuth,
+ name: 'find_discount_by_code',
+ classification: 'READ',
+ displayName: 'Find Discount By Code',
+ description: 'Look up the code discount that a redeem code belongs to.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Finds the code discount behind a code customers type, for example "SPRING15", and returns it with the same fields as get_discount (value, target, eligibility, limits, status). found=false (and every other field null or empty) when no discount uses that code. Use it to check whether a code exists before creating one, or to get the discount id for update_basic_discount_code, delete_discount or the redeem code actions. Needs the read_discounts access scope. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: findDiscountByCodeOutputSchema,
+ props: {
+ code: Property.ShortText({
+ displayName: 'Code',
+ description: 'The redeem code, for example "SPRING15".',
+ required: true,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const code = shopifyValues.nonEmpty(propsValue.code);
+ if (!code) {
+ throw new Error('Provide the code to look up.');
+ }
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ codeDiscountNodeByCode: GqlDiscountNode | null;
+ }>({
+ auth,
+ query: `query FindDiscountByCode($code: String!) { codeDiscountNodeByCode(code: $code) { id discount: codeDiscount { ${shopifyFields.CODE_DISCOUNT_DETAIL_FIELDS} } } }`,
+ variables: { code },
+ });
+ const node = data.codeDiscountNodeByCode;
+ return {
+ found: node !== null,
+ ...shopifyMappers.mapDiscountNode(node ?? { id: '' }),
+ ...(node ? {} : { id: null }),
+ searched_code: code,
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/get-discount-redeem-code-bulk-creation.ts b/packages/pieces/community/shopify/src/lib/actions/ai/get-discount-redeem-code-bulk-creation.ts
new file mode 100644
index 00000000000..d300f3ec805
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/get-discount-redeem-code-bulk-creation.ts
@@ -0,0 +1,89 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlConnection,
+ GqlDiscountRedeemCodeBulkCreation,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { getDiscountRedeemCodeBulkCreationOutputSchema } from '../../output-schemas/fulfillment';
+
+const MAX_PAGE_SIZE = 60;
+
+export const shopifyAiGetDiscountRedeemCodeBulkCreation = createAction({
+ auth: shopifyAuth,
+ name: 'get_discount_redeem_code_bulk_creation',
+ classification: 'READ',
+ displayName: 'Get Discount Redeem Code Bulk Creation',
+ description: 'Check the progress and results of a redeem code import started by add_discount_redeem_codes.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Reads one redeem code import started by add_discount_redeem_codes: done, how many codes were sent, imported and failed, and one page of the submitted codes with the created code id or the errors for each (for example "has already been taken"). A single read, not a wait: call again later while done is false. Page through the codes with end_cursor while has_next_page is true. Needs the read_discounts access scope. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: getDiscountRedeemCodeBulkCreationOutputSchema,
+ props: {
+ bulk_creation_id: Property.ShortText({
+ displayName: 'Bulk Creation ID',
+ description:
+ 'The bulk_creation_id returned by add_discount_redeem_codes, for example "gid://shopify/DiscountRedeemCodeBulkCreation/989355205" (a plain number is accepted).',
+ required: true,
+ }),
+ first: shopifyProps.first({ max: MAX_PAGE_SIZE }),
+ after: shopifyProps.after(),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyGraphqlClient.toGid({
+ type: 'DiscountRedeemCodeBulkCreation',
+ id: propsValue.bulk_creation_id,
+ });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ discountRedeemCodeBulkCreation:
+ | (GqlDiscountRedeemCodeBulkCreation & { codes?: GqlConnection<GqlBulkCode> | null })
+ | null;
+ }>({
+ auth,
+ query: `query GetDiscountRedeemCodeBulkCreation($id: ID!, $first: Int!, $after: String) { discountRedeemCodeBulkCreation(id: $id) { id done codesCount importedCount failedCount createdAt discountCode { id } codes(first: $first, after: $after) { nodes { code discountRedeemCode { id } errors { field message code } } ${shopifyFields.PAGE_INFO_FIELDS} } } }`,
+ variables: {
+ id,
+ first: shopifyValues.readFirst({ value: propsValue.first, max: MAX_PAGE_SIZE }),
+ after: shopifyValues.nonEmpty(propsValue.after),
+ },
+ });
+ const creation = data.discountRedeemCodeBulkCreation;
+ if (!creation) {
+ throw new Error(`Bulk creation ${id} was not found.`);
+ }
+ const page = shopifyMappers.toPage({ connection: creation.codes, map: mapBulkCode, redactedFields });
+ return {
+ ...shopifyMappers.mapDiscountBulkCreation(creation),
+ codes: page.items,
+ codes_on_page: page.count,
+ has_next_page: page.has_next_page,
+ end_cursor: page.end_cursor,
+ redacted_fields: redactedFields,
+ };
+ },
+});
+
+function mapBulkCode(entry: GqlBulkCode) {
+ return {
+ code: entry.code ?? null,
+ discount_redeem_code_id: entry.discountRedeemCode?.id ?? null,
+ errors: (entry.errors ?? []).map((error) => ({
+ field: Array.isArray(error.field) ? error.field.join('.') : null,
+ message: error.message ?? null,
+ code: error.code ?? null,
+ })),
+ };
+}
+
+type GqlBulkCode = {
+ code?: string | null;
+ discountRedeemCode?: { id: string } | null;
+ errors?: { field?: string[] | null; message?: string | null; code?: string | null }[] | null;
+};
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/get-discount.ts b/packages/pieces/community/shopify/src/lib/actions/ai/get-discount.ts
new file mode 100644
index 00000000000..b7d65108a51
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/get-discount.ts
@@ -0,0 +1,53 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlDiscountNode,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyValues,
+} from '../../common/graphql';
+import { discountOutputSchema } from '../../output-schemas/fulfillment';
+
+export const shopifyAiGetDiscount = createAction({
+ auth: shopifyAuth,
+ name: 'get_discount',
+ classification: 'READ',
+ displayName: 'Get Discount',
+ description: 'Get one discount (code or automatic) with its value, target, eligibility and limits.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Returns one discount, code or automatic, of any kind (amount off, buy X get Y, free shipping, app). Includes method (code or automatic), discount_type, title, status, summary, dates, usage count, value (percentage as a percent number, or amount), what it applies to (up to 25 product, variant or collection ids; items_truncated when more), eligibility (ALL, CUSTOMERS or SEGMENTS with ids), minimum requirement, combinations, usage limits and, for code discounts, the code count and up to 10 codes (use list_discount_redeem_codes for all). Takes the full discount id (gid://shopify/DiscountCodeNode/… or gid://shopify/DiscountAutomaticNode/…); a plain number is rejected as ambiguous. Needs the read_discounts access scope. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: discountOutputSchema,
+ props: {
+ discount_id: Property.ShortText({
+ displayName: 'Discount ID',
+ description:
+ 'The full discount id, for example "gid://shopify/DiscountCodeNode/123" or "gid://shopify/DiscountAutomaticNode/456". Get it from list_discounts or find_discount_by_code.',
+ required: true,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const { id } = shopifyValues.readDiscountId({
+ value: propsValue.discount_id,
+ allow: ['code', 'automatic', 'node'],
+ });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ discountNode: GqlDiscountNode | null;
+ }>({
+ auth,
+ query: `query GetDiscount($id: ID!) { discountNode(id: $id) { id discount { ${shopifyFields.DISCOUNT_DETAIL_FIELDS} } } }`,
+ variables: { id },
+ });
+ if (!data.discountNode) {
+ throw new Error(`Discount ${id} was not found.`);
+ }
+ return {
+ ...shopifyMappers.mapDiscountNode(data.discountNode),
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/get-fulfillment-details.ts b/packages/pieces/community/shopify/src/lib/actions/ai/get-fulfillment-details.ts
new file mode 100644
index 00000000000..706ff81bc75
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/get-fulfillment-details.ts
@@ -0,0 +1,49 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlFulfillment,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+} from '../../common/graphql';
+import { fulfillmentOutputSchema } from '../../output-schemas/fulfillment';
+
+export const shopifyAiGetFulfillmentDetails = createAction({
+ auth: shopifyAuth,
+ name: 'get_fulfillment_details',
+ classification: 'READ',
+ displayName: 'Get Fulfillment Details',
+ description: 'Get one fulfillment with its tracking, origin address and shipped line items.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Returns one fulfillment (a recorded shipment): status, shipment status (display_status), tracking company, numbers and URLs, dates (in transit, delivered, estimated delivery), location, fulfillment service, origin address and up to 50 shipped line items with quantities (line_items_truncated tells when there are more). Needs the read_orders access scope. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: fulfillmentOutputSchema,
+ props: {
+ fulfillment_id: Property.ShortText({
+ displayName: 'Fulfillment ID',
+ description:
+ 'The fulfillment id, numeric or "gid://shopify/Fulfillment/…". Find it with list_order_fulfillments.',
+ required: true,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyGraphqlClient.toGid({ type: 'Fulfillment', id: propsValue.fulfillment_id });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ fulfillment: GqlFulfillment | null;
+ }>({
+ auth,
+ query: `query GetFulfillment($id: ID!) { fulfillment(id: $id) { ${shopifyFields.FULFILLMENT_FIELDS} } }`,
+ variables: { id },
+ });
+ if (!data.fulfillment) {
+ throw new Error(`Fulfillment ${id} was not found.`);
+ }
+ return {
+ ...shopifyMappers.mapFulfillment(data.fulfillment),
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/get-fulfillment-order.ts b/packages/pieces/community/shopify/src/lib/actions/ai/get-fulfillment-order.ts
new file mode 100644
index 00000000000..62ca69787a8
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/get-fulfillment-order.ts
@@ -0,0 +1,55 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlFulfillmentOrder,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyValues,
+} from '../../common/graphql';
+import { fulfillmentOrderOutputSchema } from '../../output-schemas/fulfillment';
+
+export const shopifyAiGetFulfillmentOrder = createAction({
+ auth: shopifyAuth,
+ name: 'get_fulfillment_order',
+ classification: 'READ',
+ displayName: 'Get Fulfillment Order',
+ description: 'Get one fulfillment order with its status, holds, location and line items.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Returns one fulfillment order: status and request status, assigned location, destination, delivery method, active holds (with the hold ids release_fulfillment_order_hold needs), the actions Shopify allows on it right now (supported_actions, for example CREATE_FULFILLMENT, HOLD, MOVE, RELEASE_HOLD) and its line items with remaining quantities, 50 per call: while line_items_truncated is true, call again with line_items_after set to line_items_end_cursor to read the next 50. Destination name, email and phone may be redacted on Basic-plan stores (see redacted_fields). Needs the read_merchant_managed_fulfillment_orders access scope. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: fulfillmentOrderOutputSchema,
+ props: {
+ fulfillment_order_id: Property.ShortText({
+ displayName: 'Fulfillment Order ID',
+ description:
+ 'The fulfillment order id, numeric or "gid://shopify/FulfillmentOrder/…". Find it with list_order_fulfillment_orders.',
+ required: true,
+ }),
+ line_items_after: Property.ShortText({
+ displayName: 'Line Items Cursor',
+ description: 'Leave empty for the first 50 line items. To read more, pass line_items_end_cursor from the previous call.',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyGraphqlClient.toGid({ type: 'FulfillmentOrder', id: propsValue.fulfillment_order_id });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ fulfillmentOrder: GqlFulfillmentOrder | null;
+ }>({
+ auth,
+ query: `query GetFulfillmentOrder($id: ID!, $lineItemsAfter: String) { fulfillmentOrder(id: $id) { ${shopifyFields.FULFILLMENT_ORDER_PAGED_FIELDS} } }`,
+ variables: { id, lineItemsAfter: shopifyValues.nonEmpty(propsValue.line_items_after) },
+ });
+ if (!data.fulfillmentOrder) {
+ throw new Error(`Fulfillment order ${id} was not found.`);
+ }
+ return {
+ ...shopifyMappers.mapFulfillmentOrder(data.fulfillmentOrder),
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/get-gift-card.ts b/packages/pieces/community/shopify/src/lib/actions/ai/get-gift-card.ts
new file mode 100644
index 00000000000..358e2aecca1
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/get-gift-card.ts
@@ -0,0 +1,48 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlGiftCard,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+} from '../../common/graphql';
+import { giftCardOutputSchema } from '../../output-schemas/fulfillment';
+
+export const shopifyAiGetGiftCard = createAction({
+ auth: shopifyAuth,
+ name: 'get_gift_card',
+ classification: 'READ',
+ displayName: 'Get Gift Card',
+ description: 'Get one gift card with its balance, status and owner.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Returns one gift card: balance and initial value with currency, whether it is enabled and redeemable, expiry, deactivation time, owner customer, originating order, recipient details and note. Only the last characters of the code are ever returned (masked_code, last_characters); the full code is shown once, by create_gift_card. Needs the read_gift_cards access scope. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: giftCardOutputSchema,
+ props: {
+ gift_card_id: Property.ShortText({
+ displayName: 'Gift Card ID',
+ description: 'The gift card id, numeric or "gid://shopify/GiftCard/…". Find it with search_gift_cards.',
+ required: true,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyGraphqlClient.toGid({ type: 'GiftCard', id: propsValue.gift_card_id });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ giftCard: GqlGiftCard | null;
+ }>({
+ auth,
+ query: `query GetGiftCard($id: ID!) { giftCard(id: $id) { ${shopifyFields.GIFT_CARD_FIELDS} } }`,
+ variables: { id },
+ });
+ if (!data.giftCard) {
+ throw new Error(`Gift card ${id} was not found.`);
+ }
+ return {
+ ...shopifyMappers.mapGiftCard(data.giftCard),
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/hold-fulfillment-order.ts b/packages/pieces/community/shopify/src/lib/actions/ai/hold-fulfillment-order.ts
new file mode 100644
index 00000000000..a359f044715
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/hold-fulfillment-order.ts
@@ -0,0 +1,111 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlFulfillmentHold,
+ GqlFulfillmentOrder,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { holdFulfillmentOrderOutputSchema } from '../../output-schemas/fulfillment';
+
+export const shopifyAiHoldFulfillmentOrder = createAction({
+ auth: shopifyAuth,
+ name: 'hold_fulfillment_order',
+ classification: 'WRITE',
+ displayName: 'Hold Fulfillment Order',
+ description: 'Put a fulfillment order (or some of its items) on hold so it is not shipped yet.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Places a fulfillment hold on one fulfillment order so it cannot be fulfilled until the hold is released with release_fulfillment_order_hold. A reason is required (for example AWAITING_PAYMENT, HIGH_RISK_OF_FRAUD, INCORRECT_ADDRESS, INVENTORY_OUT_OF_STOCK, OTHER). Leave line_items empty to hold the whole fulfillment order, or list fulfillment order line items with quantities to hold only those; Shopify then splits the rest into remaining_fulfillment_order. Returns the new hold (its id is what release_fulfillment_order_hold takes) and the held fulfillment order. Each app can have at most 10 active holds per fulfillment order, and every call adds another hold. notify_merchant is sent explicitly and defaults to false. Needs the write_merchant_managed_fulfillment_orders access scope.',
+ idempotent: false,
+ },
+ outputSchema: holdFulfillmentOrderOutputSchema,
+ props: {
+ fulfillment_order_id: Property.ShortText({
+ displayName: 'Fulfillment Order ID',
+ description:
+ 'The fulfillment order to hold, numeric or "gid://shopify/FulfillmentOrder/…". Find it with list_order_fulfillment_orders.',
+ required: true,
+ }),
+ reason: Property.StaticDropdown({
+ displayName: 'Reason',
+ description: 'Why the fulfillment order is held.',
+ required: true,
+ options: {
+ options: [
+ { label: 'Awaiting payment', value: 'AWAITING_PAYMENT' },
+ { label: 'High risk of fraud', value: 'HIGH_RISK_OF_FRAUD' },
+ { label: 'Incorrect address', value: 'INCORRECT_ADDRESS' },
+ { label: 'Inventory out of stock', value: 'INVENTORY_OUT_OF_STOCK' },
+ { label: 'Unknown delivery date', value: 'UNKNOWN_DELIVERY_DATE' },
+ { label: 'Awaiting return items', value: 'AWAITING_RETURN_ITEMS' },
+ { label: 'Other', value: 'OTHER' },
+ ],
+ },
+ }),
+ reason_notes: Property.LongText({
+ displayName: 'Reason Notes',
+ description: 'Optional details shown with the hold, for example "Waiting for the customer to confirm the address".',
+ required: false,
+ }),
+ handle: Property.ShortText({
+ displayName: 'Handle',
+ description:
+ 'Optional unique name for this hold within your app, for example "address-check". Useful to find the hold again later.',
+ required: false,
+ }),
+ external_id: Property.ShortText({
+ displayName: 'External ID',
+ description: 'Optional id from your own system that placed the hold.',
+ required: false,
+ }),
+ notify_merchant: Property.Checkbox({
+ displayName: 'Notify Merchant',
+ description: 'Notify the merchant about the hold. Off by default.',
+ required: false,
+ defaultValue: false,
+ }),
+ line_items: shopifyProps.fulfillmentOrderLineItems({
+ description:
+ 'Optional partial hold: the fulfillment order line items and quantities to hold. Leave empty to hold the whole fulfillment order.',
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyGraphqlClient.toGid({ type: 'FulfillmentOrder', id: propsValue.fulfillment_order_id });
+ const fulfillmentHold = shopifyValues.compact({
+ reason: propsValue.reason,
+ reasonNotes: shopifyValues.nonEmpty(propsValue.reason_notes),
+ handle: shopifyValues.nonEmpty(propsValue.handle),
+ externalId: shopifyValues.nonEmpty(propsValue.external_id),
+ notifyMerchant: propsValue.notify_merchant ?? false,
+ fulfillmentOrderLineItems: shopifyValues.buildFulfillmentOrderLineItems(propsValue.line_items),
+ });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ fulfillmentOrderHold: {
+ fulfillmentHold: GqlFulfillmentHold | null;
+ fulfillmentOrder: GqlFulfillmentOrder | null;
+ remainingFulfillmentOrder: GqlFulfillmentOrder | null;
+ } | null;
+ }>({
+ auth,
+ query: `mutation HoldFulfillmentOrder($id: ID!, $fulfillmentHold: FulfillmentOrderHoldInput!) { fulfillmentOrderHold(id: $id, fulfillmentHold: $fulfillmentHold) { fulfillmentHold { id reason reasonNotes displayReason handle heldByRequestingApp } fulfillmentOrder { ${shopifyFields.FULFILLMENT_ORDER_FIELDS} } remainingFulfillmentOrder { ${shopifyFields.FULFILLMENT_ORDER_FIELDS} } userErrors { field message code } } }`,
+ variables: { id, fulfillmentHold },
+ });
+ const payload = data.fulfillmentOrderHold;
+ const hold = payload?.fulfillmentHold;
+ return {
+ hold_id: hold?.id ?? null,
+ hold_reason: hold?.reason ?? null,
+ hold_reason_notes: hold?.reasonNotes ?? null,
+ hold_display_reason: hold?.displayReason ?? null,
+ hold_handle: hold?.handle ?? null,
+ fulfillment_order: shopifyMappers.mapFulfillmentOrderOrNull(payload?.fulfillmentOrder),
+ remaining_fulfillment_order: shopifyMappers.mapFulfillmentOrderOrNull(payload?.remainingFulfillmentOrder),
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/list-carrier-services.ts b/packages/pieces/community/shopify/src/lib/actions/ai/list-carrier-services.ts
new file mode 100644
index 00000000000..6bc617c7a0f
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/list-carrier-services.ts
@@ -0,0 +1,69 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlCarrierService,
+ GqlConnection,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { listCarrierServicesOutputSchema } from '../../output-schemas/fulfillment';
+
+const MAX_PAGE_SIZE = 250;
+
+export const shopifyAiListCarrierServices = createAction({
+ auth: shopifyAuth,
+ name: 'list_carrier_services',
+ classification: 'SEARCH',
+ displayName: 'List Carrier Services',
+ description: 'List the carrier-calculated shipping rate services set up on the store.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Lists the carrier services that provide live shipping rates at checkout (apps or carriers that Shopify calls for rates), with name, whether active, callback URL and whether they support service discovery. Carrier-calculated rates need the Advanced plan or higher (or a development store), so the list is often empty on smaller plans. Optionally filter with search syntax such as "active:true". Paged: pass end_cursor back as the cursor while has_next_page is true. Needs the read_shipping access scope. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: listCarrierServicesOutputSchema,
+ props: {
+ query: shopifyProps.searchQuery(
+ 'Optional Shopify search syntax, for example "active:true" or "id:123". Leave empty to list all.'
+ ),
+ sort_key: Property.StaticDropdown({
+ displayName: 'Sort By',
+ description: 'Field to sort by. Defaults to the id.',
+ required: false,
+ options: {
+ options: [
+ { label: 'ID', value: 'ID' },
+ { label: 'Created at', value: 'CREATED_AT' },
+ { label: 'Updated at', value: 'UPDATED_AT' },
+ ],
+ },
+ }),
+ reverse: shopifyProps.reverse(),
+ first: shopifyProps.first({ max: MAX_PAGE_SIZE }),
+ after: shopifyProps.after(),
+ },
+ async run({ auth, propsValue }) {
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ carrierServices: GqlConnection<GqlCarrierService>;
+ }>({
+ auth,
+ query: `query ListCarrierServices($first: Int!, $after: String, $query: String, $sortKey: CarrierServiceSortKeys, $reverse: Boolean) { carrierServices(first: $first, after: $after, query: $query, sortKey: $sortKey, reverse: $reverse) { nodes { ${shopifyFields.CARRIER_SERVICE_FIELDS} } ${shopifyFields.PAGE_INFO_FIELDS} } }`,
+ variables: {
+ first: shopifyValues.readFirst({ value: propsValue.first, max: MAX_PAGE_SIZE }),
+ after: shopifyValues.nonEmpty(propsValue.after),
+ query: shopifyValues.nonEmpty(propsValue.query),
+ sortKey: propsValue.sort_key,
+ reverse: propsValue.reverse ?? false,
+ },
+ });
+ return shopifyMappers.toPage({
+ connection: data.carrierServices,
+ map: shopifyMappers.mapCarrierService,
+ redactedFields,
+ });
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/list-delivery-profiles.ts b/packages/pieces/community/shopify/src/lib/actions/ai/list-delivery-profiles.ts
new file mode 100644
index 00000000000..318d360e13d
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/list-delivery-profiles.ts
@@ -0,0 +1,59 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlConnection,
+ GqlDeliveryProfile,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { listDeliveryProfilesOutputSchema } from '../../output-schemas/fulfillment';
+
+const MAX_PAGE_SIZE = 1;
+
+export const shopifyAiListDeliveryProfiles = createAction({
+ auth: shopifyAuth,
+ name: 'list_delivery_profiles',
+ classification: 'SEARCH',
+ displayName: 'List Delivery Profiles',
+ description: 'List the shipping profiles with their zones, countries and rates.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Lists the store\'s delivery (shipping) profiles: name, whether it is the default profile, how many variants it covers, and per location group the shipping zones with their countries and up to 3 rates each (name, flat price or carrier service). Up to 2 zones per location group are returned; zones_truncated and rates_truncated tell when there are more; then read that location group in full with list_delivery_zones. This is the GraphQL form of the old shipping zones. Returns one profile per call to stay within the Shopify query cost limit: pass end_cursor back as the cursor while has_next_page is true to read the next profile. Needs the read_shipping access scope. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: listDeliveryProfilesOutputSchema,
+ props: {
+ merchant_owned_only: Property.Checkbox({
+ displayName: 'Merchant Owned Only',
+ description: 'Return only profiles created by the merchant, not by apps. Off by default.',
+ required: false,
+ defaultValue: false,
+ }),
+ reverse: shopifyProps.reverse(),
+ first: shopifyProps.first({ max: MAX_PAGE_SIZE }),
+ after: shopifyProps.after(),
+ },
+ async run({ auth, propsValue }) {
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ deliveryProfiles: GqlConnection<GqlDeliveryProfile>;
+ }>({
+ auth,
+ query: `query ListDeliveryProfiles($first: Int!, $after: String, $reverse: Boolean, $merchantOwnedOnly: Boolean) { deliveryProfiles(first: $first, after: $after, reverse: $reverse, merchantOwnedOnly: $merchantOwnedOnly) { nodes { ${shopifyFields.DELIVERY_PROFILE_FIELDS} } ${shopifyFields.PAGE_INFO_FIELDS} } }`,
+ variables: {
+ first: shopifyValues.readFirst({ value: propsValue.first, max: MAX_PAGE_SIZE }),
+ after: shopifyValues.nonEmpty(propsValue.after),
+ reverse: propsValue.reverse ?? false,
+ merchantOwnedOnly: propsValue.merchant_owned_only ?? false,
+ },
+ });
+ return shopifyMappers.toPage({
+ connection: data.deliveryProfiles,
+ map: shopifyMappers.mapDeliveryProfile,
+ redactedFields,
+ });
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/list-delivery-zones.ts b/packages/pieces/community/shopify/src/lib/actions/ai/list-delivery-zones.ts
new file mode 100644
index 00000000000..74996e208aa
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/list-delivery-zones.ts
@@ -0,0 +1,112 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlDeliveryZoneEntry,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { listDeliveryZonesOutputSchema } from '../../output-schemas/fulfillment';
+
+const MAX_PAGE_SIZE = 25;
+const FETCH_PAGE_SIZE = 10;
+const FIRST_ZONE_TOKEN = 'first';
+
+export const shopifyAiListDeliveryZones = createAction({
+ auth: shopifyAuth,
+ name: 'list_delivery_zones',
+ classification: 'SEARCH',
+ displayName: 'List Delivery Zones',
+ description: 'List every shipping zone of one location group in a delivery profile, with countries and rates.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Lists all shipping zones of one location group in one delivery (shipping) profile, each with its countries and up to 50 rates (name, flat price or carrier service). Use it when list_delivery_profiles reports zones_truncated or rates_truncated, or to read one group in full. Take profile_id and location_group_id from list_delivery_profiles. Paged, at most 10 zones per call even when first is larger: pass end_cursor back as the cursor while has_next_page is true. When a zone has rates_truncated, call again with the zone_token of that zone and rates_after set to its rates_end_cursor to read its next 50 rates (only that zone is returned). Needs the read_shipping access scope. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: listDeliveryZonesOutputSchema,
+ props: {
+ profile_id: Property.ShortText({
+ displayName: 'Delivery Profile ID',
+ description: 'The profile id from list_delivery_profiles, numeric or "gid://shopify/DeliveryProfile/…".',
+ required: true,
+ }),
+ location_group_id: Property.ShortText({
+ displayName: 'Location Group ID',
+ description: 'The location_group_id from list_delivery_profiles, numeric or "gid://shopify/DeliveryLocationGroup/…".',
+ required: true,
+ }),
+ first: shopifyProps.first({ max: MAX_PAGE_SIZE }),
+ after: shopifyProps.after(),
+ zone_token: Property.ShortText({
+ displayName: 'Zone Token',
+ description: 'To read more rates of one zone: that zone\'s zone_token from a previous call. Returns only that zone.',
+ required: false,
+ }),
+ rates_after: Property.ShortText({
+ displayName: 'Rates Cursor',
+ description: 'With zone_token: the zone\'s rates_end_cursor from a previous call, to read its next 50 rates.',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const profileId = shopifyGraphqlClient.toGid({ type: 'DeliveryProfile', id: propsValue.profile_id });
+ const locationGroupId = shopifyGraphqlClient.toGid({
+ type: 'DeliveryLocationGroup',
+ id: propsValue.location_group_id,
+ });
+ const zoneToken = shopifyValues.nonEmpty(propsValue.zone_token);
+ const ratesAfter = shopifyValues.nonEmpty(propsValue.rates_after);
+ if (ratesAfter && !zoneToken) {
+ throw new Error('Set zone_token together with rates_after, both from a previous call.');
+ }
+ const zonesAfter = zoneToken ? (zoneToken === FIRST_ZONE_TOKEN ? undefined : zoneToken) : shopifyValues.nonEmpty(propsValue.after);
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ deliveryProfile: {
+ id: string;
+ profileLocationGroups: {
+ locationGroupZones?: {
+ edges: { cursor: string; node: GqlDeliveryZoneEntry }[];
+ pageInfo?: { hasNextPage?: boolean | null; endCursor?: string | null } | null;
+ } | null;
+ }[];
+ } | null;
+ }>({
+ auth,
+ query: `query ListDeliveryZones($id: ID!, $locationGroupId: ID!, $first: Int!, $after: String, $ratesAfter: String) { deliveryProfile(id: $id) { id profileLocationGroups(locationGroupId: $locationGroupId) { locationGroupZones(first: $first, after: $after) { edges { cursor node { ${shopifyFields.DELIVERY_ZONE_FIELDS} } } ${shopifyFields.PAGE_INFO_FIELDS} } } } }`,
+ variables: {
+ id: profileId,
+ locationGroupId,
+ first: zoneToken ? 1 : Math.min(shopifyValues.readFirst({ value: propsValue.first, max: MAX_PAGE_SIZE }), FETCH_PAGE_SIZE),
+ after: zonesAfter,
+ ratesAfter,
+ },
+ });
+ if (!data.deliveryProfile) {
+ throw new Error(`Delivery profile ${profileId} was not found.`);
+ }
+ const group = data.deliveryProfile.profileLocationGroups[0];
+ if (!group) {
+ throw new Error(
+ `Location group ${locationGroupId} is not part of delivery profile ${profileId}. Check both ids with list_delivery_profiles.`
+ );
+ }
+ const edges = group.locationGroupZones?.edges ?? [];
+ const items = edges.map((edge, index) => ({
+ ...shopifyMappers.mapDeliveryZone(edge.node),
+ rates_end_cursor: edge.node.methodDefinitions?.pageInfo?.endCursor ?? null,
+ zone_token: index === 0 ? zonesAfter ?? FIRST_ZONE_TOKEN : edges[index - 1].cursor,
+ }));
+ return {
+ profile_id: profileId,
+ location_group_id: locationGroupId,
+ items,
+ count: items.length,
+ has_next_page: zoneToken ? false : group.locationGroupZones?.pageInfo?.hasNextPage ?? false,
+ end_cursor: zoneToken ? null : group.locationGroupZones?.pageInfo?.endCursor ?? null,
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/list-discount-redeem-codes.ts b/packages/pieces/community/shopify/src/lib/actions/ai/list-discount-redeem-codes.ts
new file mode 100644
index 00000000000..0bbaa06e5da
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/list-discount-redeem-codes.ts
@@ -0,0 +1,75 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlConnection,
+ GqlDiscountRedeemCode,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { listDiscountRedeemCodesOutputSchema } from '../../output-schemas/fulfillment';
+
+const MAX_PAGE_SIZE = 250;
+
+export const shopifyAiListDiscountRedeemCodes = createAction({
+ auth: shopifyAuth,
+ name: 'list_discount_redeem_codes',
+ classification: 'SEARCH',
+ displayName: 'List Discount Redeem Codes',
+ description: 'List the redeem codes of a code discount with their usage counts.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Lists the redeem codes (the strings customers type) of one code discount, with each code\'s id and usage count; the code ids are what delete_discount_redeem_codes takes. Optionally filter with "times_used:<n>" (for example "times_used:0") or plain text matched against the code (for example "SUMMER"); Shopify ignores other field filters such as "code:" and would list every code, so they are rejected. Plain text is matched word by word, not exactly: "APTEST-A" also matches "APTEST-B1". Takes the code discount id (gid://shopify/DiscountCodeNode/… or its plain number); automatic discounts have no codes. Paged: pass end_cursor back as the cursor while has_next_page is true. Needs the read_discounts access scope. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: listDiscountRedeemCodesOutputSchema,
+ props: {
+ discount_id: Property.ShortText({
+ displayName: 'Discount ID',
+ description:
+ 'The code discount id, for example "gid://shopify/DiscountCodeNode/123" or "123". Get it from list_discounts or find_discount_by_code.',
+ required: true,
+ }),
+ query: shopifyProps.searchQuery(
+ 'Optional filter: "times_used:<n>" such as "times_used:0", or plain text matched against the code such as "SUMMER". Other field filters (for example "code:") are rejected. Leave empty to list all.'
+ ),
+ first: shopifyProps.first({ max: MAX_PAGE_SIZE }),
+ after: shopifyProps.after(),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyValues.toDiscountCodeNodeId(propsValue.discount_id);
+ const codesSelection = `codes(first: $first, after: $after, query: $query) { nodes { id code asyncUsageCount createdBy { id title } } ${shopifyFields.PAGE_INFO_FIELDS} }`;
+ const fragments = shopifyFields.CODE_DISCOUNT_TYPES.map((type) => `... on ${type} { ${codesSelection} }`).join(' ');
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ discountNode: {
+ id: string;
+ discount?: { __typename?: string; codes?: GqlConnection<GqlDiscountRedeemCode> | null } | null;
+ } | null;
+ }>({
+ auth,
+ query: `query ListDiscountRedeemCodes($id: ID!, $first: Int!, $after: String, $query: String) { discountNode(id: $id) { id discount { __typename ${fragments} } } }`,
+ variables: {
+ id,
+ first: shopifyValues.readFirst({ value: propsValue.first, max: MAX_PAGE_SIZE }),
+ after: shopifyValues.nonEmpty(propsValue.after),
+ query: shopifyValues.readRedeemCodeSearch(propsValue.query),
+ },
+ primaryPaths: ['discountNode.discount.codes'],
+ });
+ if (!data.discountNode) {
+ throw new Error(`Discount ${id} was not found.`);
+ }
+ return {
+ discount_id: id,
+ discount_type: data.discountNode.discount?.__typename ?? null,
+ ...shopifyMappers.toPage({
+ connection: data.discountNode.discount?.codes,
+ map: shopifyMappers.mapDiscountRedeemCode,
+ redactedFields,
+ }),
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/list-discounts.ts b/packages/pieces/community/shopify/src/lib/actions/ai/list-discounts.ts
new file mode 100644
index 00000000000..ad4c213ca88
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/list-discounts.ts
@@ -0,0 +1,73 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlConnection,
+ GqlDiscountNode,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { listDiscountsOutputSchema } from '../../output-schemas/fulfillment';
+
+const MAX_PAGE_SIZE = 45;
+
+export const shopifyAiListDiscounts = createAction({
+ auth: shopifyAuth,
+ name: 'list_discounts',
+ classification: 'SEARCH',
+ displayName: 'List Discounts',
+ description: 'List and search discounts (code and automatic) with their status and dates.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Lists the store\'s discounts, code and automatic, of every kind. Filter with Shopify search syntax, for example "status:active", "method:code", "method:automatic", "type:free_shipping", "title:Spring*" or "starts_at:>2026-01-01". Each item has the full discount id (gid://shopify/DiscountCodeNode/… or gid://shopify/DiscountAutomaticNode/…) that the other discount actions take, method, discount_type, title, status, summary, dates, usage count, eligibility, combinations and, for code discounts, the code count and first code. Use get_discount for value and targets. Paged: pass end_cursor back as the cursor while has_next_page is true. Needs the read_discounts access scope. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: listDiscountsOutputSchema,
+ props: {
+ query: shopifyProps.searchQuery(
+ 'Shopify discount search syntax, for example "status:active method:code" or "title:Spring*". Leave empty to list all.'
+ ),
+ sort_key: Property.StaticDropdown({
+ displayName: 'Sort By',
+ description: 'Field to sort by. Defaults to the id.',
+ required: false,
+ options: {
+ options: [
+ { label: 'ID', value: 'ID' },
+ { label: 'Title', value: 'TITLE' },
+ { label: 'Created at', value: 'CREATED_AT' },
+ { label: 'Updated at', value: 'UPDATED_AT' },
+ { label: 'Starts at', value: 'STARTS_AT' },
+ { label: 'Ends at', value: 'ENDS_AT' },
+ { label: 'Relevance (with a query)', value: 'RELEVANCE' },
+ ],
+ },
+ }),
+ reverse: shopifyProps.reverse(),
+ first: shopifyProps.first({ max: MAX_PAGE_SIZE }),
+ after: shopifyProps.after(),
+ },
+ async run({ auth, propsValue }) {
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ discountNodes: GqlConnection<GqlDiscountNode>;
+ }>({
+ auth,
+ query: `query ListDiscounts($first: Int!, $after: String, $query: String, $sortKey: DiscountSortKeys, $reverse: Boolean) { discountNodes(first: $first, after: $after, query: $query, sortKey: $sortKey, reverse: $reverse) { nodes { id discount { ${shopifyFields.DISCOUNT_SUMMARY_FIELDS} } } ${shopifyFields.PAGE_INFO_FIELDS} } }`,
+ variables: {
+ first: shopifyValues.readFirst({ value: propsValue.first, max: MAX_PAGE_SIZE }),
+ after: shopifyValues.nonEmpty(propsValue.after),
+ query: shopifyValues.nonEmpty(propsValue.query),
+ sortKey: propsValue.sort_key,
+ reverse: propsValue.reverse ?? false,
+ },
+ });
+ return shopifyMappers.toPage({
+ connection: data.discountNodes,
+ map: shopifyMappers.mapDiscountNode,
+ redactedFields,
+ });
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/list-fulfillment-events.ts b/packages/pieces/community/shopify/src/lib/actions/ai/list-fulfillment-events.ts
new file mode 100644
index 00000000000..1c611066bfd
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/list-fulfillment-events.ts
@@ -0,0 +1,79 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlConnection,
+ GqlFulfillmentEvent,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { listFulfillmentEventsOutputSchema } from '../../output-schemas/fulfillment';
+
+const MAX_PAGE_SIZE = 250;
+
+export const shopifyAiListFulfillmentEvents = createAction({
+ auth: shopifyAuth,
+ name: 'list_fulfillment_events',
+ classification: 'SEARCH',
+ displayName: 'List Fulfillment Events',
+ description: 'List the tracking events recorded on a fulfillment.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Lists the tracking events of one fulfillment (label printed, in transit, out for delivery, delivered, …) with message, time and place. Sorted by when they happened unless another sort is chosen. Paged: pass end_cursor back as the cursor while has_next_page is true. Needs the read_orders access scope. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: listFulfillmentEventsOutputSchema,
+ props: {
+ fulfillment_id: Property.ShortText({
+ displayName: 'Fulfillment ID',
+ description:
+ 'The fulfillment id, numeric or "gid://shopify/Fulfillment/…". Find it with list_order_fulfillments.',
+ required: true,
+ }),
+ sort_key: Property.StaticDropdown({
+ displayName: 'Sort By',
+ description: 'Field to sort by. Defaults to when the event happened.',
+ required: false,
+ options: {
+ options: [
+ { label: 'Happened at', value: 'HAPPENED_AT' },
+ { label: 'ID', value: 'ID' },
+ ],
+ },
+ }),
+ reverse: shopifyProps.reverse(),
+ first: shopifyProps.first({ max: MAX_PAGE_SIZE }),
+ after: shopifyProps.after(),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyGraphqlClient.toGid({ type: 'Fulfillment', id: propsValue.fulfillment_id });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ fulfillment: { id: string; events?: GqlConnection<GqlFulfillmentEvent> | null } | null;
+ }>({
+ auth,
+ query: `query ListFulfillmentEvents($id: ID!, $first: Int!, $after: String, $sortKey: FulfillmentEventSortKeys, $reverse: Boolean) { fulfillment(id: $id) { id events(first: $first, after: $after, sortKey: $sortKey, reverse: $reverse) { nodes { ${shopifyFields.FULFILLMENT_EVENT_FIELDS} } ${shopifyFields.PAGE_INFO_FIELDS} } } }`,
+ variables: {
+ id,
+ first: shopifyValues.readFirst({ value: propsValue.first, max: MAX_PAGE_SIZE }),
+ after: shopifyValues.nonEmpty(propsValue.after),
+ sortKey: propsValue.sort_key ?? 'HAPPENED_AT',
+ reverse: propsValue.reverse ?? false,
+ },
+ primaryPaths: ['fulfillment.events'],
+ });
+ if (!data.fulfillment) {
+ throw new Error(`Fulfillment ${id} was not found.`);
+ }
+ return {
+ fulfillment_id: data.fulfillment.id,
+ ...shopifyMappers.toPage({
+ connection: data.fulfillment.events,
+ map: shopifyMappers.mapFulfillmentEvent,
+ redactedFields,
+ }),
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/list-fulfillment-order-move-locations.ts b/packages/pieces/community/shopify/src/lib/actions/ai/list-fulfillment-order-move-locations.ts
new file mode 100644
index 00000000000..4a0cc63458a
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/list-fulfillment-order-move-locations.ts
@@ -0,0 +1,96 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlConnection,
+ GqlCount,
+ GqlRef,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { listFulfillmentOrderMoveLocationsOutputSchema } from '../../output-schemas/fulfillment';
+
+const MAX_PAGE_SIZE = 200;
+
+export const shopifyAiListFulfillmentOrderMoveLocations = createAction({
+ auth: shopifyAuth,
+ name: 'list_fulfillment_order_move_locations',
+ classification: 'SEARCH',
+ displayName: 'List Fulfillment Order Move Locations',
+ description: 'List the locations a fulfillment order could be moved to, and whether each one can take it.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Lists candidate locations for moving one fulfillment order. For each location: movable (true when move_fulfillment_order will accept it), a message explaining why not, and how many of the line items it can and cannot stock. Optionally narrow by location name search or by fulfillment order line item ids. Paged: pass end_cursor back as the cursor while has_next_page is true. Needs the read_merchant_managed_fulfillment_orders access scope. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: listFulfillmentOrderMoveLocationsOutputSchema,
+ props: {
+ fulfillment_order_id: Property.ShortText({
+ displayName: 'Fulfillment Order ID',
+ description:
+ 'The fulfillment order to move, numeric or "gid://shopify/FulfillmentOrder/…". Find it with list_order_fulfillment_orders.',
+ required: true,
+ }),
+ query: shopifyProps.searchQuery(
+ 'Optional location search, for example "name:Warehouse*". Leave empty to list all candidates.'
+ ),
+ line_item_ids: Property.Array({
+ displayName: 'Fulfillment Order Line Item IDs',
+ description:
+ 'Optional: only check these fulfillment order line items (line_items[].id from get_fulfillment_order). Leave empty to check all.',
+ required: false,
+ }),
+ first: shopifyProps.first({ max: MAX_PAGE_SIZE }),
+ after: shopifyProps.after(),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyGraphqlClient.toGid({ type: 'FulfillmentOrder', id: propsValue.fulfillment_order_id });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ fulfillmentOrder: { id: string; locationsForMove?: GqlConnection<GqlLocationForMove> | null } | null;
+ }>({
+ auth,
+ query: `query ListFulfillmentOrderMoveLocations($id: ID!, $first: Int!, $after: String, $query: String, $lineItemIds: [ID!]) { fulfillmentOrder(id: $id) { id locationsForMove(first: $first, after: $after, query: $query, lineItemIds: $lineItemIds) { nodes { movable message location { id name } availableLineItemsCount { count } unavailableLineItemsCount { count } } ${shopifyFields.PAGE_INFO_FIELDS} } } }`,
+ variables: {
+ id,
+ first: shopifyValues.readFirst({ value: propsValue.first, max: MAX_PAGE_SIZE }),
+ after: shopifyValues.nonEmpty(propsValue.after),
+ query: shopifyValues.nonEmpty(propsValue.query),
+ lineItemIds: shopifyValues.toGidList({ type: 'FulfillmentOrderLineItem', value: propsValue.line_item_ids }),
+ },
+ primaryPaths: ['fulfillmentOrder.locationsForMove'],
+ });
+ if (!data.fulfillmentOrder) {
+ throw new Error(`Fulfillment order ${id} was not found.`);
+ }
+ return {
+ fulfillment_order_id: data.fulfillmentOrder.id,
+ ...shopifyMappers.toPage({
+ connection: data.fulfillmentOrder.locationsForMove,
+ map: mapLocationForMove,
+ redactedFields,
+ }),
+ };
+ },
+});
+
+function mapLocationForMove(entry: GqlLocationForMove) {
+ return {
+ location_id: entry.location?.id ?? null,
+ location_name: entry.location?.name ?? null,
+ movable: entry.movable ?? null,
+ message: entry.message ?? null,
+ available_line_items_count: entry.availableLineItemsCount?.count ?? null,
+ unavailable_line_items_count: entry.unavailableLineItemsCount?.count ?? null,
+ };
+}
+
+type GqlLocationForMove = {
+ movable?: boolean | null;
+ message?: string | null;
+ location?: GqlRef | null;
+ availableLineItemsCount?: GqlCount | null;
+ unavailableLineItemsCount?: GqlCount | null;
+};
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/list-fulfillment-services.ts b/packages/pieces/community/shopify/src/lib/actions/ai/list-fulfillment-services.ts
new file mode 100644
index 00000000000..e6c23309fda
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/list-fulfillment-services.ts
@@ -0,0 +1,40 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlFulfillmentService,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+} from '../../common/graphql';
+import { listFulfillmentServicesOutputSchema } from '../../output-schemas/fulfillment';
+
+export const shopifyAiListFulfillmentServices = createAction({
+ auth: shopifyAuth,
+ name: 'list_fulfillment_services',
+ classification: 'SEARCH',
+ displayName: 'List Fulfillment Services',
+ description: 'List the fulfillment services installed on the store.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Lists the store\'s fulfillment services (third-party warehouses, gift card and manual services) with handle, name, type, callback URL, whether they manage inventory or support tracking, and the location each one uses. Returns the full list in one call (no paging). Needs the read_fulfillments access scope. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: listFulfillmentServicesOutputSchema,
+ props: {},
+ async run({ auth }) {
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ shop: { fulfillmentServices?: GqlFulfillmentService[] | null } | null;
+ }>({
+ auth,
+ query: `query ListFulfillmentServices { shop { fulfillmentServices { ${shopifyFields.FULFILLMENT_SERVICE_FIELDS} } } }`,
+ primaryPaths: ['shop.fulfillmentServices'],
+ });
+ const items = (data.shop?.fulfillmentServices ?? []).map(shopifyMappers.mapFulfillmentService);
+ return {
+ items,
+ count: items.length,
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/list-order-fulfillment-orders.ts b/packages/pieces/community/shopify/src/lib/actions/ai/list-order-fulfillment-orders.ts
new file mode 100644
index 00000000000..6ff7dab1bbe
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/list-order-fulfillment-orders.ts
@@ -0,0 +1,68 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlConnection,
+ GqlFulfillmentOrder,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { listOrderFulfillmentOrdersOutputSchema } from '../../output-schemas/fulfillment';
+
+const MAX_PAGE_SIZE = 4;
+
+export const shopifyAiListOrderFulfillmentOrders = createAction({
+ auth: shopifyAuth,
+ name: 'list_order_fulfillment_orders',
+ classification: 'SEARCH',
+ displayName: 'List Order Fulfillment Orders',
+ description: 'List the fulfillment orders of an order: what still has to be shipped, from which location.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Lists the fulfillment orders of one order. Each fulfillment order groups the items to ship from one location and carries its status (OPEN, IN_PROGRESS, ON_HOLD, SCHEDULED, CLOSED, CANCELLED), holds, supported actions and line items with remaining quantities (up to 50 per fulfillment order; line_items_truncated tells when there are more). Call this before create_fulfillment, hold_fulfillment_order or move_fulfillment_order: those take the fulfillment order id and the fulfillment order line item ids from here, not the order line item ids. Destination name, email and phone may be redacted on Basic-plan stores (see redacted_fields). Paged: pass end_cursor back as the cursor while has_next_page is true. Needs the read_merchant_managed_fulfillment_orders access scope. Read-only. Each fulfillment order carries up to 50 line items; when line_items_truncated is true, read the rest with get_fulfillment_order and line_items_after.',
+ idempotent: true,
+ },
+ outputSchema: listOrderFulfillmentOrdersOutputSchema,
+ props: {
+ order_id: Property.ShortText({
+ displayName: 'Order ID',
+ description: 'The order id, numeric or "gid://shopify/Order/…". Find it with search_orders.',
+ required: true,
+ }),
+ query: shopifyProps.searchQuery(
+ 'Optional Shopify search syntax on the fulfillment orders, for example "status:open". Leave empty to list all.'
+ ),
+ first: shopifyProps.first({ max: MAX_PAGE_SIZE }),
+ after: shopifyProps.after(),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyGraphqlClient.toGid({ type: 'Order', id: propsValue.order_id });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ order: { id: string; fulfillmentOrders?: GqlConnection<GqlFulfillmentOrder> | null } | null;
+ }>({
+ auth,
+ query: `query ListOrderFulfillmentOrders($id: ID!, $first: Int!, $after: String, $query: String) { order(id: $id) { id fulfillmentOrders(first: $first, after: $after, query: $query) { nodes { ${shopifyFields.FULFILLMENT_ORDER_FIELDS} } ${shopifyFields.PAGE_INFO_FIELDS} } } }`,
+ variables: {
+ id,
+ first: shopifyValues.readFirst({ value: propsValue.first, max: MAX_PAGE_SIZE }),
+ after: shopifyValues.nonEmpty(propsValue.after),
+ query: shopifyValues.nonEmpty(propsValue.query),
+ },
+ primaryPaths: ['order.fulfillmentOrders'],
+ });
+ if (!data.order) {
+ throw new Error(`Order ${id} was not found.`);
+ }
+ return {
+ order_id: data.order.id,
+ ...shopifyMappers.toPage({
+ connection: data.order.fulfillmentOrders,
+ map: shopifyMappers.mapFulfillmentOrder,
+ redactedFields,
+ }),
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/list-order-fulfillments.ts b/packages/pieces/community/shopify/src/lib/actions/ai/list-order-fulfillments.ts
new file mode 100644
index 00000000000..8dbd04457a3
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/list-order-fulfillments.ts
@@ -0,0 +1,58 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlCount,
+ GqlFulfillment,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+} from '../../common/graphql';
+import { listOrderFulfillmentsOutputSchema } from '../../output-schemas/fulfillment';
+
+export const shopifyAiListOrderFulfillments = createAction({
+ auth: shopifyAuth,
+ name: 'list_order_fulfillments',
+ classification: 'SEARCH',
+ displayName: 'List Order Fulfillments',
+ description: 'List the fulfillments (shipments) of an order with their tracking.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Lists the fulfillments (shipments already recorded) of one order, up to 50, with status, shipment status, tracking company, numbers and URLs, location and dates. Returns the list in one call (no paging): total_count is Shopify\'s count of fulfillments on the order, and truncated=true means total_count is larger than the number returned, so only the first 50 are listed. Use get_fulfillment_details for the shipped line items of one fulfillment. Needs the read_orders access scope. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: listOrderFulfillmentsOutputSchema,
+ props: {
+ order_id: Property.ShortText({
+ displayName: 'Order ID',
+ description: 'The order id, numeric or "gid://shopify/Order/…". Find it with search_orders.',
+ required: true,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyGraphqlClient.toGid({ type: 'Order', id: propsValue.order_id });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ order: { id: string; fulfillmentsCount?: GqlCount | null; fulfillments?: GqlFulfillment[] | null } | null;
+ }>({
+ auth,
+ query: `query ListOrderFulfillments($id: ID!) { order(id: $id) { id fulfillmentsCount { count } fulfillments(first: ${FULFILLMENT_LIMIT}) { ${shopifyFields.FULFILLMENT_SUMMARY_FIELDS} } } }`,
+ variables: { id },
+ primaryPaths: ['order.fulfillments'],
+ });
+ if (!data.order) {
+ throw new Error(`Order ${id} was not found.`);
+ }
+ const items = (data.order.fulfillments ?? []).map(shopifyMappers.mapFulfillmentSummary);
+ const totalCount = data.order.fulfillmentsCount?.count ?? null;
+ return {
+ order_id: data.order.id,
+ items,
+ count: items.length,
+ total_count: totalCount,
+ truncated: totalCount === null ? items.length === FULFILLMENT_LIMIT : totalCount > items.length,
+ redacted_fields: redactedFields,
+ };
+ },
+});
+
+const FULFILLMENT_LIMIT = 50;
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/move-fulfillment-order.ts b/packages/pieces/community/shopify/src/lib/actions/ai/move-fulfillment-order.ts
new file mode 100644
index 00000000000..4fcb967191b
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/move-fulfillment-order.ts
@@ -0,0 +1,70 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlFulfillmentOrder,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { moveFulfillmentOrderOutputSchema } from '../../output-schemas/fulfillment';
+
+export const shopifyAiMoveFulfillmentOrder = createAction({
+ auth: shopifyAuth,
+ name: 'move_fulfillment_order',
+ classification: 'WRITE',
+ displayName: 'Move Fulfillment Order',
+ description: 'Ship a fulfillment order (or some of its items) from a different location.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Moves one fulfillment order, or some of its items, to another location that will ship them. Check first with list_fulfillment_order_move_locations which locations are movable. Leave line_items empty to move everything; with line_items only those quantities move and Shopify splits the fulfillment order. Returns moved_fulfillment_order (now at the new location), original_fulfillment_order and remaining_fulfillment_order (what stayed behind, if any). Each call moves again, so do not repeat it after a success. Needs the write_merchant_managed_fulfillment_orders access scope.',
+ idempotent: false,
+ },
+ outputSchema: moveFulfillmentOrderOutputSchema,
+ props: {
+ fulfillment_order_id: Property.ShortText({
+ displayName: 'Fulfillment Order ID',
+ description:
+ 'The fulfillment order to move, numeric or "gid://shopify/FulfillmentOrder/…". Find it with list_order_fulfillment_orders.',
+ required: true,
+ }),
+ new_location_id: Property.ShortText({
+ displayName: 'New Location ID',
+ description:
+ 'The location that should ship the items, numeric or "gid://shopify/Location/…". Find a movable one with list_fulfillment_order_move_locations.',
+ required: true,
+ }),
+ line_items: shopifyProps.fulfillmentOrderLineItems({
+ description:
+ 'Optional partial move: the fulfillment order line items and quantities to move. Leave empty to move the whole fulfillment order.',
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyGraphqlClient.toGid({ type: 'FulfillmentOrder', id: propsValue.fulfillment_order_id });
+ const newLocationId = shopifyGraphqlClient.toGid({ type: 'Location', id: propsValue.new_location_id });
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ fulfillmentOrderMove: {
+ movedFulfillmentOrder: GqlFulfillmentOrder | null;
+ originalFulfillmentOrder: GqlFulfillmentOrder | null;
+ remainingFulfillmentOrder: GqlFulfillmentOrder | null;
+ } | null;
+ }>({
+ auth,
+ query: `mutation MoveFulfillmentOrder($id: ID!, $newLocationId: ID!, $fulfillmentOrderLineItems: [FulfillmentOrderLineItemInput!]) { fulfillmentOrderMove(id: $id, newLocationId: $newLocationId, fulfillmentOrderLineItems: $fulfillmentOrderLineItems) { movedFulfillmentOrder { ${shopifyFields.FULFILLMENT_ORDER_FIELDS} } originalFulfillmentOrder { ${shopifyFields.FULFILLMENT_ORDER_FIELDS} } remainingFulfillmentOrder { ${shopifyFields.FULFILLMENT_ORDER_FIELDS} } userErrors { field message code } } }`,
+ variables: {
+ id,
+ newLocationId,
+ fulfillmentOrderLineItems: shopifyValues.buildFulfillmentOrderLineItems(propsValue.line_items),
+ },
+ });
+ const payload = data.fulfillmentOrderMove;
+ return {
+ moved_fulfillment_order: shopifyMappers.mapFulfillmentOrderOrNull(payload?.movedFulfillmentOrder),
+ original_fulfillment_order: shopifyMappers.mapFulfillmentOrderOrNull(payload?.originalFulfillmentOrder),
+ remaining_fulfillment_order: shopifyMappers.mapFulfillmentOrderOrNull(payload?.remainingFulfillmentOrder),
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/release-fulfillment-order-hold.ts b/packages/pieces/community/shopify/src/lib/actions/ai/release-fulfillment-order-hold.ts
new file mode 100644
index 00000000000..76fa7d2da76
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/release-fulfillment-order-hold.ts
@@ -0,0 +1,87 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlFulfillmentOrder,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyValues,
+} from '../../common/graphql';
+import { releaseFulfillmentOrderHoldOutputSchema } from '../../output-schemas/fulfillment';
+
+export const shopifyAiReleaseFulfillmentOrderHold = createAction({
+ auth: shopifyAuth,
+ name: 'release_fulfillment_order_hold',
+ classification: 'WRITE',
+ displayName: 'Release Fulfillment Order Hold',
+ description: 'Release holds on a fulfillment order so it can be shipped.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Releases fulfillment holds on one fulfillment order and returns the fulfillment order. release_scope is required: LISTED_HOLDS releases only the hold ids you pass (recommended; get them from get_fulfillment_order holds[].id), ALL_HOLDS releases every hold on the fulfillment order, including holds placed by other apps or staff, which can let items ship too early. When the last hold is gone the fulfillment order becomes fulfillable again. Releasing holds that are already released leaves the same state (confirm at Tier-2). Needs the write_merchant_managed_fulfillment_orders access scope.',
+ idempotent: true,
+ },
+ outputSchema: releaseFulfillmentOrderHoldOutputSchema,
+ props: {
+ fulfillment_order_id: Property.ShortText({
+ displayName: 'Fulfillment Order ID',
+ description:
+ 'The held fulfillment order, numeric or "gid://shopify/FulfillmentOrder/…". Find it with list_order_fulfillment_orders.',
+ required: true,
+ }),
+ release_scope: Property.StaticDropdown({
+ displayName: 'Release Scope',
+ description: 'Release only the listed holds, or every hold on the fulfillment order.',
+ required: true,
+ options: {
+ options: [
+ { label: 'Only the listed holds', value: 'LISTED_HOLDS' },
+ { label: 'All holds on the fulfillment order', value: 'ALL_HOLDS' },
+ ],
+ },
+ }),
+ hold_ids: Property.Array({
+ displayName: 'Hold IDs',
+ description:
+ 'The holds to release, for example "gid://shopify/FulfillmentHold/123". Required with LISTED_HOLDS, must be empty with ALL_HOLDS.',
+ required: false,
+ }),
+ external_id: Property.ShortText({
+ displayName: 'External ID',
+ description: 'Optional id from your own system that releases the hold.',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyGraphqlClient.toGid({ type: 'FulfillmentOrder', id: propsValue.fulfillment_order_id });
+ const holdIds = shopifyValues.toGidList({ type: 'FulfillmentHold', value: propsValue.hold_ids });
+ if (propsValue.release_scope === 'LISTED_HOLDS' && !holdIds) {
+ throw new Error('release_scope LISTED_HOLDS needs at least one hold id. Nothing was changed.');
+ }
+ if (propsValue.release_scope === 'ALL_HOLDS' && holdIds) {
+ throw new Error(
+ 'release_scope ALL_HOLDS releases every hold; leave hold_ids empty, or use LISTED_HOLDS. Nothing was changed.'
+ );
+ }
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ fulfillmentOrderReleaseHold: { fulfillmentOrder: GqlFulfillmentOrder | null } | null;
+ }>({
+ auth,
+ query: `mutation ReleaseFulfillmentOrderHold($id: ID!, $holdIds: [ID!], $externalId: String) { fulfillmentOrderReleaseHold(id: $id, holdIds: $holdIds, externalId: $externalId) { fulfillmentOrder { ${shopifyFields.FULFILLMENT_ORDER_FIELDS} } userErrors { field message code } } }`,
+ variables: {
+ id,
+ holdIds,
+ externalId: shopifyValues.nonEmpty(propsValue.external_id),
+ },
+ });
+ const fulfillmentOrder = data.fulfillmentOrderReleaseHold?.fulfillmentOrder;
+ if (!fulfillmentOrder) {
+ throw new Error('Shopify did not return the fulfillment order.');
+ }
+ return {
+ ...shopifyMappers.mapFulfillmentOrder(fulfillmentOrder),
+ released_hold_ids: holdIds ?? [],
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/search-gift-cards.ts b/packages/pieces/community/shopify/src/lib/actions/ai/search-gift-cards.ts
new file mode 100644
index 00000000000..6a142c4a763
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/search-gift-cards.ts
@@ -0,0 +1,76 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlConnection,
+ GqlGiftCard,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { searchGiftCardsOutputSchema } from '../../output-schemas/fulfillment';
+
+const MAX_PAGE_SIZE = 110;
+
+export const shopifyAiSearchGiftCards = createAction({
+ auth: shopifyAuth,
+ name: 'search_gift_cards',
+ classification: 'SEARCH',
+ displayName: 'Search Gift Cards',
+ description: 'Search gift cards by status, balance, customer, code ending and more.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Searches the store\'s gift cards with Shopify search syntax, for example "status:enabled", "balance_status:partial", "initial_value:10", "customer_id:123" or "created_at:>2026-01-01". To find a card by its code, pass the full code or its last 4 characters as plain text (for example "1234"); Shopify ignores a "last_characters:" filter and would return every card. Plain text does not match the note. Returns balance, initial value, status, expiry, owner and the last characters of each code (never the full code). Paged: pass end_cursor back as the cursor while has_next_page is true. Needs the read_gift_cards access scope. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: searchGiftCardsOutputSchema,
+ props: {
+ query: shopifyProps.searchQuery(
+ 'Shopify gift card search syntax, for example "status:enabled balance_status:partial", or a code or its last 4 characters as plain text such as "1234". Leave empty to list all.'
+ ),
+ sort_key: Property.StaticDropdown({
+ displayName: 'Sort By',
+ description: 'Field to sort by. Defaults to the id.',
+ required: false,
+ options: {
+ options: [
+ { label: 'ID', value: 'ID' },
+ { label: 'Created at', value: 'CREATED_AT' },
+ { label: 'Updated at', value: 'UPDATED_AT' },
+ { label: 'Balance', value: 'BALANCE' },
+ { label: 'Initial value', value: 'INITIAL_VALUE' },
+ { label: 'Amount spent', value: 'AMOUNT_SPENT' },
+ { label: 'Expires on', value: 'EXPIRES_ON' },
+ { label: 'Disabled at', value: 'DISABLED_AT' },
+ { label: 'Customer name', value: 'CUSTOMER_NAME' },
+ { label: 'Code', value: 'CODE' },
+ ],
+ },
+ }),
+ reverse: shopifyProps.reverse(),
+ first: shopifyProps.first({ max: MAX_PAGE_SIZE }),
+ after: shopifyProps.after(),
+ },
+ async run({ auth, propsValue }) {
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ giftCards: GqlConnection<GqlGiftCard>;
+ }>({
+ auth,
+ query: `query SearchGiftCards($first: Int!, $after: String, $query: String, $sortKey: GiftCardSortKeys, $reverse: Boolean) { giftCards(first: $first, after: $after, query: $query, sortKey: $sortKey, reverse: $reverse) { nodes { ${shopifyFields.GIFT_CARD_FIELDS} } ${shopifyFields.PAGE_INFO_FIELDS} } }`,
+ variables: {
+ first: shopifyValues.readFirst({ value: propsValue.first, max: MAX_PAGE_SIZE }),
+ after: shopifyValues.nonEmpty(propsValue.after),
+ query: shopifyValues.nonEmpty(propsValue.query),
+ sortKey: propsValue.sort_key,
+ reverse: propsValue.reverse ?? false,
+ },
+ });
+ return shopifyMappers.toPage({
+ connection: data.giftCards,
+ map: shopifyMappers.mapGiftCard,
+ redactedFields,
+ });
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/set-fulfillment-orders-deadline.ts b/packages/pieces/community/shopify/src/lib/actions/ai/set-fulfillment-orders-deadline.ts
new file mode 100644
index 00000000000..41ffadb7b08
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/set-fulfillment-orders-deadline.ts
@@ -0,0 +1,58 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import { shopifyGraphqlClient, shopifyValues } from '../../common/graphql';
+import { setFulfillmentOrdersDeadlineOutputSchema } from '../../output-schemas/fulfillment';
+
+export const shopifyAiSetFulfillmentOrdersDeadline = createAction({
+ auth: shopifyAuth,
+ name: 'set_fulfillment_orders_deadline',
+ classification: 'WRITE',
+ displayName: 'Set Fulfillment Orders Deadline',
+ description: 'Set the date by which one or more fulfillment orders must be fulfilled.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Sets the same fulfillment deadline (fulfill_by) on one or more fulfillment orders. Returns success. Setting the same deadline again leaves the same state. Read the result back with get_fulfillment_order. Needs the write_merchant_managed_fulfillment_orders access scope.',
+ idempotent: true,
+ },
+ outputSchema: setFulfillmentOrdersDeadlineOutputSchema,
+ props: {
+ fulfillment_order_ids: Property.Array({
+ displayName: 'Fulfillment Order IDs',
+ description:
+ 'The fulfillment orders, numeric or "gid://shopify/FulfillmentOrder/…". Find them with list_order_fulfillment_orders.',
+ required: true,
+ }),
+ deadline: Property.DateTime({
+ displayName: 'Deadline',
+ description: 'The date and time by which they must be fulfilled, ISO 8601, for example "2026-10-01T17:00:00Z".',
+ required: true,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const fulfillmentOrderIds = shopifyValues.toGidList({
+ type: 'FulfillmentOrder',
+ value: propsValue.fulfillment_order_ids,
+ });
+ if (!fulfillmentOrderIds) {
+ throw new Error('Provide at least one fulfillment order id. Nothing was changed.');
+ }
+ const fulfillmentDeadline = shopifyValues.nonEmpty(propsValue.deadline);
+ if (!fulfillmentDeadline) {
+ throw new Error('Provide the deadline. Nothing was changed.');
+ }
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ fulfillmentOrdersSetFulfillmentDeadline: { success?: boolean | null } | null;
+ }>({
+ auth,
+ query: `mutation SetFulfillmentOrdersDeadline($fulfillmentOrderIds: [ID!]!, $fulfillmentDeadline: DateTime!) { fulfillmentOrdersSetFulfillmentDeadline(fulfillmentOrderIds: $fulfillmentOrderIds, fulfillmentDeadline: $fulfillmentDeadline) { success userErrors { field message code } } }`,
+ variables: { fulfillmentOrderIds, fulfillmentDeadline },
+ });
+ return {
+ success: data.fulfillmentOrdersSetFulfillmentDeadline?.success ?? false,
+ fulfillment_order_ids: fulfillmentOrderIds,
+ deadline: fulfillmentDeadline,
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/update-basic-discount-code.ts b/packages/pieces/community/shopify/src/lib/actions/ai/update-basic-discount-code.ts
new file mode 100644
index 00000000000..68634c936e6
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/update-basic-discount-code.ts
@@ -0,0 +1,269 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlDiscountNode,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { discountOutputSchema } from '../../output-schemas/fulfillment';
+
+export const shopifyAiUpdateBasicDiscountCode = createAction({
+ auth: shopifyAuth,
+ name: 'update_basic_discount_code',
+ classification: 'WRITE',
+ displayName: 'Update Amount-Off Discount Code',
+ description: 'Change an existing percentage or fixed-amount discount code.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Updates one amount-off code discount (created by create_basic_discount_code or in the admin) and returns it. Only the fields you supply are sent; an empty update is rejected. Several parts are REPLACED as a whole when sent, so send them complete: (1) the discount value and target: value_type, value and applies_to must be given together, and with PRODUCTS or COLLECTIONS the ids go in the *_to_add lists (ids to drop in *_to_remove). To change only the value of a product or collection discount, read it with get_discount and re-send its applies_to with one of its current product_ids, variant_ids or collection_ids in the matching *_to_add list, which keeps the targets unchanged; (2) eligibility with its customer or segment ids; (3) combines_with: all three combines_with_* choices together; (4) tags: the full tag list. minimum_requirement NONE removes the minimum; remove_end_date Yes clears the end date so the code never expires, and remove_usage_limit Yes clears the total usage limit (neither can be combined with a new ends_at or usage_limit). Takes the code discount id (gid://shopify/DiscountCodeNode/… or its plain number). Repeating the same update leaves the same state. Automatic discounts cannot be edited here. Needs the write_discounts access scope.',
+ idempotent: true,
+ },
+ outputSchema: discountOutputSchema,
+ props: {
+ discount_id: Property.ShortText({
+ displayName: 'Discount ID',
+ description:
+ 'The code discount id, for example "gid://shopify/DiscountCodeNode/123" or "123". Get it from list_discounts, get_discount or find_discount_by_code.',
+ required: true,
+ }),
+ title: Property.ShortText({
+ displayName: 'Title',
+ description: 'New internal title. Leave empty to keep it.',
+ required: false,
+ }),
+ code: Property.ShortText({
+ displayName: 'Code',
+ description: 'New code customers enter. Leave empty to keep it.',
+ required: false,
+ }),
+ starts_at: Property.DateTime({
+ displayName: 'Starts At',
+ description: 'New start, ISO 8601. Leave empty to keep it.',
+ required: false,
+ }),
+ ends_at: Property.DateTime({
+ displayName: 'Ends At',
+ description: 'New end, ISO 8601. Leave empty to keep it. To remove the end date use remove_end_date.',
+ required: false,
+ }),
+ remove_end_date: shopifyProps.booleanChoice({
+ displayName: 'Remove End Date',
+ description: 'Yes: clear the end date so the code no longer expires. Cannot be combined with ends_at. Leave unset to keep the end date.',
+ }),
+ value_type: Property.StaticDropdown({
+ displayName: 'Value Type',
+ description: 'Percentage or fixed amount. Send together with value and applies_to.',
+ required: false,
+ options: {
+ options: [
+ { label: 'Percentage', value: 'PERCENTAGE' },
+ { label: 'Fixed amount', value: 'FIXED_AMOUNT' },
+ ],
+ },
+ }),
+ value: Property.Number({
+ displayName: 'Value',
+ description: 'For PERCENTAGE the percent (15 means 15% off). For FIXED_AMOUNT the amount in the shop currency.',
+ required: false,
+ }),
+ applies_on_each_item: shopifyProps.booleanChoice({
+ displayName: 'Apply Amount To Each Item',
+ description: 'FIXED_AMOUNT only: Yes takes the amount off every eligible item, No once per order.',
+ }),
+ applies_to: Property.StaticDropdown({
+ displayName: 'Applies To',
+ description: 'What the discount applies to. Send together with value_type and value.',
+ required: false,
+ options: {
+ options: [
+ { label: 'All items', value: 'ALL' },
+ { label: 'Specific products or variants', value: 'PRODUCTS' },
+ { label: 'Specific collections', value: 'COLLECTIONS' },
+ ],
+ },
+ }),
+ product_ids_to_add: shopifyProps.idList({
+ displayName: 'Product IDs To Add',
+ description: 'With applies_to PRODUCTS: products the discount applies to, numeric or "gid://shopify/Product/…".',
+ }),
+ product_ids_to_remove: shopifyProps.idList({
+ displayName: 'Product IDs To Remove',
+ description: 'With applies_to PRODUCTS: products to take out of the discount.',
+ }),
+ variant_ids_to_add: shopifyProps.idList({
+ displayName: 'Variant IDs To Add',
+ description: 'With applies_to PRODUCTS: variants the discount applies to, numeric or "gid://shopify/ProductVariant/…".',
+ }),
+ variant_ids_to_remove: shopifyProps.idList({
+ displayName: 'Variant IDs To Remove',
+ description: 'With applies_to PRODUCTS: variants to take out of the discount.',
+ }),
+ collection_ids_to_add: shopifyProps.idList({
+ displayName: 'Collection IDs To Add',
+ description: 'With applies_to COLLECTIONS: collections the discount applies to, numeric or "gid://shopify/Collection/…".',
+ }),
+ collection_ids_to_remove: shopifyProps.idList({
+ displayName: 'Collection IDs To Remove',
+ description: 'With applies_to COLLECTIONS: collections to take out of the discount.',
+ }),
+ eligibility: Property.StaticDropdown({
+ displayName: 'Eligibility',
+ description: 'Who can use the code. Replaces the current eligibility.',
+ required: false,
+ options: {
+ options: [
+ { label: 'All buyers', value: 'ALL' },
+ { label: 'Specific customers', value: 'CUSTOMERS' },
+ { label: 'Customer segments', value: 'SEGMENTS' },
+ ],
+ },
+ }),
+ customer_ids_to_add: shopifyProps.idList({
+ displayName: 'Customer IDs To Add',
+ description: 'With eligibility CUSTOMERS: customers who can use the code, numeric or "gid://shopify/Customer/…".',
+ }),
+ customer_ids_to_remove: shopifyProps.idList({
+ displayName: 'Customer IDs To Remove',
+ description: 'With eligibility CUSTOMERS: customers who should no longer be able to use it.',
+ }),
+ segment_ids_to_add: shopifyProps.idList({
+ displayName: 'Segment IDs To Add',
+ description: 'With eligibility SEGMENTS: segments that can use the code, numeric or "gid://shopify/Segment/…".',
+ }),
+ segment_ids_to_remove: shopifyProps.idList({
+ displayName: 'Segment IDs To Remove',
+ description: 'With eligibility SEGMENTS: segments that should no longer be able to use it.',
+ }),
+ minimum_requirement: Property.StaticDropdown({
+ displayName: 'Minimum Requirement',
+ description: 'New minimum, or NONE to remove it. Leave unset to keep the current one.',
+ required: false,
+ options: {
+ options: [
+ { label: 'None (remove the minimum)', value: 'NONE' },
+ { label: 'Minimum subtotal', value: 'SUBTOTAL' },
+ { label: 'Minimum quantity of items', value: 'QUANTITY' },
+ ],
+ },
+ }),
+ minimum_value: Property.Number({
+ displayName: 'Minimum Value',
+ description: 'With SUBTOTAL or QUANTITY: the subtotal or the whole-number item quantity.',
+ required: false,
+ }),
+ usage_limit: Property.Number({
+ displayName: 'Usage Limit',
+ description: 'New total usage limit, a whole number of 1 or more. Leave empty to keep it. To remove the limit use remove_usage_limit.',
+ required: false,
+ }),
+ remove_usage_limit: shopifyProps.booleanChoice({
+ displayName: 'Remove Usage Limit',
+ description: 'Yes: clear the total usage limit so the code can be used any number of times. Cannot be combined with usage_limit. Leave unset to keep the limit.',
+ }),
+ applies_once_per_customer: shopifyProps.booleanChoice({
+ displayName: 'Once Per Customer',
+ description: 'Yes: each customer can use it once. No: no per-customer limit. Leave unset to keep it.',
+ }),
+ combines_with_product_discounts: shopifyProps.booleanChoice({
+ displayName: 'Combines With Product Discounts',
+ description: 'Set all three combines_with choices together; they replace the current combinations.',
+ }),
+ combines_with_order_discounts: shopifyProps.booleanChoice({
+ displayName: 'Combines With Order Discounts',
+ description: 'Set all three combines_with choices together; they replace the current combinations.',
+ }),
+ combines_with_shipping_discounts: shopifyProps.booleanChoice({
+ displayName: 'Combines With Shipping Discounts',
+ description: 'Set all three combines_with choices together; they replace the current combinations.',
+ }),
+ tags: Property.Array({
+ displayName: 'Tags',
+ description: 'The complete new tag list; replaces the current tags. Leave empty to keep them.',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyValues.toDiscountCodeNodeId(propsValue.discount_id);
+ const value = shopifyValues.buildDiscountValue({
+ valueType: propsValue.value_type,
+ value: shopifyValues.readNumber(propsValue.value),
+ appliesOnEachItem: shopifyValues.toBooleanChoice(propsValue.applies_on_each_item),
+ });
+ const items = shopifyValues.buildDiscountItems({
+ appliesTo: propsValue.applies_to,
+ productIdsToAdd: propsValue.product_ids_to_add,
+ productIdsToRemove: propsValue.product_ids_to_remove,
+ variantIdsToAdd: propsValue.variant_ids_to_add,
+ variantIdsToRemove: propsValue.variant_ids_to_remove,
+ collectionIdsToAdd: propsValue.collection_ids_to_add,
+ collectionIdsToRemove: propsValue.collection_ids_to_remove,
+ });
+ if ((value === undefined) !== (items === undefined)) {
+ throw new Error(
+ 'The discount value and target are replaced together: send value_type, value and applies_to in the same call. Nothing was changed.'
+ );
+ }
+ const usageLimit = shopifyValues.readNumber(propsValue.usage_limit);
+ if (usageLimit !== undefined && (!Number.isInteger(usageLimit) || usageLimit < 1)) {
+ throw new Error('usage_limit must be a whole number of 1 or more. Nothing was changed.');
+ }
+ const basicCodeDiscount = shopifyValues.compact({
+ title: shopifyValues.nonEmpty(propsValue.title),
+ code: shopifyValues.nonEmpty(propsValue.code),
+ startsAt: shopifyValues.nonEmpty(propsValue.starts_at),
+ endsAt: shopifyValues.clearableValue({
+ value: shopifyValues.nonEmpty(propsValue.ends_at),
+ clear: shopifyValues.toBooleanChoice(propsValue.remove_end_date),
+ valueName: 'ends_at',
+ clearName: 'remove_end_date',
+ }),
+ customerGets: value && items ? { value, items } : undefined,
+ context: shopifyValues.buildDiscountContext({
+ eligibility: propsValue.eligibility,
+ customerIdsToAdd: propsValue.customer_ids_to_add,
+ customerIdsToRemove: propsValue.customer_ids_to_remove,
+ segmentIdsToAdd: propsValue.segment_ids_to_add,
+ segmentIdsToRemove: propsValue.segment_ids_to_remove,
+ }),
+ minimumRequirement: shopifyValues.buildMinimumRequirement({
+ kind: propsValue.minimum_requirement,
+ value: shopifyValues.readNumber(propsValue.minimum_value),
+ }),
+ usageLimit: shopifyValues.clearableValue({
+ value: usageLimit,
+ clear: shopifyValues.toBooleanChoice(propsValue.remove_usage_limit),
+ valueName: 'usage_limit',
+ clearName: 'remove_usage_limit',
+ }),
+ appliesOncePerCustomer: shopifyValues.toBooleanChoice(propsValue.applies_once_per_customer),
+ combinesWith: shopifyValues.buildCombinesWith({
+ productDiscounts: shopifyValues.toBooleanChoice(propsValue.combines_with_product_discounts),
+ orderDiscounts: shopifyValues.toBooleanChoice(propsValue.combines_with_order_discounts),
+ shippingDiscounts: shopifyValues.toBooleanChoice(propsValue.combines_with_shipping_discounts),
+ }),
+ tags: shopifyValues.nonEmptyList(propsValue.tags),
+ });
+ if (Object.keys(basicCodeDiscount).length === 0) {
+ throw new Error('Nothing to update: provide at least one field to change. Nothing was changed.');
+ }
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ discountCodeBasicUpdate: { codeDiscountNode: GqlDiscountNode | null } | null;
+ }>({
+ auth,
+ query: `mutation UpdateBasicDiscountCode($id: ID!, $basicCodeDiscount: DiscountCodeBasicInput!) { discountCodeBasicUpdate(id: $id, basicCodeDiscount: $basicCodeDiscount) { codeDiscountNode { id discount: codeDiscount { ${shopifyFields.CODE_DISCOUNT_DETAIL_FIELDS} } } userErrors { field message code } } }`,
+ variables: { id, basicCodeDiscount },
+ });
+ const node = data.discountCodeBasicUpdate?.codeDiscountNode;
+ if (!node) {
+ throw new Error('Shopify did not return the updated discount.');
+ }
+ return {
+ ...shopifyMappers.mapDiscountNode(node),
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/update-free-shipping-discount-code.ts b/packages/pieces/community/shopify/src/lib/actions/ai/update-free-shipping-discount-code.ts
new file mode 100644
index 00000000000..2fa05254a27
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/update-free-shipping-discount-code.ts
@@ -0,0 +1,274 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlDiscountNode,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyProps,
+ shopifyValues,
+} from '../../common/graphql';
+import { discountOutputSchema } from '../../output-schemas/fulfillment';
+
+export const shopifyAiUpdateFreeShippingDiscountCode = createAction({
+ auth: shopifyAuth,
+ name: 'update_free_shipping_discount_code',
+ classification: 'WRITE',
+ displayName: 'Update Free Shipping Discount Code',
+ description: 'Change an existing free shipping discount code.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Updates one free shipping code discount (created by create_free_shipping_discount_code or in the admin) and returns it. Only the fields you supply are sent; an empty update is rejected. Several parts are REPLACED as a whole when sent, so send them complete: (1) destination: ALL countries, or COUNTRIES with the codes to add in country_codes_to_add and the codes to drop in country_codes_to_remove (left unset, it becomes COUNTRIES when any country code is given); (2) eligibility with its customer or segment ids; (3) combines_with: all three combines_with_* choices together; (4) tags: the full tag list. minimum_requirement NONE removes the minimum; remove_end_date Yes clears the end date so the code never expires, and remove_usage_limit Yes clears the total usage limit (neither can be combined with a new ends_at or usage_limit). Takes the code discount id (gid://shopify/DiscountCodeNode/… or its plain number). Read the current settings with get_discount first. Repeating the same update leaves the same state. Amount-off codes are edited with update_basic_discount_code; automatic discounts cannot be edited here. Needs the write_discounts access scope.',
+ idempotent: true,
+ },
+ outputSchema: discountOutputSchema,
+ props: {
+ discount_id: Property.ShortText({
+ displayName: 'Discount ID',
+ description:
+ 'The code discount id, for example "gid://shopify/DiscountCodeNode/123" or "123". Get it from list_discounts, get_discount or find_discount_by_code.',
+ required: true,
+ }),
+ title: Property.ShortText({
+ displayName: 'Title',
+ description: 'New internal title. Leave empty to keep it.',
+ required: false,
+ }),
+ code: Property.ShortText({
+ displayName: 'Code',
+ description: 'New code customers enter. Leave empty to keep it.',
+ required: false,
+ }),
+ starts_at: Property.DateTime({
+ displayName: 'Starts At',
+ description: 'New start, ISO 8601. Leave empty to keep it.',
+ required: false,
+ }),
+ ends_at: Property.DateTime({
+ displayName: 'Ends At',
+ description: 'New end, ISO 8601. Leave empty to keep it. To remove the end date use remove_end_date.',
+ required: false,
+ }),
+ remove_end_date: shopifyProps.booleanChoice({
+ displayName: 'Remove End Date',
+ description: 'Yes: clear the end date so the code no longer expires. Cannot be combined with ends_at. Leave unset to keep the end date.',
+ }),
+ destination: Property.StaticDropdown({
+ displayName: 'Destination',
+ description: 'Where free shipping applies; replaces the current destination. Leave unset to keep it, or to use COUNTRIES when country codes are given.',
+ required: false,
+ options: {
+ options: [
+ { label: 'All countries', value: 'ALL' },
+ { label: 'Specific countries', value: 'COUNTRIES' },
+ ],
+ },
+ }),
+ country_codes_to_add: Property.Array({
+ displayName: 'Country Codes To Add',
+ description: 'With destination COUNTRIES: two-letter ISO country codes where free shipping should apply, for example "US" and "CA".',
+ required: false,
+ }),
+ country_codes_to_remove: Property.Array({
+ displayName: 'Country Codes To Remove',
+ description: 'With destination COUNTRIES: two-letter ISO country codes to take out, for example "MX".',
+ required: false,
+ }),
+ maximum_shipping_price: Property.Number({
+ displayName: 'Maximum Shipping Price',
+ description: 'New cap on the shipping rate the code covers, above 0, for example 20. Leave empty to keep it.',
+ required: false,
+ }),
+ eligibility: Property.StaticDropdown({
+ displayName: 'Eligibility',
+ description: 'Who can use the code. Replaces the current eligibility.',
+ required: false,
+ options: {
+ options: [
+ { label: 'All buyers', value: 'ALL' },
+ { label: 'Specific customers', value: 'CUSTOMERS' },
+ { label: 'Customer segments', value: 'SEGMENTS' },
+ ],
+ },
+ }),
+ customer_ids_to_add: shopifyProps.idList({
+ displayName: 'Customer IDs To Add',
+ description: 'With eligibility CUSTOMERS: customers who can use the code, numeric or "gid://shopify/Customer/…".',
+ }),
+ customer_ids_to_remove: shopifyProps.idList({
+ displayName: 'Customer IDs To Remove',
+ description: 'With eligibility CUSTOMERS: customers who should no longer be able to use it.',
+ }),
+ segment_ids_to_add: shopifyProps.idList({
+ displayName: 'Segment IDs To Add',
+ description: 'With eligibility SEGMENTS: segments that can use the code, numeric or "gid://shopify/Segment/…".',
+ }),
+ segment_ids_to_remove: shopifyProps.idList({
+ displayName: 'Segment IDs To Remove',
+ description: 'With eligibility SEGMENTS: segments that should no longer be able to use it.',
+ }),
+ minimum_requirement: Property.StaticDropdown({
+ displayName: 'Minimum Requirement',
+ description: 'New minimum, or NONE to remove it. Leave unset to keep the current one.',
+ required: false,
+ options: {
+ options: [
+ { label: 'None (remove the minimum)', value: 'NONE' },
+ { label: 'Minimum subtotal', value: 'SUBTOTAL' },
+ { label: 'Minimum quantity of items', value: 'QUANTITY' },
+ ],
+ },
+ }),
+ minimum_value: Property.Number({
+ displayName: 'Minimum Value',
+ description: 'With SUBTOTAL or QUANTITY: the subtotal or the whole-number item quantity.',
+ required: false,
+ }),
+ usage_limit: Property.Number({
+ displayName: 'Usage Limit',
+ description: 'New total usage limit, a whole number of 1 or more. Leave empty to keep it. To remove the limit use remove_usage_limit.',
+ required: false,
+ }),
+ remove_usage_limit: shopifyProps.booleanChoice({
+ displayName: 'Remove Usage Limit',
+ description: 'Yes: clear the total usage limit so the code can be used any number of times. Cannot be combined with usage_limit. Leave unset to keep the limit.',
+ }),
+ applies_once_per_customer: shopifyProps.booleanChoice({
+ displayName: 'Once Per Customer',
+ description: 'Yes: each customer can use it once. No: no per-customer limit. Leave unset to keep it.',
+ }),
+ combines_with_product_discounts: shopifyProps.booleanChoice({
+ displayName: 'Combines With Product Discounts',
+ description: 'Set all three combines_with choices together; they replace the current combinations.',
+ }),
+ combines_with_order_discounts: shopifyProps.booleanChoice({
+ displayName: 'Combines With Order Discounts',
+ description: 'Set all three combines_with choices together; they replace the current combinations.',
+ }),
+ combines_with_shipping_discounts: shopifyProps.booleanChoice({
+ displayName: 'Combines With Shipping Discounts',
+ description: 'Set all three combines_with choices together; they replace the current combinations.',
+ }),
+ tags: Property.Array({
+ displayName: 'Tags',
+ description: 'The complete new tag list; replaces the current tags. Leave empty to keep them.',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyValues.toDiscountCodeNodeId(propsValue.discount_id);
+ const maximumShippingPrice = shopifyValues.readNumber(propsValue.maximum_shipping_price);
+ if (maximumShippingPrice !== undefined && !(maximumShippingPrice > 0)) {
+ throw new Error('maximum_shipping_price must be above 0. Nothing was changed.');
+ }
+ const usageLimit = shopifyValues.readNumber(propsValue.usage_limit);
+ if (usageLimit !== undefined && (!Number.isInteger(usageLimit) || usageLimit < 1)) {
+ throw new Error('usage_limit must be a whole number of 1 or more. Nothing was changed.');
+ }
+ const freeShippingCodeDiscount = shopifyValues.compact({
+ title: shopifyValues.nonEmpty(propsValue.title),
+ code: shopifyValues.nonEmpty(propsValue.code),
+ startsAt: shopifyValues.nonEmpty(propsValue.starts_at),
+ endsAt: shopifyValues.clearableValue({
+ value: shopifyValues.nonEmpty(propsValue.ends_at),
+ clear: shopifyValues.toBooleanChoice(propsValue.remove_end_date),
+ valueName: 'ends_at',
+ clearName: 'remove_end_date',
+ }),
+ destination: buildDestinationUpdate({
+ destination: propsValue.destination,
+ countryCodesToAdd: propsValue.country_codes_to_add,
+ countryCodesToRemove: propsValue.country_codes_to_remove,
+ }),
+ maximumShippingPrice: maximumShippingPrice === undefined ? undefined : String(maximumShippingPrice),
+ context: shopifyValues.buildDiscountContext({
+ eligibility: propsValue.eligibility,
+ customerIdsToAdd: propsValue.customer_ids_to_add,
+ customerIdsToRemove: propsValue.customer_ids_to_remove,
+ segmentIdsToAdd: propsValue.segment_ids_to_add,
+ segmentIdsToRemove: propsValue.segment_ids_to_remove,
+ }),
+ minimumRequirement: shopifyValues.buildMinimumRequirement({
+ kind: propsValue.minimum_requirement,
+ value: shopifyValues.readNumber(propsValue.minimum_value),
+ }),
+ usageLimit: shopifyValues.clearableValue({
+ value: usageLimit,
+ clear: shopifyValues.toBooleanChoice(propsValue.remove_usage_limit),
+ valueName: 'usage_limit',
+ clearName: 'remove_usage_limit',
+ }),
+ appliesOncePerCustomer: shopifyValues.toBooleanChoice(propsValue.applies_once_per_customer),
+ combinesWith: shopifyValues.buildCombinesWith({
+ productDiscounts: shopifyValues.toBooleanChoice(propsValue.combines_with_product_discounts),
+ orderDiscounts: shopifyValues.toBooleanChoice(propsValue.combines_with_order_discounts),
+ shippingDiscounts: shopifyValues.toBooleanChoice(propsValue.combines_with_shipping_discounts),
+ }),
+ tags: shopifyValues.nonEmptyList(propsValue.tags),
+ });
+ if (Object.keys(freeShippingCodeDiscount).length === 0) {
+ throw new Error('Nothing to update: provide at least one field to change. Nothing was changed.');
+ }
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ discountCodeFreeShippingUpdate: { codeDiscountNode: GqlDiscountNode | null } | null;
+ }>({
+ auth,
+ query: `mutation UpdateFreeShippingDiscountCode($id: ID!, $freeShippingCodeDiscount: DiscountCodeFreeShippingInput!) { discountCodeFreeShippingUpdate(id: $id, freeShippingCodeDiscount: $freeShippingCodeDiscount) { codeDiscountNode { id discount: codeDiscount { ${shopifyFields.CODE_DISCOUNT_DETAIL_FIELDS} } } userErrors { field message code } } }`,
+ variables: { id, freeShippingCodeDiscount },
+ });
+ const node = data.discountCodeFreeShippingUpdate?.codeDiscountNode;
+ if (!node) {
+ throw new Error('Shopify did not return the updated discount.');
+ }
+ return {
+ ...shopifyMappers.mapDiscountNode(node),
+ redacted_fields: redactedFields,
+ };
+ },
+});
+
+function buildDestinationUpdate({
+ destination,
+ countryCodesToAdd,
+ countryCodesToRemove,
+}: {
+ destination: string | undefined;
+ countryCodesToAdd: unknown;
+ countryCodesToRemove: unknown;
+}): Record<string, unknown> | undefined {
+ const add = readCountryCodes(countryCodesToAdd);
+ const remove = readCountryCodes(countryCodesToRemove);
+ const hasCodes = add.length > 0 || remove.length > 0;
+ const target = destination ?? (hasCodes ? 'COUNTRIES' : undefined);
+ if (target === undefined) {
+ return undefined;
+ }
+ if (target === 'ALL') {
+ if (hasCodes) {
+ throw new Error('destination ALL cannot be combined with country codes; choose COUNTRIES. Nothing was changed.');
+ }
+ return { all: true };
+ }
+ if (target === 'COUNTRIES') {
+ if (!hasCodes) {
+ throw new Error('destination COUNTRIES needs country_codes_to_add or country_codes_to_remove, for example "US". Nothing was changed.');
+ }
+ return {
+ countries: shopifyValues.compact({
+ add: add.length > 0 ? add : undefined,
+ remove: remove.length > 0 ? remove : undefined,
+ }),
+ };
+ }
+ throw new Error(`Unknown destination "${target}". Use ALL or COUNTRIES. Nothing was changed.`);
+}
+
+function readCountryCodes(value: unknown): string[] {
+ const codes = (shopifyValues.nonEmptyList(value) ?? []).map((code) => code.trim().toUpperCase());
+ const invalid = codes.filter((code) => !/^[A-Z]{2}$/.test(code));
+ if (invalid.length > 0) {
+ throw new Error(`Country codes must be two letters, got: ${invalid.join(', ')}. Nothing was changed.`);
+ }
+ return codes;
+}
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/update-fulfillment-tracking.ts b/packages/pieces/community/shopify/src/lib/actions/ai/update-fulfillment-tracking.ts
new file mode 100644
index 00000000000..cba0a8b1854
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/update-fulfillment-tracking.ts
@@ -0,0 +1,88 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlFulfillment,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyValues,
+} from '../../common/graphql';
+import { fulfillmentSummaryOutputSchema } from '../../output-schemas/fulfillment';
+
+export const shopifyAiUpdateFulfillmentTracking = createAction({
+ auth: shopifyAuth,
+ name: 'update_fulfillment_tracking',
+ classification: 'WRITE',
+ displayName: 'Update Fulfillment Tracking',
+ description: 'Change the carrier, tracking numbers or tracking URLs of a fulfillment.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Updates the tracking information of one existing fulfillment and returns it. Only the fields you supply are sent. Tracking numbers and tracking URLs are lists that REPLACE the stored lists when sent: to add a number, send the complete list including the numbers already on the fulfillment (read them with get_fulfillment_details first). At least one of tracking_company, tracking_numbers or tracking_urls is required. notify_customer is sent explicitly and defaults to false; with true the customer gets a shipping update email, and every call made with notify_customer=true sends another email, so set it to true only on the one call that should notify (never on retries). Repeating the same call leaves the same tracking in place. Needs the write_merchant_managed_fulfillment_orders access scope.',
+ idempotent: true,
+ },
+ outputSchema: fulfillmentSummaryOutputSchema,
+ props: {
+ fulfillment_id: Property.ShortText({
+ displayName: 'Fulfillment ID',
+ description:
+ 'The fulfillment id, numeric or "gid://shopify/Fulfillment/…". Find it with list_order_fulfillments.',
+ required: true,
+ }),
+ tracking_company: Property.ShortText({
+ displayName: 'Tracking Company',
+ description: 'The carrier name, for example "UPS", "USPS", "FedEx" or "DHL Express".',
+ required: false,
+ }),
+ tracking_numbers: Property.Array({
+ displayName: 'Tracking Numbers',
+ description:
+ 'The complete list of tracking numbers. Replaces the stored list; leave empty to keep it.',
+ required: false,
+ }),
+ tracking_urls: Property.Array({
+ displayName: 'Tracking URLs',
+ description:
+ 'The complete list of tracking page URLs, one per tracking number. Replaces the stored list; leave empty to keep it.',
+ required: false,
+ }),
+ notify_customer: Property.Checkbox({
+ displayName: 'Notify Customer',
+ description: 'Send the customer a shipping update email. Off by default.',
+ required: false,
+ defaultValue: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const fulfillmentId = shopifyGraphqlClient.toGid({ type: 'Fulfillment', id: propsValue.fulfillment_id });
+ const trackingInfoInput = shopifyValues.compact({
+ company: shopifyValues.nonEmpty(propsValue.tracking_company),
+ numbers: shopifyValues.nonEmptyList(propsValue.tracking_numbers),
+ urls: shopifyValues.nonEmptyList(propsValue.tracking_urls),
+ });
+ if (Object.keys(trackingInfoInput).length === 0) {
+ throw new Error(
+ 'Nothing to update: provide tracking_company, tracking_numbers or tracking_urls. Nothing was changed.'
+ );
+ }
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ fulfillmentTrackingInfoUpdate: { fulfillment: GqlFulfillment | null } | null;
+ }>({
+ auth,
+ query: `mutation UpdateFulfillmentTracking($fulfillmentId: ID!, $trackingInfoInput: FulfillmentTrackingInput!, $notifyCustomer: Boolean) { fulfillmentTrackingInfoUpdate(fulfillmentId: $fulfillmentId, trackingInfoInput: $trackingInfoInput, notifyCustomer: $notifyCustomer) { fulfillment { ${shopifyFields.FULFILLMENT_SUMMARY_FIELDS} } userErrors { field message } } }`,
+ variables: {
+ fulfillmentId,
+ trackingInfoInput,
+ notifyCustomer: propsValue.notify_customer ?? false,
+ },
+ });
+ const fulfillment = data.fulfillmentTrackingInfoUpdate?.fulfillment;
+ if (!fulfillment) {
+ throw new Error('Shopify did not return the updated fulfillment.');
+ }
+ return {
+ ...shopifyMappers.mapFulfillmentSummary(fulfillment),
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/actions/ai/update-gift-card.ts b/packages/pieces/community/shopify/src/lib/actions/ai/update-gift-card.ts
new file mode 100644
index 00000000000..b33b8d3b76b
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/actions/ai/update-gift-card.ts
@@ -0,0 +1,115 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { shopifyAuth } from '../../..';
+import {
+ GqlGiftCard,
+ shopifyFields,
+ shopifyGraphqlClient,
+ shopifyMappers,
+ shopifyValues,
+} from '../../common/graphql';
+import { giftCardOutputSchema } from '../../output-schemas/fulfillment';
+
+export const shopifyAiUpdateGiftCard = createAction({
+ auth: shopifyAuth,
+ name: 'update_gift_card',
+ classification: 'WRITE',
+ displayName: 'Update Gift Card',
+ description: 'Change a gift card\'s note, expiry date, owner or recipient.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Updates one gift card and returns it. Only the fields you supply are sent; at least one is required. You can change the internal note, the expiry date, the owner customer, the theme template suffix and the recipient (customer, preferred name, message, notification time). The balance and the code cannot be changed here, and a deactivated card cannot be re-enabled. Repeating the same update leaves the same state. Needs the write_gift_cards access scope.',
+ idempotent: true,
+ },
+ outputSchema: giftCardOutputSchema,
+ props: {
+ gift_card_id: Property.ShortText({
+ displayName: 'Gift Card ID',
+ description: 'The gift card id, numeric or "gid://shopify/GiftCard/…". Find it with search_gift_cards.',
+ required: true,
+ }),
+ note: Property.LongText({
+ displayName: 'Note',
+ description: 'New internal note. Leave empty to keep the current one.',
+ required: false,
+ }),
+ expires_on: Property.ShortText({
+ displayName: 'Expires On',
+ description: 'New expiry date, YYYY-MM-DD, for example "2027-12-31". Leave empty to keep the current one.',
+ required: false,
+ }),
+ customer_id: Property.ShortText({
+ displayName: 'Customer ID',
+ description: 'New owner customer, numeric or "gid://shopify/Customer/…". Leave empty to keep the current owner.',
+ required: false,
+ }),
+ template_suffix: Property.ShortText({
+ displayName: 'Template Suffix',
+ description: 'Theme template suffix for the gift card page, for example "birthday". Leave empty to keep it.',
+ required: false,
+ }),
+ recipient_customer_id: Property.ShortText({
+ displayName: 'Recipient Customer ID',
+ description:
+ 'Customer who receives the gift card notification, numeric or "gid://shopify/Customer/…". Required to change any recipient detail.',
+ required: false,
+ }),
+ recipient_preferred_name: Property.ShortText({
+ displayName: 'Recipient Preferred Name',
+ description: 'Name used to greet the recipient, for example "Sam".',
+ required: false,
+ }),
+ recipient_message: Property.LongText({
+ displayName: 'Recipient Message',
+ description: 'Personal message included in the recipient notification.',
+ required: false,
+ }),
+ send_notification_at: Property.DateTime({
+ displayName: 'Send Notification At',
+ description: 'Time to email the recipient, ISO 8601.',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const id = shopifyGraphqlClient.toGid({ type: 'GiftCard', id: propsValue.gift_card_id });
+ const customerId = shopifyValues.nonEmpty(propsValue.customer_id);
+ const recipientId = shopifyValues.nonEmpty(propsValue.recipient_customer_id);
+ const recipientDetails = shopifyValues.compact({
+ preferredName: shopifyValues.nonEmpty(propsValue.recipient_preferred_name),
+ message: shopifyValues.nonEmpty(propsValue.recipient_message),
+ sendNotificationAt: shopifyValues.nonEmpty(propsValue.send_notification_at),
+ });
+ if (!recipientId && Object.keys(recipientDetails).length > 0) {
+ throw new Error(
+ 'Recipient details need recipient_customer_id (the recipient is replaced as a whole). Nothing was changed.'
+ );
+ }
+ const input = shopifyValues.compact({
+ note: shopifyValues.nonEmpty(propsValue.note),
+ expiresOn: shopifyValues.readIsoDate(propsValue.expires_on),
+ customerId: customerId ? shopifyGraphqlClient.toGid({ type: 'Customer', id: customerId }) : undefined,
+ templateSuffix: shopifyValues.nonEmpty(propsValue.template_suffix),
+ recipientAttributes: recipientId
+ ? { id: shopifyGraphqlClient.toGid({ type: 'Customer', id: recipientId }), ...recipientDetails }
+ : undefined,
+ });
+ if (Object.keys(input).length === 0) {
+ throw new Error('Nothing to update: provide at least one field to change. Nothing was changed.');
+ }
+ const { data, redactedFields } = await shopifyGraphqlClient.request<{
+ giftCardUpdate: { giftCard: GqlGiftCard | null } | null;
+ }>({
+ auth,
+ query: `mutation UpdateGiftCard($id: ID!, $input: GiftCardUpdateInput!) { giftCardUpdate(id: $id, input: $input) { giftCard { ${shopifyFields.GIFT_CARD_FIELDS} } userErrors { field message } } }`,
+ variables: { id, input },
+ });
+ const card = data.giftCardUpdate?.giftCard;
+ if (!card) {
+ throw new Error('Shopify did not return the updated gift card.');
+ }
+ return {
+ ...shopifyMappers.mapGiftCard(card),
+ redacted_fields: redactedFields,
+ };
+ },
+});
diff --git a/packages/pieces/community/shopify/src/lib/common/auth.ts b/packages/pieces/community/shopify/src/lib/common/auth.ts
index 15ad5e9b2f0..259354e145c 100644
--- a/packages/pieces/community/shopify/src/lib/common/auth.ts
+++ b/packages/pieces/community/shopify/src/lib/common/auth.ts
@@ -23,7 +23,7 @@ You can find your shop name in the URL. For example, if the URL is \`https://exa
1. Log in to your Shopify admin.
2. Go to **Settings** -> **Apps and sales channels** -> **Develop apps**.
3. Open your existing custom app.
-4. Under **Configuration**, check that the Admin API scopes include: \`read_orders\`, \`write_orders\`, \`read_customers\`, \`write_customers\`, \`read_products\`, \`write_products\`, \`read_draft_orders\`, \`write_draft_orders\`, \`read_locations\`, \`read_inventory\`, \`write_inventory\`, \`read_themes\`, \`write_fulfillments\`, \`read_publications\`, \`write_publications\`, \`write_files\`.
+4. Under **Configuration**, check that the Admin API scopes include: \`read_orders\`, \`write_orders\`, \`read_customers\`, \`write_customers\`, \`read_products\`, \`write_products\`, \`read_draft_orders\`, \`write_draft_orders\`, \`read_locations\`, \`read_inventory\`, \`write_inventory\`, \`read_themes\`, \`write_fulfillments\`, \`read_publications\`, \`write_publications\`, \`write_files\`, \`read_merchant_managed_fulfillment_orders\`, \`write_merchant_managed_fulfillment_orders\`, \`read_fulfillments\`, \`read_shipping\`, \`read_discounts\`, \`write_discounts\`, \`read_gift_cards\`, \`write_gift_cards\`.
5. Under **API credentials**, copy the **Admin API access token**.
`;
@@ -33,7 +33,7 @@ Use this option for apps created in the Shopify **Dev Dashboard** (all new apps
**Important:** the app and the store must belong to the **same Shopify organization**, otherwise Shopify rejects the connection.
1. Go to the [Shopify Dev Dashboard](https://dev.shopify.com/dashboard) and click **Create app**. Give it a name.
-2. Create a version of the app and, under **Access** -> **Scopes**, select these Admin API scopes: \`read_orders\`, \`write_orders\`, \`read_customers\`, \`write_customers\`, \`read_products\`, \`write_products\`, \`read_draft_orders\`, \`write_draft_orders\`, \`read_locations\`, \`read_inventory\`, \`write_inventory\`, \`read_themes\`, \`write_fulfillments\`, \`read_publications\`, \`write_publications\`, \`write_files\`.
+2. Create a version of the app and, under **Access** -> **Scopes**, select these Admin API scopes: \`read_orders\`, \`write_orders\`, \`read_customers\`, \`write_customers\`, \`read_products\`, \`write_products\`, \`read_draft_orders\`, \`write_draft_orders\`, \`read_locations\`, \`read_inventory\`, \`write_inventory\`, \`read_themes\`, \`write_fulfillments\`, \`read_publications\`, \`write_publications\`, \`write_files\`, \`read_merchant_managed_fulfillment_orders\`, \`write_merchant_managed_fulfillment_orders\`, \`read_fulfillments\`, \`read_shipping\`, \`read_discounts\`, \`write_discounts\`, \`read_gift_cards\`, \`write_gift_cards\`.
3. Release a version with these scopes and install/approve it on the store: from the app's **Home** page, click **Install app** and install it on your store (reinstall it if it was installed before the scopes were added). The store must be in the same organization as the app.
4. Open the app's **Settings** page and copy the **Client ID** and **Client secret**.
5. Enter your shop name below (for \`https://example.myshopify.com\`, enter **example**), then paste the client ID and client secret.
diff --git a/packages/pieces/community/shopify/src/lib/common/graphql.ts b/packages/pieces/community/shopify/src/lib/common/graphql.ts
index 0280924138f..e71affb320d 100644
--- a/packages/pieces/community/shopify/src/lib/common/graphql.ts
+++ b/packages/pieces/community/shopify/src/lib/common/graphql.ts
@@ -1939,6 +1939,799 @@ function toGidList({ type, value }: { type: string; value: unknown }): string[]
return ids.map((id) => toGid({ type, id }));
}
+function mapFulfillmentOrder(order: GqlFulfillmentOrder) {
+ const destination = order.destination;
+ const lineItems = order.lineItems;
+ return {
+ id: order.id,
+ status: order.status ?? null,
+ request_status: order.requestStatus ?? null,
+ order_id: order.orderId ?? null,
+ order_name: order.orderName ?? null,
+ created_at: order.createdAt ?? null,
+ updated_at: order.updatedAt ?? null,
+ fulfill_at: order.fulfillAt ?? null,
+ fulfill_by: order.fulfillBy ?? null,
+ assigned_location_id: order.assignedLocation?.location?.id ?? null,
+ assigned_location_name: order.assignedLocation?.name ?? null,
+ destination_first_name: destination?.firstName ?? null,
+ destination_last_name: destination?.lastName ?? null,
+ destination_company: destination?.company ?? null,
+ destination_address1: destination?.address1 ?? null,
+ destination_address2: destination?.address2 ?? null,
+ destination_city: destination?.city ?? null,
+ destination_province: destination?.province ?? null,
+ destination_zip: destination?.zip ?? null,
+ destination_country_code: destination?.countryCode ?? null,
+ destination_phone: destination?.phone ?? null,
+ destination_email: destination?.email ?? null,
+ delivery_method_type: order.deliveryMethod?.methodType ?? null,
+ delivery_method_name: order.deliveryMethod?.presentedName ?? null,
+ holds: (order.fulfillmentHolds ?? []).map((hold) => ({
+ id: hold.id,
+ reason: hold.reason ?? null,
+ reason_notes: hold.reasonNotes ?? null,
+ display_reason: hold.displayReason ?? null,
+ handle: hold.handle ?? null,
+ held_by_requesting_app: hold.heldByRequestingApp ?? null,
+ })),
+ supported_actions: (order.supportedActions ?? [])
+ .map((entry) => entry.action ?? null)
+ .filter((action): action is string => action !== null),
+ line_items: (lineItems?.nodes ?? []).map((item) => ({
+ id: item.id,
+ sku: item.sku ?? null,
+ product_title: item.productTitle ?? null,
+ variant_title: item.variantTitle ?? null,
+ total_quantity: item.totalQuantity ?? null,
+ remaining_quantity: item.remainingQuantity ?? null,
+ requires_shipping: item.requiresShipping ?? null,
+ line_item_id: item.lineItem?.id ?? null,
+ variant_id: item.variant?.id ?? null,
+ inventory_item_id: item.inventoryItemId ?? null,
+ })),
+ line_items_truncated: lineItems?.pageInfo?.hasNextPage ?? false,
+ line_items_end_cursor: lineItems?.pageInfo?.endCursor ?? null,
+ };
+}
+
+function mapFulfillmentOrderOrNull(order: GqlFulfillmentOrder | null | undefined) {
+ return order ? mapFulfillmentOrder(order) : null;
+}
+
+function mapFulfillmentSummary(fulfillment: GqlFulfillment) {
+ const tracking = fulfillment.trackingInfo ?? [];
+ return {
+ id: fulfillment.id,
+ legacy_resource_id: fulfillment.legacyResourceId ?? null,
+ name: fulfillment.name ?? null,
+ status: fulfillment.status ?? null,
+ display_status: fulfillment.displayStatus ?? null,
+ created_at: fulfillment.createdAt ?? null,
+ updated_at: fulfillment.updatedAt ?? null,
+ in_transit_at: fulfillment.inTransitAt ?? null,
+ delivered_at: fulfillment.deliveredAt ?? null,
+ estimated_delivery_at: fulfillment.estimatedDeliveryAt ?? null,
+ total_quantity: fulfillment.totalQuantity ?? null,
+ requires_shipping: fulfillment.requiresShipping ?? null,
+ tracking_company: tracking[0]?.company ?? null,
+ tracking_numbers: tracking
+ .map((entry) => entry.number ?? null)
+ .filter((value): value is string => value !== null),
+ tracking_urls: tracking
+ .map((entry) => entry.url ?? null)
+ .filter((value): value is string => value !== null),
+ location_id: fulfillment.location?.id ?? null,
+ location_name: fulfillment.location?.name ?? null,
+ service_id: fulfillment.service?.id ?? null,
+ service_name: fulfillment.service?.serviceName ?? null,
+ order_id: fulfillment.order?.id ?? null,
+ order_name: fulfillment.order?.name ?? null,
+ };
+}
+
+function mapFulfillment(fulfillment: GqlFulfillment) {
+ const origin = fulfillment.originAddress;
+ const lineItems = fulfillment.fulfillmentLineItems;
+ return {
+ ...mapFulfillmentSummary(fulfillment),
+ origin_address1: origin?.address1 ?? null,
+ origin_address2: origin?.address2 ?? null,
+ origin_city: origin?.city ?? null,
+ origin_zip: origin?.zip ?? null,
+ origin_province_code: origin?.provinceCode ?? null,
+ origin_country_code: origin?.countryCode ?? null,
+ line_items: (lineItems?.nodes ?? []).map((item) => ({
+ id: item.id,
+ quantity: item.quantity ?? null,
+ line_item_id: item.lineItem?.id ?? null,
+ title: item.lineItem?.title ?? null,
+ sku: item.lineItem?.sku ?? null,
+ })),
+ line_items_truncated: lineItems?.pageInfo?.hasNextPage ?? false,
+ };
+}
+
+function mapFulfillmentEvent(event: GqlFulfillmentEvent) {
+ return {
+ id: event.id,
+ status: event.status ?? null,
+ message: event.message ?? null,
+ happened_at: event.happenedAt ?? null,
+ created_at: event.createdAt ?? null,
+ estimated_delivery_at: event.estimatedDeliveryAt ?? null,
+ address1: event.address1 ?? null,
+ city: event.city ?? null,
+ province: event.province ?? null,
+ country: event.country ?? null,
+ zip: event.zip ?? null,
+ latitude: event.latitude ?? null,
+ longitude: event.longitude ?? null,
+ };
+}
+
+function mapFulfillmentService(service: GqlFulfillmentService) {
+ return {
+ id: service.id,
+ handle: service.handle ?? null,
+ service_name: service.serviceName ?? null,
+ type: service.type ?? null,
+ callback_url: service.callbackUrl ?? null,
+ inventory_management: service.inventoryManagement ?? null,
+ tracking_support: service.trackingSupport ?? null,
+ requires_shipping_method: service.requiresShippingMethod ?? null,
+ location_id: service.location?.id ?? null,
+ location_name: service.location?.name ?? null,
+ };
+}
+
+function mapCarrierService(service: GqlCarrierService) {
+ return {
+ id: service.id,
+ name: service.name ?? null,
+ formatted_name: service.formattedName ?? null,
+ active: service.active ?? null,
+ callback_url: service.callbackUrl ?? null,
+ supports_service_discovery: service.supportsServiceDiscovery ?? null,
+ };
+}
+
+function mapDeliveryProfile(profile: GqlDeliveryProfile) {
+ const groups = profile.profileLocationGroups ?? [];
+ return {
+ id: profile.id,
+ name: profile.name ?? null,
+ default: profile.default ?? null,
+ version: profile.version ?? null,
+ active_method_definitions_count: profile.activeMethodDefinitionsCount ?? null,
+ locations_without_rates_count: profile.locationsWithoutRatesCount ?? null,
+ origin_location_count: profile.originLocationCount ?? null,
+ zone_country_count: profile.zoneCountryCount ?? null,
+ product_variants_count: profile.productVariantsCount?.count ?? null,
+ location_groups: groups.map((group) => ({
+ location_group_id: group.locationGroup?.id ?? null,
+ locations_count: group.locationGroup?.locationsCount?.count ?? null,
+ zones: (group.locationGroupZones?.nodes ?? []).map(mapDeliveryZone),
+ zones_truncated: group.locationGroupZones?.pageInfo?.hasNextPage ?? false,
+ })),
+ };
+}
+
+function mapDeliveryZone(entry: GqlDeliveryZoneEntry) {
+ return {
+ zone_id: entry.zone?.id ?? null,
+ zone_name: entry.zone?.name ?? null,
+ countries: (entry.zone?.countries ?? []).map((country) =>
+ country.code?.restOfWorld ? 'REST_OF_WORLD' : country.code?.countryCode ?? country.name ?? null
+ ),
+ rates: (entry.methodDefinitions?.nodes ?? []).map((method) => ({
+ id: method.id,
+ name: method.name ?? null,
+ active: method.active ?? null,
+ description: method.description ?? null,
+ price: method.rateProvider?.price?.amount ?? null,
+ currency_code: method.rateProvider?.price?.currencyCode ?? null,
+ carrier_service_id: method.rateProvider?.carrierService?.id ?? null,
+ carrier_service_name: method.rateProvider?.carrierService?.name ?? null,
+ })),
+ rates_truncated: entry.methodDefinitions?.pageInfo?.hasNextPage ?? false,
+ };
+}
+
+function mapGiftCard(card: GqlGiftCard) {
+ return {
+ id: card.id,
+ last_characters: card.lastCharacters ?? null,
+ masked_code: card.maskedCode ?? null,
+ enabled: card.enabled ?? null,
+ is_redeemable: card.isRedeemable ?? null,
+ deactivated_at: card.deactivatedAt ?? null,
+ expires_on: card.expiresOn ?? null,
+ balance: card.balance?.amount ?? null,
+ initial_value: card.initialValue?.amount ?? null,
+ currency_code: card.balance?.currencyCode ?? card.initialValue?.currencyCode ?? null,
+ note: card.note ?? null,
+ template_suffix: card.templateSuffix ?? null,
+ customer_id: card.customer?.id ?? null,
+ customer_name: card.customer?.displayName ?? null,
+ order_id: card.order?.id ?? null,
+ order_name: card.order?.name ?? null,
+ recipient_id: card.recipientAttributes?.recipient?.id ?? null,
+ recipient_name: card.recipientAttributes?.recipient?.displayName ?? null,
+ recipient_preferred_name: card.recipientAttributes?.preferredName ?? null,
+ recipient_message: card.recipientAttributes?.message ?? null,
+ send_notification_at: card.recipientAttributes?.sendNotificationAt ?? null,
+ created_at: card.createdAt ?? null,
+ updated_at: card.updatedAt ?? null,
+ };
+}
+
+function mapDiscountNode(node: GqlDiscountNode) {
+ const discount: GqlDiscount = node.discount ?? {};
+ const typename = discount.__typename ?? null;
+ const method = discountMethod(typename);
+ const value = discount.customerGets?.value;
+ const effect = value?.effect;
+ const items = discount.customerGets?.items;
+ const minimum = discount.minimumRequirement;
+ const context = discount.context;
+ const destination = discount.destinationSelection;
+ const buysValue = discount.customerBuys?.value;
+ const buysItems = discount.customerBuys?.items;
+ const marketIds = (context?.markets?.nodes ?? []).map((market) => market.id);
+ return {
+ id: typedDiscountId({ id: node.id, method }),
+ method,
+ discount_type: typename,
+ title: discount.title ?? null,
+ status: discount.status ?? null,
+ summary: discount.summary ?? null,
+ starts_at: discount.startsAt ?? null,
+ ends_at: discount.endsAt ?? null,
+ created_at: discount.createdAt ?? null,
+ updated_at: discount.updatedAt ?? null,
+ usage_count: discount.asyncUsageCount ?? null,
+ discount_classes: discount.discountClasses ?? [],
+ tags: discount.tags ?? [],
+ combines_with_product_discounts: discount.combinesWith?.productDiscounts ?? null,
+ combines_with_order_discounts: discount.combinesWith?.orderDiscounts ?? null,
+ combines_with_shipping_discounts: discount.combinesWith?.shippingDiscounts ?? null,
+ applies_once_per_customer: discount.appliesOncePerCustomer ?? null,
+ usage_limit: discount.usageLimit ?? null,
+ codes_count: discount.codesCount?.count ?? null,
+ codes: (discount.codes?.nodes ?? [])
+ .map((entry) => entry.code ?? null)
+ .filter((code): code is string => code !== null),
+ eligibility: discountEligibility(context?.__typename),
+ customer_ids: (context?.customers ?? []).map((customer) => customer.id),
+ segment_ids: (context?.segments ?? []).map((segment) => segment.id),
+ market_ids: marketIds,
+ markets_truncated: (context?.marketsCount ?? 0) > marketIds.length,
+ value_type: discountValueType(value?.__typename),
+ percentage: toPercent(value?.percentage ?? effect?.percentage),
+ amount: value?.amount?.amount ?? effect?.amount?.amount ?? null,
+ amount_currency: value?.amount?.currencyCode ?? effect?.amount?.currencyCode ?? null,
+ applies_on_each_item: value?.appliesOnEachItem ?? null,
+ quantity: value?.quantity?.quantity ?? null,
+ applies_to: discountAppliesTo(items?.__typename),
+ product_ids: (items?.products?.nodes ?? []).map((product) => product.id),
+ variant_ids: (items?.productVariants?.nodes ?? []).map((variant) => variant.id),
+ collection_ids: (items?.collections?.nodes ?? []).map((collection) => collection.id),
+ items_truncated: discountItemsTruncated(items),
+ buys_type: discountBuysType(buysValue?.__typename),
+ buys_quantity: buysValue?.quantity ?? null,
+ buys_amount: buysValue?.amount ?? null,
+ buys_applies_to: discountAppliesTo(buysItems?.__typename),
+ buys_product_ids: (buysItems?.products?.nodes ?? []).map((product) => product.id),
+ buys_variant_ids: (buysItems?.productVariants?.nodes ?? []).map((variant) => variant.id),
+ buys_collection_ids: (buysItems?.collections?.nodes ?? []).map((collection) => collection.id),
+ buys_items_truncated: discountItemsTruncated(buysItems),
+ minimum_quantity: minimum?.greaterThanOrEqualToQuantity ?? null,
+ minimum_subtotal: minimum?.greaterThanOrEqualToSubtotal?.amount ?? null,
+ minimum_subtotal_currency: minimum?.greaterThanOrEqualToSubtotal?.currencyCode ?? null,
+ maximum_shipping_price: discount.maximumShippingPrice?.amount ?? null,
+ destination_all_countries: destination
+ ? destination.__typename === 'DiscountCountryAll'
+ : null,
+ destination_countries: destination?.countries ?? [],
+ uses_per_order_limit: discount.usesPerOrderLimit ?? null,
+ };
+}
+
+function mapDiscountRedeemCode(code: GqlDiscountRedeemCode) {
+ return {
+ id: code.id ?? null,
+ code: code.code ?? null,
+ usage_count: code.asyncUsageCount ?? null,
+ created_by_app_id: code.createdBy?.id ?? null,
+ created_by_app_title: code.createdBy?.title ?? null,
+ };
+}
+
+function mapDiscountBulkCreation(creation: GqlDiscountRedeemCodeBulkCreation | null | undefined) {
+ return {
+ bulk_creation_id: creation?.id ?? null,
+ done: creation?.done ?? false,
+ codes_count: creation?.codesCount ?? null,
+ imported_count: creation?.importedCount ?? null,
+ failed_count: creation?.failedCount ?? null,
+ created_at: creation?.createdAt ?? null,
+ discount_id: creation?.discountCode?.id ?? null,
+ };
+}
+
+function discountMethod(typename: string | null): 'code' | 'automatic' | null {
+ if (typename?.startsWith('DiscountCode')) {
+ return 'code';
+ }
+ if (typename?.startsWith('DiscountAutomatic')) {
+ return 'automatic';
+ }
+ return null;
+}
+
+function discountEligibility(typename: string | null | undefined): string | null {
+ const map: Record<string, string> = {
+ DiscountBuyerSelectionAll: 'ALL',
+ DiscountCustomers: 'CUSTOMERS',
+ DiscountCustomerSegments: 'SEGMENTS',
+ DiscountMarkets: 'MARKETS',
+ };
+ return typename ? map[typename] ?? null : null;
+}
+
+function discountValueType(typename: string | null | undefined): string | null {
+ const map: Record<string, string> = {
+ DiscountPercentage: 'PERCENTAGE',
+ DiscountAmount: 'FIXED_AMOUNT',
+ DiscountOnQuantity: 'QUANTITY',
+ };
+ return typename ? map[typename] ?? null : null;
+}
+
+function discountBuysType(typename: string | null | undefined): string | null {
+ const map: Record<string, string> = {
+ DiscountQuantity: 'QUANTITY',
+ DiscountPurchaseAmount: 'AMOUNT',
+ };
+ return typename ? map[typename] ?? null : null;
+}
+
+function discountItemsTruncated(items: GqlDiscountItems | null | undefined): boolean {
+ return (
+ (items?.products?.pageInfo?.hasNextPage ?? false) ||
+ (items?.productVariants?.pageInfo?.hasNextPage ?? false) ||
+ (items?.collections?.pageInfo?.hasNextPage ?? false)
+ );
+}
+
+function clearableValue<T>({
+ value,
+ clear,
+ valueName,
+ clearName,
+}: {
+ value: T | undefined;
+ clear: boolean | undefined;
+ valueName: string;
+ clearName: string;
+}): T | null | undefined {
+ if (clear !== true) {
+ return value;
+ }
+ if (value !== undefined) {
+ throw new Error(`Choose either ${valueName} or ${clearName}, not both. Nothing was changed.`);
+ }
+ return null;
+}
+
+function discountAppliesTo(typename: string | null | undefined): string | null {
+ const map: Record<string, string> = {
+ AllDiscountItems: 'ALL',
+ DiscountProducts: 'PRODUCTS',
+ DiscountCollections: 'COLLECTIONS',
+ };
+ return typename ? map[typename] ?? null : null;
+}
+
+function toPercent(fraction: number | null | undefined): number | null {
+ if (fraction === null || fraction === undefined) {
+ return null;
+ }
+ return Math.round(fraction * 10000) / 100;
+}
+
+function typedDiscountId({
+ id,
+ method,
+}: {
+ id: string;
+ method: 'code' | 'automatic' | null;
+}): string {
+ const match = /^gid:\/\/shopify\/DiscountNode\/(\d+)$/.exec(id);
+ if (!match || method === null) {
+ return id;
+ }
+ return `gid://shopify/${method === 'code' ? 'DiscountCodeNode' : 'DiscountAutomaticNode'}/${match[1]}`;
+}
+
+function readDiscountId({
+ value,
+ allow,
+}: {
+ value: string | undefined | null;
+ allow: DiscountIdKind[];
+}): { id: string; kind: DiscountIdKind; numericId: string } {
+ const text = nonEmpty(value);
+ if (!text) {
+ throw new Error('Provide the discount id.');
+ }
+ const match = /^gid:\/\/shopify\/(DiscountCodeNode|DiscountAutomaticNode|DiscountNode)\/(\d+)$/.exec(text);
+ if (!match) {
+ throw new Error(
+ `"${text}" is not a full discount id. A plain number is ambiguous because code and automatic discounts are different objects; pass the full id such as "gid://shopify/DiscountCodeNode/123" or "gid://shopify/DiscountAutomaticNode/456" returned by list_discounts, get_discount or find_discount_by_code. Nothing was changed.`
+ );
+ }
+ const kind = DISCOUNT_ID_KINDS[match[1]];
+ if (!allow.includes(kind)) {
+ throw new Error(
+ `"${text}" is ${kind === 'automatic' ? 'an automatic discount' : 'a code discount'}, but this action works only on ${allow.includes('code') ? 'code discounts (gid://shopify/DiscountCodeNode/…)' : 'automatic discounts (gid://shopify/DiscountAutomaticNode/…)'}. Nothing was changed.`
+ );
+ }
+ return { id: text, kind, numericId: match[2] };
+}
+
+function toDiscountCodeNodeId(value: string | undefined | null): string {
+ const text = nonEmpty(value);
+ if (text && /^\d+$/.test(text)) {
+ return `gid://shopify/DiscountCodeNode/${text}`;
+ }
+ const { kind, id, numericId } = readDiscountId({ value, allow: ['code', 'node'] });
+ return kind === 'node' ? `gid://shopify/DiscountCodeNode/${numericId}` : id;
+}
+
+function buildDiscountValue({
+ valueType,
+ value,
+ appliesOnEachItem,
+}: {
+ valueType: string | undefined;
+ value: number | undefined;
+ appliesOnEachItem: boolean | undefined;
+}): Record<string, unknown> | undefined {
+ if (valueType === undefined && value === undefined) {
+ if (appliesOnEachItem !== undefined) {
+ throw new Error('applies_on_each_item needs value_type FIXED_AMOUNT and a value. Nothing was changed.');
+ }
+ return undefined;
+ }
+ if (valueType === undefined || value === undefined) {
+ throw new Error('Set both value_type and value together. Nothing was changed.');
+ }
+ if (valueType === 'PERCENTAGE') {
+ if (!(value > 0 && value <= 100)) {
+ throw new Error('A percentage value must be above 0 and at most 100, for example 15 for 15% off. Nothing was changed.');
+ }
+ if (appliesOnEachItem !== undefined) {
+ throw new Error('applies_on_each_item applies only to FIXED_AMOUNT discounts. Nothing was changed.');
+ }
+ return { percentage: Math.round(value * 100) / 10000 };
+ }
+ if (valueType === 'FIXED_AMOUNT') {
+ if (!(value > 0)) {
+ throw new Error('A fixed amount must be above 0, for example 10 for 10.00 off in the shop currency. Nothing was changed.');
+ }
+ return compact({
+ discountAmount: compact({ amount: String(value), appliesOnEachItem }),
+ });
+ }
+ throw new Error(`Unknown value_type "${valueType}". Use PERCENTAGE or FIXED_AMOUNT.`);
+}
+
+function buildDiscountItems({
+ appliesTo,
+ productIdsToAdd,
+ productIdsToRemove,
+ variantIdsToAdd,
+ variantIdsToRemove,
+ collectionIdsToAdd,
+ collectionIdsToRemove,
+}: {
+ appliesTo: string | undefined;
+ productIdsToAdd: unknown;
+ productIdsToRemove: unknown;
+ variantIdsToAdd: unknown;
+ variantIdsToRemove: unknown;
+ collectionIdsToAdd: unknown;
+ collectionIdsToRemove: unknown;
+}): Record<string, unknown> | undefined {
+ const products = compact({
+ productsToAdd: toGidList({ type: 'Product', value: productIdsToAdd }),
+ productsToRemove: toGidList({ type: 'Product', value: productIdsToRemove }),
+ productVariantsToAdd: toGidList({ type: 'ProductVariant', value: variantIdsToAdd }),
+ productVariantsToRemove: toGidList({ type: 'ProductVariant', value: variantIdsToRemove }),
+ });
+ const collections = compact({
+ add: toGidList({ type: 'Collection', value: collectionIdsToAdd }),
+ remove: toGidList({ type: 'Collection', value: collectionIdsToRemove }),
+ });
+ const hasProducts = Object.keys(products).length > 0;
+ const hasCollections = Object.keys(collections).length > 0;
+ if (hasProducts && hasCollections) {
+ throw new Error('A discount applies to products or to collections, not both. Nothing was changed.');
+ }
+ const target = appliesTo ?? (hasProducts ? 'PRODUCTS' : hasCollections ? 'COLLECTIONS' : undefined);
+ if (target === undefined) {
+ return undefined;
+ }
+ if (target === 'ALL') {
+ if (hasProducts || hasCollections) {
+ throw new Error('applies_to ALL cannot be combined with product, variant or collection ids. Nothing was changed.');
+ }
+ return { all: true };
+ }
+ if (target === 'PRODUCTS') {
+ if (hasCollections) {
+ throw new Error('applies_to PRODUCTS takes product or variant ids, not collection ids. Nothing was changed.');
+ }
+ if (!hasProducts) {
+ throw new Error('applies_to PRODUCTS needs at least one product or variant id. Nothing was changed.');
+ }
+ return { products };
+ }
+ if (target === 'COLLECTIONS') {
+ if (hasProducts) {
+ throw new Error('applies_to COLLECTIONS takes collection ids, not product ids. Nothing was changed.');
+ }
+ if (!hasCollections) {
+ throw new Error('applies_to COLLECTIONS needs at least one collection id. Nothing was changed.');
+ }
+ return { collections };
+ }
+ throw new Error(`Unknown applies_to "${target}". Use ALL, PRODUCTS or COLLECTIONS.`);
+}
+
+function buildDiscountContext({
+ eligibility,
+ customerIdsToAdd,
+ customerIdsToRemove,
+ segmentIdsToAdd,
+ segmentIdsToRemove,
+}: {
+ eligibility: string | undefined;
+ customerIdsToAdd: unknown;
+ customerIdsToRemove: unknown;
+ segmentIdsToAdd: unknown;
+ segmentIdsToRemove: unknown;
+}): Record<string, unknown> | undefined {
+ const customers = compact({
+ add: toGidList({ type: 'Customer', value: customerIdsToAdd }),
+ remove: toGidList({ type: 'Customer', value: customerIdsToRemove }),
+ });
+ const segments = compact({
+ add: toGidList({ type: 'Segment', value: segmentIdsToAdd }),
+ remove: toGidList({ type: 'Segment', value: segmentIdsToRemove }),
+ });
+ const hasCustomers = Object.keys(customers).length > 0;
+ const hasSegments = Object.keys(segments).length > 0;
+ if (hasCustomers && hasSegments) {
+ throw new Error('Eligibility is either specific customers or customer segments, not both. Nothing was changed.');
+ }
+ const target = eligibility ?? (hasCustomers ? 'CUSTOMERS' : hasSegments ? 'SEGMENTS' : undefined);
+ if (target === undefined) {
+ return undefined;
+ }
+ if (target === 'ALL') {
+ if (hasCustomers || hasSegments) {
+ throw new Error('eligibility ALL cannot be combined with customer or segment ids. Nothing was changed.');
+ }
+ return { all: 'ALL' };
+ }
+ if (target === 'CUSTOMERS') {
+ if (!hasCustomers || hasSegments) {
+ throw new Error('eligibility CUSTOMERS needs customer ids (and no segment ids). Nothing was changed.');
+ }
+ return { customers };
+ }
+ if (target === 'SEGMENTS') {
+ if (!hasSegments || hasCustomers) {
+ throw new Error('eligibility SEGMENTS needs segment ids (and no customer ids). Nothing was changed.');
+ }
+ return { customerSegments: segments };
+ }
+ throw new Error(`Unknown eligibility "${target}". Use ALL, CUSTOMERS or SEGMENTS.`);
+}
+
+function readRedeemCodeSearch(value: string | undefined | null): string | undefined {
+ const text = nonEmpty(value);
+ if (!text) {
+ return undefined;
+ }
+ const unsupported = [...text.matchAll(/([A-Za-z_]+):/g)]
+ .map((match) => match[1])
+ .filter((field) => field.toLowerCase() !== 'times_used');
+ if (unsupported.length > 0) {
+ throw new Error(
+ `The redeem code search supports only the times_used filter (for example "times_used:0") and plain text matched against the code (for example "SUMMER"). Shopify ignores other filters such as "${unsupported[0]}:" and would then match EVERY code of the discount. Nothing was changed.`
+ );
+ }
+ return text;
+}
+
+function buildMinimumRequirement({
+ kind,
+ value,
+}: {
+ kind: string | undefined;
+ value: number | undefined;
+}): Record<string, unknown> | undefined {
+ if (kind === undefined) {
+ if (value !== undefined) {
+ throw new Error('Set minimum_requirement (SUBTOTAL or QUANTITY) together with minimum_value. Nothing was changed.');
+ }
+ return undefined;
+ }
+ if (kind === 'NONE') {
+ return {
+ quantity: { greaterThanOrEqualToQuantity: null },
+ subtotal: { greaterThanOrEqualToSubtotal: null },
+ };
+ }
+ if (value === undefined || !(value > 0)) {
+ throw new Error('minimum_value must be above 0 when a minimum requirement is set. Nothing was changed.');
+ }
+ if (kind === 'SUBTOTAL') {
+ return {
+ subtotal: { greaterThanOrEqualToSubtotal: String(value) },
+ quantity: { greaterThanOrEqualToQuantity: null },
+ };
+ }
+ if (kind === 'QUANTITY') {
+ if (!Number.isInteger(value)) {
+ throw new Error('A minimum quantity must be a whole number. Nothing was changed.');
+ }
+ return {
+ quantity: { greaterThanOrEqualToQuantity: String(value) },
+ subtotal: { greaterThanOrEqualToSubtotal: null },
+ };
+ }
+ throw new Error(`Unknown minimum_requirement "${kind}". Use NONE, SUBTOTAL or QUANTITY.`);
+}
+
+function buildCombinesWith({
+ productDiscounts,
+ orderDiscounts,
+ shippingDiscounts,
+}: {
+ productDiscounts: boolean | undefined;
+ orderDiscounts: boolean | undefined;
+ shippingDiscounts: boolean | undefined;
+}): Record<string, boolean> | undefined {
+ const values = [productDiscounts, orderDiscounts, shippingDiscounts];
+ if (values.every((entry) => entry === undefined)) {
+ return undefined;
+ }
+ if (productDiscounts === undefined || orderDiscounts === undefined || shippingDiscounts === undefined) {
+ throw new Error(
+ 'combinesWith is replaced as a whole: set all three of combines_with_product_discounts, combines_with_order_discounts and combines_with_shipping_discounts. Nothing was changed.'
+ );
+ }
+ return { productDiscounts, orderDiscounts, shippingDiscounts };
+}
+
+function buildFulfillmentOrderLineItems(value: unknown): Record<string, unknown>[] | undefined {
+ const records = readRecords(value);
+ if (records.length === 0) {
+ return undefined;
+ }
+ return records.map((record) => {
+ const id = readText(record['fulfillment_order_line_item_id']);
+ const quantity = readNumber(record['quantity']);
+ if (!id || quantity === undefined || !Number.isInteger(quantity) || quantity < 1) {
+ throw new Error(
+ 'Every line item needs a fulfillment_order_line_item_id and a whole-number quantity of 1 or more. Nothing was changed.'
+ );
+ }
+ return {
+ id: toGid({ type: 'FulfillmentOrderLineItem', id }),
+ quantity,
+ };
+ });
+}
+
+function nonEmptyList(value: unknown): string[] | undefined {
+ const list = readStringList(value);
+ return list && list.length > 0 ? list : undefined;
+}
+
+function readIsoDate(value: string | undefined | null): string | undefined {
+ const text = nonEmpty(value);
+ if (text === undefined) {
+ return undefined;
+ }
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(text) || !isCalendarDate(text)) {
+ throw new Error(`"${text}" is not a real date in the form YYYY-MM-DD. Nothing was changed.`);
+ }
+ return text;
+}
+
+function isCalendarDate(text: string): boolean {
+ const [year, month, day] = text.split('-').map(Number);
+ const date = new Date(Date.UTC(year, month - 1, day));
+ return date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day;
+}
+
+function discountFragments({
+ types,
+ detail,
+}: {
+ types: string[];
+ detail: boolean;
+}): string {
+ return types
+ .map((type) => `... on ${type} { ${discountTypeFields({ type, detail })} }`)
+ .join(' ');
+}
+
+function discountTypeFields({ type, detail }: { type: string; detail: boolean }): string {
+ const kind = type.replace(/^Discount(Code|Automatic)/, '');
+ const parts = [DISCOUNT_COMMON_FIELDS];
+ if (kind !== 'App') {
+ parts.push('summary');
+ }
+ if (type.startsWith('DiscountCode')) {
+ parts.push(detail ? DISCOUNT_CODE_DETAIL_FIELDS : DISCOUNT_CODE_SUMMARY_FIELDS);
+ }
+ if (detail && (kind === 'Basic' || kind === 'Bxgy')) {
+ parts.push(DISCOUNT_CUSTOMER_GETS_FIELDS);
+ }
+ if (detail && (kind === 'Basic' || kind === 'FreeShipping')) {
+ parts.push(DISCOUNT_MINIMUM_FIELDS);
+ }
+ if (detail && kind === 'FreeShipping') {
+ parts.push(DISCOUNT_SHIPPING_FIELDS);
+ }
+ if (detail && kind === 'Bxgy') {
+ parts.push('usesPerOrderLimit', DISCOUNT_CUSTOMER_BUYS_FIELDS);
+ }
+ return parts.join(' ');
+}
+
+function fulfillmentOrderLineItemsProp({ description }: { description: string }) {
+ return Property.Array({
+ displayName: 'Line Items',
+ description,
+ required: false,
+ properties: {
+ fulfillment_order_line_item_id: Property.ShortText({
+ displayName: 'Fulfillment Order Line Item ID',
+ description:
+ 'The fulfillment order line item id from list_order_fulfillment_orders or get_fulfillment_order (line_items[].id), for example "gid://shopify/FulfillmentOrderLineItem/1234". This is not the order line item id.',
+ required: true,
+ }),
+ quantity: Property.Number({
+ displayName: 'Quantity',
+ description: 'How many units of this line item, 1 or more and at most its remaining_quantity.',
+ required: true,
+ }),
+ },
+ });
+}
+
+function idListProp({
+ displayName,
+ description,
+}: {
+ displayName: string;
+ description: string;
+}) {
+ return Property.Array({
+ displayName,
+ description,
+ required: false,
+ });
+}
+
const MONEY_FIELDS = 'shopMoney { amount currencyCode }';
const MONEY_WITH_PRESENTMENT_FIELDS =
@@ -2057,6 +2850,98 @@ const MANUAL_SELECTION_SOURCE_TITLE = 'Selected products';
const CONDITIONS_SOURCE_TITLE = 'Product conditions';
+const FULFILLMENT_ORDER_LINE_ITEM_LIMIT = 50;
+
+const FULFILLMENT_ORDER_FIELDS = `id status requestStatus createdAt updatedAt fulfillAt fulfillBy orderId orderName assignedLocation { name location { id name } } destination { firstName lastName company address1 address2 city province zip countryCode phone email } deliveryMethod { methodType presentedName } fulfillmentHolds { id reason reasonNotes displayReason handle heldByRequestingApp } supportedActions { action } lineItems(first: ${FULFILLMENT_ORDER_LINE_ITEM_LIMIT}) { pageInfo { hasNextPage endCursor } nodes { id sku productTitle variantTitle totalQuantity remainingQuantity requiresShipping inventoryItemId lineItem { id } variant { id } } }`;
+
+const FULFILLMENT_ORDER_PAGED_FIELDS = FULFILLMENT_ORDER_FIELDS.replace(
+ `lineItems(first: ${FULFILLMENT_ORDER_LINE_ITEM_LIMIT}) {`,
+ `lineItems(first: ${FULFILLMENT_ORDER_LINE_ITEM_LIMIT}, after: $lineItemsAfter) {`
+);
+
+const FULFILLMENT_SUMMARY_FIELDS =
+ 'id legacyResourceId name status displayStatus createdAt updatedAt inTransitAt deliveredAt estimatedDeliveryAt totalQuantity requiresShipping trackingInfo(first: 10) { company number url } location { id name } service { id serviceName } order { id name }';
+
+const FULFILLMENT_FIELDS = `${FULFILLMENT_SUMMARY_FIELDS} originAddress { address1 address2 city zip provinceCode countryCode } fulfillmentLineItems(first: 50) { pageInfo { hasNextPage } nodes { id quantity lineItem { id title sku } } }`;
+
+const FULFILLMENT_EVENT_FIELDS =
+ 'id status message happenedAt createdAt estimatedDeliveryAt address1 city province country zip latitude longitude';
+
+const FULFILLMENT_SERVICE_FIELDS =
+ 'id handle serviceName type callbackUrl inventoryManagement trackingSupport requiresShippingMethod location { id name }';
+
+const CARRIER_SERVICE_FIELDS =
+ 'id name formattedName active callbackUrl supportsServiceDiscovery';
+
+const DELIVERY_PROFILE_FIELDS =
+ 'id name default version activeMethodDefinitionsCount locationsWithoutRatesCount originLocationCount zoneCountryCount productVariantsCount { count } profileLocationGroups { locationGroup { id locationsCount { count } } locationGroupZones(first: 2) { pageInfo { hasNextPage } nodes { zone { id name countries { name code { countryCode restOfWorld } } } methodDefinitions(first: 3) { pageInfo { hasNextPage } nodes { id name active description rateProvider { __typename ... on DeliveryRateDefinition { price { amount currencyCode } } ... on DeliveryParticipant { carrierService { id name } } } } } } } }';
+
+const DELIVERY_ZONE_FIELDS =
+ 'zone { id name countries { name code { countryCode restOfWorld } } } methodDefinitions(first: 50, after: $ratesAfter) { pageInfo { hasNextPage endCursor } nodes { id name active description rateProvider { __typename ... on DeliveryRateDefinition { price { amount currencyCode } } ... on DeliveryParticipant { carrierService { id name } } } } }';
+
+const GIFT_CARD_FIELDS =
+ 'id lastCharacters maskedCode enabled isRedeemable deactivatedAt expiresOn createdAt updatedAt note templateSuffix balance { amount currencyCode } initialValue { amount currencyCode } customer { id displayName } order { id name } recipientAttributes { preferredName message sendNotificationAt recipient { id displayName } }';
+
+const DISCOUNT_MARKETS_LIMIT = 10;
+
+const DISCOUNT_COMMON_FIELDS = `title status startsAt endsAt createdAt updatedAt asyncUsageCount discountClasses tags combinesWith { productDiscounts orderDiscounts shippingDiscounts } context { __typename ... on DiscountBuyerSelectionAll { all } ... on DiscountCustomers { customers { id } } ... on DiscountCustomerSegments { segments { id } } ... on DiscountMarkets { marketsCount markets(first: ${DISCOUNT_MARKETS_LIMIT}) { nodes { id } } } }`;
+
+const DISCOUNT_ITEMS_FIELDS =
+ 'items { __typename ... on DiscountProducts { products(first: 25) { pageInfo { hasNextPage } nodes { id } } productVariants(first: 25) { pageInfo { hasNextPage } nodes { id } } } ... on DiscountCollections { collections(first: 25) { pageInfo { hasNextPage } nodes { id } } } }';
+
+const DISCOUNT_CUSTOMER_BUYS_FIELDS = `customerBuys { value { __typename ... on DiscountQuantity { quantity } ... on DiscountPurchaseAmount { amount } } ${DISCOUNT_ITEMS_FIELDS} }`;
+
+const DISCOUNT_CODE_SUMMARY_FIELDS =
+ 'appliesOncePerCustomer usageLimit codesCount { count } codes(first: 1) { nodes { code } }';
+
+const DISCOUNT_CODE_DETAIL_FIELDS =
+ 'appliesOncePerCustomer usageLimit codesCount { count } codes(first: 10) { nodes { code } }';
+
+const DISCOUNT_CUSTOMER_GETS_FIELDS = `customerGets { value { __typename ... on DiscountPercentage { percentage } ... on DiscountAmount { amount { amount currencyCode } appliesOnEachItem } ... on DiscountOnQuantity { quantity { quantity } effect { __typename ... on DiscountPercentage { percentage } ... on DiscountAmount { amount { amount currencyCode } } } } } ${DISCOUNT_ITEMS_FIELDS} }`;
+
+const DISCOUNT_MINIMUM_FIELDS =
+ 'minimumRequirement { __typename ... on DiscountMinimumQuantity { greaterThanOrEqualToQuantity } ... on DiscountMinimumSubtotal { greaterThanOrEqualToSubtotal { amount currencyCode } } }';
+
+const DISCOUNT_SHIPPING_FIELDS =
+ 'maximumShippingPrice { amount currencyCode } destinationSelection { __typename ... on DiscountCountries { countries } ... on DiscountCountryAll { allCountries } }';
+
+const CODE_DISCOUNT_TYPES = [
+ 'DiscountCodeBasic',
+ 'DiscountCodeBxgy',
+ 'DiscountCodeFreeShipping',
+ 'DiscountCodeApp',
+];
+
+const AUTOMATIC_DISCOUNT_TYPES = [
+ 'DiscountAutomaticBasic',
+ 'DiscountAutomaticBxgy',
+ 'DiscountAutomaticFreeShipping',
+ 'DiscountAutomaticApp',
+];
+
+const DISCOUNT_SUMMARY_FIELDS = `__typename ${discountFragments({
+ types: [...CODE_DISCOUNT_TYPES, ...AUTOMATIC_DISCOUNT_TYPES],
+ detail: false,
+})}`;
+
+const DISCOUNT_DETAIL_FIELDS = `__typename ${discountFragments({
+ types: [...CODE_DISCOUNT_TYPES, ...AUTOMATIC_DISCOUNT_TYPES],
+ detail: true,
+})}`;
+
+const CODE_DISCOUNT_DETAIL_FIELDS = `__typename ${discountFragments({
+ types: CODE_DISCOUNT_TYPES,
+ detail: true,
+})}`;
+
+const DISCOUNT_ID_KINDS: Record<string, DiscountIdKind> = {
+ DiscountCodeNode: 'code',
+ DiscountAutomaticNode: 'automatic',
+ DiscountNode: 'node',
+};
+
+const MAX_REDEEM_CODES_PER_CALL = 250;
+
export const shopifyFields = {
MONEY_FIELDS,
@@ -2090,6 +2975,21 @@ export const shopifyFields = {
TAXONOMY_CATEGORY_FIELDS,
MANUAL_SELECTION_SOURCE_TITLE,
CONDITIONS_SOURCE_TITLE,
+ FULFILLMENT_ORDER_FIELDS,
+ FULFILLMENT_ORDER_PAGED_FIELDS,
+ DELIVERY_ZONE_FIELDS,
+ FULFILLMENT_SUMMARY_FIELDS,
+ FULFILLMENT_FIELDS,
+ FULFILLMENT_EVENT_FIELDS,
+ FULFILLMENT_SERVICE_FIELDS,
+ CARRIER_SERVICE_FIELDS,
+ DELIVERY_PROFILE_FIELDS,
+ GIFT_CARD_FIELDS,
+ DISCOUNT_SUMMARY_FIELDS,
+ DISCOUNT_DETAIL_FIELDS,
+ CODE_DISCOUNT_DETAIL_FIELDS,
+ CODE_DISCOUNT_TYPES,
+ MAX_REDEEM_CODES_PER_CALL,
};
export const shopifyGraphqlClient = {
@@ -2131,6 +3031,18 @@ export const shopifyValues = {
sharedConditionsSources,
findExplicitConditionsSource,
groupVariantMedia,
+ readDiscountId,
+ toDiscountCodeNodeId,
+ readRedeemCodeSearch,
+ buildDiscountValue,
+ buildDiscountItems,
+ buildDiscountContext,
+ buildMinimumRequirement,
+ buildCombinesWith,
+ buildFulfillmentOrderLineItems,
+ readIsoDate,
+ nonEmptyList,
+ clearableValue,
};
export const shopifyMappers = {
@@ -2160,6 +3072,19 @@ export const shopifyMappers = {
mapPublication,
mapChannel,
mapTaxonomyCategory,
+ mapFulfillmentOrder,
+ mapFulfillmentOrderOrNull,
+ mapFulfillmentSummary,
+ mapFulfillment,
+ mapFulfillmentEvent,
+ mapFulfillmentService,
+ mapCarrierService,
+ mapDeliveryProfile,
+ mapDeliveryZone,
+ mapGiftCard,
+ mapDiscountNode,
+ mapDiscountRedeemCode,
+ mapDiscountBulkCreation,
};
export const shopifyProps = {
@@ -2177,6 +3102,8 @@ export const shopifyProps = {
conditions: conditionsProp,
collectionSortOrder: collectionSortOrderProp,
productStatus: productStatusProp,
+ fulfillmentOrderLineItems: fulfillmentOrderLineItemsProp,
+ idList: idListProp,
};
export type ShopifyGraphqlParams = {
@@ -2776,3 +3703,287 @@ export type GqlJob = {
id?: string | null;
done?: boolean | null;
};
+
+export type GqlRef = {
+ id: string;
+ name?: string | null;
+};
+
+export type GqlFulfillmentOrder = {
+ id: string;
+ status?: string | null;
+ requestStatus?: string | null;
+ createdAt?: string | null;
+ updatedAt?: string | null;
+ fulfillAt?: string | null;
+ fulfillBy?: string | null;
+ orderId?: string | null;
+ orderName?: string | null;
+ assignedLocation?: { name?: string | null; location?: GqlRef | null } | null;
+ destination?: {
+ firstName?: string | null;
+ lastName?: string | null;
+ company?: string | null;
+ address1?: string | null;
+ address2?: string | null;
+ city?: string | null;
+ province?: string | null;
+ zip?: string | null;
+ countryCode?: string | null;
+ phone?: string | null;
+ email?: string | null;
+ } | null;
+ deliveryMethod?: { methodType?: string | null; presentedName?: string | null } | null;
+ fulfillmentHolds?: GqlFulfillmentHold[] | null;
+ supportedActions?: { action?: string | null }[] | null;
+ lineItems?: GqlConnection<{
+ id: string;
+ sku?: string | null;
+ productTitle?: string | null;
+ variantTitle?: string | null;
+ totalQuantity?: number | null;
+ remainingQuantity?: number | null;
+ requiresShipping?: boolean | null;
+ inventoryItemId?: string | null;
+ lineItem?: { id: string } | null;
+ variant?: { id: string } | null;
+ }> | null;
+};
+
+export type GqlFulfillmentHold = {
+ id: string;
+ reason?: string | null;
+ reasonNotes?: string | null;
+ displayReason?: string | null;
+ handle?: string | null;
+ heldByRequestingApp?: boolean | null;
+};
+
+export type GqlFulfillment = {
+ id: string;
+ legacyResourceId?: string | null;
+ name?: string | null;
+ status?: string | null;
+ displayStatus?: string | null;
+ createdAt?: string | null;
+ updatedAt?: string | null;
+ inTransitAt?: string | null;
+ deliveredAt?: string | null;
+ estimatedDeliveryAt?: string | null;
+ totalQuantity?: number | null;
+ requiresShipping?: boolean | null;
+ trackingInfo?: { company?: string | null; number?: string | null; url?: string | null }[] | null;
+ location?: GqlRef | null;
+ service?: { id: string; serviceName?: string | null } | null;
+ order?: GqlRef | null;
+ originAddress?: {
+ address1?: string | null;
+ address2?: string | null;
+ city?: string | null;
+ zip?: string | null;
+ provinceCode?: string | null;
+ countryCode?: string | null;
+ } | null;
+ fulfillmentLineItems?: GqlConnection<{
+ id: string;
+ quantity?: number | null;
+ lineItem?: { id: string; title?: string | null; sku?: string | null } | null;
+ }> | null;
+};
+
+export type GqlFulfillmentEvent = {
+ id: string;
+ status?: string | null;
+ message?: string | null;
+ happenedAt?: string | null;
+ createdAt?: string | null;
+ estimatedDeliveryAt?: string | null;
+ address1?: string | null;
+ city?: string | null;
+ province?: string | null;
+ country?: string | null;
+ zip?: string | null;
+ latitude?: number | null;
+ longitude?: number | null;
+};
+
+export type GqlFulfillmentService = {
+ id: string;
+ handle?: string | null;
+ serviceName?: string | null;
+ type?: string | null;
+ callbackUrl?: string | null;
+ inventoryManagement?: boolean | null;
+ trackingSupport?: boolean | null;
+ requiresShippingMethod?: boolean | null;
+ location?: GqlRef | null;
+};
+
+export type GqlCarrierService = {
+ id: string;
+ name?: string | null;
+ formattedName?: string | null;
+ active?: boolean | null;
+ callbackUrl?: string | null;
+ supportsServiceDiscovery?: boolean | null;
+};
+
+export type GqlDeliveryProfile = {
+ id: string;
+ name?: string | null;
+ default?: boolean | null;
+ version?: number | null;
+ activeMethodDefinitionsCount?: number | null;
+ locationsWithoutRatesCount?: number | null;
+ originLocationCount?: number | null;
+ zoneCountryCount?: number | null;
+ productVariantsCount?: GqlCount | null;
+ profileLocationGroups?: {
+ locationGroup?: { id: string; locationsCount?: GqlCount | null } | null;
+ locationGroupZones?: GqlConnection<GqlDeliveryZoneEntry> | null;
+ }[] | null;
+};
+
+export type GqlDeliveryZoneEntry = {
+ zone?: {
+ id: string;
+ name?: string | null;
+ countries?: {
+ name?: string | null;
+ code?: { countryCode?: string | null; restOfWorld?: boolean | null } | null;
+ }[] | null;
+ } | null;
+ methodDefinitions?: GqlConnection<{
+ id: string;
+ name?: string | null;
+ active?: boolean | null;
+ description?: string | null;
+ rateProvider?: {
+ __typename?: string;
+ price?: GqlMoneyV2 | null;
+ carrierService?: GqlRef | null;
+ } | null;
+ }> | null;
+};
+
+export type GqlGiftCard = {
+ id: string;
+ lastCharacters?: string | null;
+ maskedCode?: string | null;
+ enabled?: boolean | null;
+ isRedeemable?: boolean | null;
+ deactivatedAt?: string | null;
+ expiresOn?: string | null;
+ createdAt?: string | null;
+ updatedAt?: string | null;
+ note?: string | null;
+ templateSuffix?: string | null;
+ balance?: GqlMoneyV2 | null;
+ initialValue?: GqlMoneyV2 | null;
+ customer?: { id: string; displayName?: string | null } | null;
+ order?: GqlRef | null;
+ recipientAttributes?: {
+ preferredName?: string | null;
+ message?: string | null;
+ sendNotificationAt?: string | null;
+ recipient?: { id: string; displayName?: string | null } | null;
+ } | null;
+};
+
+export type GqlDiscountNode = {
+ id: string;
+ discount?: GqlDiscount | null;
+};
+
+export type GqlDiscount = {
+ __typename?: string;
+ title?: string | null;
+ status?: string | null;
+ summary?: string | null;
+ startsAt?: string | null;
+ endsAt?: string | null;
+ createdAt?: string | null;
+ updatedAt?: string | null;
+ asyncUsageCount?: number | null;
+ discountClasses?: string[] | null;
+ tags?: string[] | null;
+ combinesWith?: {
+ productDiscounts?: boolean | null;
+ orderDiscounts?: boolean | null;
+ shippingDiscounts?: boolean | null;
+ } | null;
+ context?: {
+ __typename?: string;
+ customers?: { id: string }[] | null;
+ segments?: { id: string }[] | null;
+ marketsCount?: number | null;
+ markets?: GqlConnection<{ id: string }> | null;
+ } | null;
+ appliesOncePerCustomer?: boolean | null;
+ usageLimit?: number | null;
+ codesCount?: GqlCount | null;
+ codes?: GqlConnection<GqlDiscountRedeemCode> | null;
+ customerGets?: {
+ value?: GqlDiscountValue | null;
+ items?: GqlDiscountItems | null;
+ } | null;
+ customerBuys?: {
+ value?: {
+ __typename?: string;
+ quantity?: string | null;
+ amount?: string | null;
+ } | null;
+ items?: GqlDiscountItems | null;
+ } | null;
+ minimumRequirement?: {
+ __typename?: string;
+ greaterThanOrEqualToQuantity?: string | null;
+ greaterThanOrEqualToSubtotal?: GqlMoneyV2 | null;
+ } | null;
+ maximumShippingPrice?: GqlMoneyV2 | null;
+ destinationSelection?: {
+ __typename?: string;
+ countries?: string[] | null;
+ allCountries?: boolean | null;
+ } | null;
+ usesPerOrderLimit?: number | null;
+};
+
+export type GqlDiscountItems = {
+ __typename?: string;
+ products?: GqlConnection<{ id: string }> | null;
+ productVariants?: GqlConnection<{ id: string }> | null;
+ collections?: GqlConnection<{ id: string }> | null;
+};
+
+export type GqlDiscountValue = {
+ __typename?: string;
+ percentage?: number | null;
+ amount?: GqlMoneyV2 | null;
+ appliesOnEachItem?: boolean | null;
+ quantity?: { quantity?: string | null } | null;
+ effect?: {
+ __typename?: string;
+ percentage?: number | null;
+ amount?: GqlMoneyV2 | null;
+ } | null;
+};
+
+export type GqlDiscountRedeemCode = {
+ id?: string | null;
+ code?: string | null;
+ asyncUsageCount?: number | null;
+ createdBy?: { id?: string | null; title?: string | null } | null;
+};
+
+export type GqlDiscountRedeemCodeBulkCreation = {
+ id?: string | null;
+ done?: boolean | null;
+ codesCount?: number | null;
+ importedCount?: number | null;
+ failedCount?: number | null;
+ createdAt?: string | null;
+ discountCode?: { id: string } | null;
+};
+
+export type DiscountIdKind = 'code' | 'automatic' | 'node';
diff --git a/packages/pieces/community/shopify/src/lib/output-schemas/fulfillment.ts b/packages/pieces/community/shopify/src/lib/output-schemas/fulfillment.ts
new file mode 100644
index 00000000000..e9073d7ba1e
--- /dev/null
+++ b/packages/pieces/community/shopify/src/lib/output-schemas/fulfillment.ts
@@ -0,0 +1,852 @@
+import { OutputSchema, OutputSchemaField } from '@activepieces/pieces-framework';
+
+const redactedFieldsField: OutputSchemaField = {
+ key: 'redacted_fields',
+ label: 'Redacted Fields',
+ description:
+ 'Response paths Shopify withheld, for example because the app is not approved for protected customer data.',
+};
+
+const pageFields: OutputSchema['fields'] = [
+ { key: 'count', label: 'Count', format: 'number' },
+ { key: 'has_next_page', label: 'Has Next Page', format: 'boolean' },
+ {
+ key: 'end_cursor',
+ label: 'End Cursor',
+ description: 'Pass back as the cursor to read the next page.',
+ },
+ redactedFieldsField,
+];
+
+const countFields: OutputSchema['fields'] = [
+ { key: 'count', label: 'Count', format: 'number' },
+ {
+ key: 'precision',
+ label: 'Precision',
+ description: 'EXACT, or AT_LEAST when Shopify capped the count.',
+ },
+ redactedFieldsField,
+];
+
+const discountFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Discount ID' },
+ { key: 'method', label: 'Method', description: 'code or automatic.' },
+ { key: 'discount_type', label: 'Discount Type' },
+ { key: 'title', label: 'Title' },
+ { key: 'status', label: 'Status' },
+ { key: 'summary', label: 'Summary' },
+ { key: 'starts_at', label: 'Starts At', format: 'datetime' },
+ { key: 'ends_at', label: 'Ends At', format: 'datetime' },
+ { key: 'created_at', label: 'Created At', format: 'datetime' },
+ { key: 'updated_at', label: 'Updated At', format: 'datetime' },
+ { key: 'usage_count', label: 'Usage Count', format: 'number' },
+ { key: 'discount_classes', label: 'Discount Classes' },
+ { key: 'tags', label: 'Tags' },
+ {
+ key: 'combines_with_product_discounts',
+ label: 'Combines With Product Discounts',
+ format: 'boolean',
+ },
+ {
+ key: 'combines_with_order_discounts',
+ label: 'Combines With Order Discounts',
+ format: 'boolean',
+ },
+ {
+ key: 'combines_with_shipping_discounts',
+ label: 'Combines With Shipping Discounts',
+ format: 'boolean',
+ },
+ {
+ key: 'applies_once_per_customer',
+ label: 'Applies Once Per Customer',
+ format: 'boolean',
+ },
+ { key: 'usage_limit', label: 'Usage Limit', format: 'number' },
+ { key: 'codes_count', label: 'Codes Count', format: 'number' },
+ { key: 'codes', label: 'Codes', description: 'Up to 10 redeem codes.' },
+ {
+ key: 'eligibility',
+ label: 'Eligibility',
+ description: 'ALL, CUSTOMERS or SEGMENTS.',
+ },
+ { key: 'customer_ids', label: 'Customer IDs' },
+ { key: 'segment_ids', label: 'Segment IDs' },
+ { key: 'market_ids', label: 'Market IDs' },
+ { key: 'markets_truncated', label: 'Markets Truncated', format: 'boolean' },
+ {
+ key: 'value_type',
+ label: 'Value Type',
+ description: 'PERCENTAGE, FIXED_AMOUNT or QUANTITY.',
+ },
+ {
+ key: 'percentage',
+ label: 'Percentage',
+ format: 'number',
+ description: 'Percent off, for example 15 for 15%.',
+ },
+ { key: 'amount', label: 'Amount', format: 'number' },
+ { key: 'amount_currency', label: 'Amount Currency' },
+ {
+ key: 'applies_on_each_item',
+ label: 'Applies On Each Item',
+ format: 'boolean',
+ },
+ { key: 'quantity', label: 'Quantity', format: 'number' },
+ {
+ key: 'applies_to',
+ label: 'Applies To',
+ description: 'ALL, PRODUCTS or COLLECTIONS.',
+ },
+ { key: 'product_ids', label: 'Product IDs' },
+ { key: 'variant_ids', label: 'Variant IDs' },
+ { key: 'collection_ids', label: 'Collection IDs' },
+ { key: 'items_truncated', label: 'Items Truncated', format: 'boolean' },
+ { key: 'buys_type', label: 'Buys Type' },
+ { key: 'buys_quantity', label: 'Buys Quantity', format: 'number' },
+ { key: 'buys_amount', label: 'Buys Amount', format: 'number' },
+ { key: 'buys_applies_to', label: 'Buys Applies To' },
+ { key: 'buys_product_ids', label: 'Buys Product IDs' },
+ { key: 'buys_variant_ids', label: 'Buys Variant IDs' },
+ { key: 'buys_collection_ids', label: 'Buys Collection IDs' },
+ {
+ key: 'buys_items_truncated',
+ label: 'Buys Items Truncated',
+ format: 'boolean',
+ },
+ { key: 'minimum_quantity', label: 'Minimum Quantity', format: 'number' },
+ { key: 'minimum_subtotal', label: 'Minimum Subtotal', format: 'number' },
+ { key: 'minimum_subtotal_currency', label: 'Minimum Subtotal Currency' },
+ {
+ key: 'maximum_shipping_price',
+ label: 'Maximum Shipping Price',
+ format: 'number',
+ },
+ {
+ key: 'destination_all_countries',
+ label: 'Destination All Countries',
+ format: 'boolean',
+ },
+ { key: 'destination_countries', label: 'Destination Countries' },
+ {
+ key: 'uses_per_order_limit',
+ label: 'Uses Per Order Limit',
+ format: 'number',
+ },
+];
+
+const bulkCreationFields: OutputSchema['fields'] = [
+ { key: 'bulk_creation_id', label: 'Bulk Creation ID' },
+ { key: 'done', label: 'Done', format: 'boolean' },
+ { key: 'codes_count', label: 'Codes Count', format: 'number' },
+ { key: 'imported_count', label: 'Imported Count', format: 'number' },
+ { key: 'failed_count', label: 'Failed Count', format: 'number' },
+ { key: 'created_at', label: 'Created At', format: 'datetime' },
+ { key: 'discount_id', label: 'Discount ID' },
+];
+
+export const discountOutputSchema: OutputSchema = {
+ fields: [...discountFields, redactedFieldsField],
+};
+
+export const findDiscountByCodeOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'found', label: 'Found', format: 'boolean' },
+ { key: 'searched_code', label: 'Searched Code' },
+ ...discountFields,
+ redactedFieldsField,
+ ],
+};
+
+export const listDiscountsOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'items',
+ label: 'Discounts',
+ labelKey: 'title',
+ listItems: discountFields,
+ },
+ ...pageFields,
+ ],
+};
+
+export const discountCountOutputSchema: OutputSchema = {
+ fields: countFields,
+};
+
+export const giftCardCountOutputSchema: OutputSchema = {
+ fields: countFields,
+};
+
+export const addDiscountRedeemCodesOutputSchema: OutputSchema = {
+ fields: [
+ ...bulkCreationFields,
+ { key: 'codes_sent', label: 'Codes Sent', format: 'number' },
+ redactedFieldsField,
+ ],
+};
+
+export const getDiscountRedeemCodeBulkCreationOutputSchema: OutputSchema = {
+ fields: [
+ ...bulkCreationFields,
+ {
+ key: 'codes',
+ label: 'Codes',
+ labelKey: 'code',
+ listItems: [
+ { key: 'code', label: 'Code' },
+ { key: 'discount_redeem_code_id', label: 'Redeem Code ID' },
+ {
+ key: 'errors',
+ label: 'Errors',
+ labelKey: 'message',
+ listItems: [
+ { key: 'field', label: 'Field' },
+ { key: 'message', label: 'Message' },
+ { key: 'code', label: 'Code' },
+ ],
+ },
+ ],
+ },
+ { key: 'codes_on_page', label: 'Codes On Page', format: 'number' },
+ { key: 'has_next_page', label: 'Has Next Page', format: 'boolean' },
+ {
+ key: 'end_cursor',
+ label: 'End Cursor',
+ description: 'Pass back as the cursor to read the next page.',
+ },
+ redactedFieldsField,
+ ],
+};
+
+export const listDiscountRedeemCodesOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'discount_id', label: 'Discount ID' },
+ { key: 'discount_type', label: 'Discount Type' },
+ {
+ key: 'items',
+ label: 'Redeem Codes',
+ labelKey: 'code',
+ listItems: [
+ { key: 'id', label: 'Redeem Code ID' },
+ { key: 'code', label: 'Code' },
+ { key: 'usage_count', label: 'Usage Count', format: 'number' },
+ { key: 'created_by_app_id', label: 'Created By App ID' },
+ { key: 'created_by_app_title', label: 'Created By App' },
+ ],
+ },
+ ...pageFields,
+ ],
+};
+
+export const deleteDiscountRedeemCodesOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'discount_id', label: 'Discount ID' },
+ {
+ key: 'job_id',
+ label: 'Job ID',
+ description: 'Poll get_job with this id until done is true.',
+ },
+ { key: 'done', label: 'Done', format: 'boolean' },
+ redactedFieldsField,
+ ],
+};
+
+export const deleteDiscountOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'deleted_discount_id', label: 'Deleted Discount ID' },
+ { key: 'method', label: 'Method', description: 'code or automatic.' },
+ redactedFieldsField,
+ ],
+};
+
+export const listFulfillmentServicesOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'items',
+ label: 'Fulfillment Services',
+ labelKey: 'service_name',
+ listItems: [
+ { key: 'id', label: 'Fulfillment Service ID' },
+ { key: 'handle', label: 'Handle' },
+ { key: 'service_name', label: 'Service Name' },
+ { key: 'type', label: 'Type' },
+ { key: 'callback_url', label: 'Callback URL', format: 'url' },
+ {
+ key: 'inventory_management',
+ label: 'Inventory Management',
+ format: 'boolean',
+ },
+ { key: 'tracking_support', label: 'Tracking Support', format: 'boolean' },
+ {
+ key: 'requires_shipping_method',
+ label: 'Requires Shipping Method',
+ format: 'boolean',
+ },
+ { key: 'location_id', label: 'Location ID' },
+ { key: 'location_name', label: 'Location Name' },
+ ],
+ },
+ { key: 'count', label: 'Count', format: 'number' },
+ redactedFieldsField,
+ ],
+};
+
+export const deleteFulfillmentServiceOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'deleted_id', label: 'Deleted Fulfillment Service ID' },
+ { key: 'inventory_action', label: 'Inventory Action' },
+ redactedFieldsField,
+ ],
+};
+
+export const listCarrierServicesOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'items',
+ label: 'Carrier Services',
+ labelKey: 'name',
+ listItems: [
+ { key: 'id', label: 'Carrier Service ID' },
+ { key: 'name', label: 'Name' },
+ { key: 'formatted_name', label: 'Formatted Name' },
+ { key: 'active', label: 'Active', format: 'boolean' },
+ { key: 'callback_url', label: 'Callback URL', format: 'url' },
+ {
+ key: 'supports_service_discovery',
+ label: 'Supports Service Discovery',
+ format: 'boolean',
+ },
+ ],
+ },
+ ...pageFields,
+ ],
+};
+
+export const listDeliveryProfilesOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'items',
+ label: 'Delivery Profiles',
+ labelKey: 'name',
+ listItems: [
+ { key: 'id', label: 'Delivery Profile ID' },
+ { key: 'name', label: 'Name' },
+ { key: 'default', label: 'Default', format: 'boolean' },
+ { key: 'version', label: 'Version', format: 'number' },
+ {
+ key: 'active_method_definitions_count',
+ label: 'Active Rates Count',
+ format: 'number',
+ },
+ {
+ key: 'locations_without_rates_count',
+ label: 'Locations Without Rates',
+ format: 'number',
+ },
+ {
+ key: 'origin_location_count',
+ label: 'Origin Locations',
+ format: 'number',
+ },
+ {
+ key: 'zone_country_count',
+ label: 'Zone Countries',
+ format: 'number',
+ },
+ {
+ key: 'product_variants_count',
+ label: 'Product Variants',
+ format: 'number',
+ },
+ {
+ key: 'location_groups',
+ label: 'Location Groups',
+ labelKey: 'location_group_id',
+ listItems: [
+ { key: 'location_group_id', label: 'Location Group ID' },
+ { key: 'locations_count', label: 'Locations', format: 'number' },
+ {
+ key: 'zones',
+ label: 'Zones',
+ labelKey: 'zone_name',
+ listItems: [
+ { key: 'zone_id', label: 'Zone ID' },
+ { key: 'zone_name', label: 'Zone Name' },
+ { key: 'countries', label: 'Countries' },
+ {
+ key: 'rates',
+ label: 'Rates',
+ labelKey: 'name',
+ listItems: [
+ { key: 'id', label: 'Rate ID' },
+ { key: 'name', label: 'Name' },
+ { key: 'active', label: 'Active', format: 'boolean' },
+ { key: 'description', label: 'Description' },
+ { key: 'price', label: 'Price', format: 'number' },
+ { key: 'currency_code', label: 'Currency Code' },
+ { key: 'carrier_service_id', label: 'Carrier Service ID' },
+ {
+ key: 'carrier_service_name',
+ label: 'Carrier Service Name',
+ },
+ ],
+ },
+ {
+ key: 'rates_truncated',
+ label: 'Rates Truncated',
+ format: 'boolean',
+ },
+ ],
+ },
+ {
+ key: 'zones_truncated',
+ label: 'Zones Truncated',
+ format: 'boolean',
+ },
+ ],
+ },
+ ],
+ },
+ ...pageFields,
+ ],
+};
+
+const fulfillmentOrderFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Fulfillment Order ID' },
+ { key: 'status', label: 'Status' },
+ { key: 'request_status', label: 'Request Status' },
+ { key: 'order_id', label: 'Order ID' },
+ { key: 'order_name', label: 'Order Name' },
+ { key: 'created_at', label: 'Created At', format: 'datetime' },
+ { key: 'updated_at', label: 'Updated At', format: 'datetime' },
+ { key: 'fulfill_at', label: 'Fulfill At', format: 'datetime' },
+ { key: 'fulfill_by', label: 'Fulfill By', format: 'datetime' },
+ { key: 'assigned_location_id', label: 'Assigned Location ID' },
+ { key: 'assigned_location_name', label: 'Assigned Location Name' },
+ { key: 'destination_first_name', label: 'Destination First Name' },
+ { key: 'destination_last_name', label: 'Destination Last Name' },
+ { key: 'destination_company', label: 'Destination Company' },
+ { key: 'destination_address1', label: 'Destination Address 1' },
+ { key: 'destination_address2', label: 'Destination Address 2' },
+ { key: 'destination_city', label: 'Destination City' },
+ { key: 'destination_province', label: 'Destination Province' },
+ { key: 'destination_zip', label: 'Destination Zip' },
+ { key: 'destination_country_code', label: 'Destination Country Code' },
+ { key: 'destination_phone', label: 'Destination Phone' },
+ { key: 'destination_email', label: 'Destination Email', format: 'email' },
+ { key: 'delivery_method_type', label: 'Delivery Method Type' },
+ { key: 'delivery_method_name', label: 'Delivery Method Name' },
+ {
+ key: 'holds',
+ label: 'Holds',
+ labelKey: 'display_reason',
+ listItems: [
+ { key: 'id', label: 'Hold ID' },
+ { key: 'reason', label: 'Reason' },
+ { key: 'reason_notes', label: 'Reason Notes' },
+ { key: 'display_reason', label: 'Display Reason' },
+ { key: 'handle', label: 'Handle' },
+ {
+ key: 'held_by_requesting_app',
+ label: 'Held By This App',
+ format: 'boolean',
+ },
+ ],
+ },
+ {
+ key: 'supported_actions',
+ label: 'Supported Actions',
+ description: 'Actions allowed right now, for example HOLD, MOVE or CREATE_FULFILLMENT.',
+ },
+ {
+ key: 'line_items',
+ label: 'Line Items',
+ labelKey: 'product_title',
+ listItems: [
+ { key: 'id', label: 'Fulfillment Order Line Item ID' },
+ { key: 'sku', label: 'SKU' },
+ { key: 'product_title', label: 'Product Title' },
+ { key: 'variant_title', label: 'Variant Title' },
+ { key: 'total_quantity', label: 'Total Quantity', format: 'number' },
+ {
+ key: 'remaining_quantity',
+ label: 'Remaining Quantity',
+ format: 'number',
+ },
+ { key: 'requires_shipping', label: 'Requires Shipping', format: 'boolean' },
+ { key: 'line_item_id', label: 'Order Line Item ID' },
+ { key: 'variant_id', label: 'Variant ID' },
+ { key: 'inventory_item_id', label: 'Inventory Item ID' },
+ ],
+ },
+ {
+ key: 'line_items_truncated',
+ label: 'Line Items Truncated',
+ format: 'boolean',
+ },
+ {
+ key: 'line_items_end_cursor',
+ label: 'Line Items Cursor',
+ description: 'Pass to get_fulfillment_order as line_items_after to read the next 50 line items.',
+ },
+];
+
+const fulfillmentSummaryFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Fulfillment ID' },
+ { key: 'legacy_resource_id', label: 'Legacy Resource ID' },
+ { key: 'name', label: 'Name' },
+ { key: 'status', label: 'Status' },
+ { key: 'display_status', label: 'Display Status' },
+ { key: 'created_at', label: 'Created At', format: 'datetime' },
+ { key: 'updated_at', label: 'Updated At', format: 'datetime' },
+ { key: 'in_transit_at', label: 'In Transit At', format: 'datetime' },
+ { key: 'delivered_at', label: 'Delivered At', format: 'datetime' },
+ {
+ key: 'estimated_delivery_at',
+ label: 'Estimated Delivery At',
+ format: 'datetime',
+ },
+ { key: 'total_quantity', label: 'Total Quantity', format: 'number' },
+ { key: 'requires_shipping', label: 'Requires Shipping', format: 'boolean' },
+ { key: 'tracking_company', label: 'Tracking Company' },
+ { key: 'tracking_numbers', label: 'Tracking Numbers' },
+ { key: 'tracking_urls', label: 'Tracking URLs' },
+ { key: 'location_id', label: 'Location ID' },
+ { key: 'location_name', label: 'Location Name' },
+ { key: 'service_id', label: 'Fulfillment Service ID' },
+ { key: 'service_name', label: 'Fulfillment Service Name' },
+ { key: 'order_id', label: 'Order ID' },
+ { key: 'order_name', label: 'Order Name' },
+];
+
+const fulfillmentFields: OutputSchema['fields'] = [
+ ...fulfillmentSummaryFields,
+ { key: 'origin_address1', label: 'Origin Address 1' },
+ { key: 'origin_address2', label: 'Origin Address 2' },
+ { key: 'origin_city', label: 'Origin City' },
+ { key: 'origin_zip', label: 'Origin Zip' },
+ { key: 'origin_province_code', label: 'Origin Province Code' },
+ { key: 'origin_country_code', label: 'Origin Country Code' },
+ {
+ key: 'line_items',
+ label: 'Line Items',
+ labelKey: 'title',
+ listItems: [
+ { key: 'id', label: 'Fulfillment Line Item ID' },
+ { key: 'quantity', label: 'Quantity', format: 'number' },
+ { key: 'line_item_id', label: 'Order Line Item ID' },
+ { key: 'title', label: 'Title' },
+ { key: 'sku', label: 'SKU' },
+ ],
+ },
+ {
+ key: 'line_items_truncated',
+ label: 'Line Items Truncated',
+ format: 'boolean',
+ },
+];
+
+const fulfillmentEventFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Fulfillment Event ID' },
+ { key: 'status', label: 'Status' },
+ { key: 'message', label: 'Message' },
+ { key: 'happened_at', label: 'Happened At', format: 'datetime' },
+ { key: 'created_at', label: 'Created At', format: 'datetime' },
+ {
+ key: 'estimated_delivery_at',
+ label: 'Estimated Delivery At',
+ format: 'datetime',
+ },
+ { key: 'address1', label: 'Address 1' },
+ { key: 'city', label: 'City' },
+ { key: 'province', label: 'Province' },
+ { key: 'country', label: 'Country' },
+ { key: 'zip', label: 'Zip' },
+ { key: 'latitude', label: 'Latitude', format: 'number' },
+ { key: 'longitude', label: 'Longitude', format: 'number' },
+];
+
+const giftCardFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Gift Card ID' },
+ { key: 'last_characters', label: 'Last Characters' },
+ { key: 'masked_code', label: 'Masked Code' },
+ { key: 'enabled', label: 'Enabled', format: 'boolean' },
+ { key: 'is_redeemable', label: 'Is Redeemable', format: 'boolean' },
+ { key: 'deactivated_at', label: 'Deactivated At', format: 'datetime' },
+ { key: 'expires_on', label: 'Expires On', format: 'date' },
+ { key: 'balance', label: 'Balance', format: 'number' },
+ { key: 'initial_value', label: 'Initial Value', format: 'number' },
+ { key: 'currency_code', label: 'Currency Code' },
+ { key: 'note', label: 'Note' },
+ { key: 'template_suffix', label: 'Template Suffix' },
+ { key: 'customer_id', label: 'Customer ID' },
+ { key: 'customer_name', label: 'Customer Name' },
+ { key: 'order_id', label: 'Order ID' },
+ { key: 'order_name', label: 'Order Name' },
+ { key: 'recipient_id', label: 'Recipient ID' },
+ { key: 'recipient_name', label: 'Recipient Name' },
+ { key: 'recipient_preferred_name', label: 'Recipient Preferred Name' },
+ { key: 'recipient_message', label: 'Recipient Message' },
+ {
+ key: 'send_notification_at',
+ label: 'Send Notification At',
+ format: 'datetime',
+ },
+ { key: 'created_at', label: 'Created At', format: 'datetime' },
+ { key: 'updated_at', label: 'Updated At', format: 'datetime' },
+];
+
+export const fulfillmentOrderOutputSchema: OutputSchema = {
+ fields: [...fulfillmentOrderFields, redactedFieldsField],
+};
+
+export const listOrderFulfillmentOrdersOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'order_id', label: 'Order ID' },
+ {
+ key: 'items',
+ label: 'Fulfillment Orders',
+ labelKey: 'assigned_location_name',
+ listItems: fulfillmentOrderFields,
+ },
+ ...pageFields,
+ ],
+};
+
+export const holdFulfillmentOrderOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'hold_id', label: 'Hold ID' },
+ { key: 'hold_reason', label: 'Hold Reason' },
+ { key: 'hold_reason_notes', label: 'Hold Reason Notes' },
+ { key: 'hold_display_reason', label: 'Hold Display Reason' },
+ { key: 'hold_handle', label: 'Hold Handle' },
+ {
+ key: 'fulfillment_order',
+ label: 'Fulfillment Order',
+ children: fulfillmentOrderFields,
+ },
+ {
+ key: 'remaining_fulfillment_order',
+ label: 'Remaining Fulfillment Order',
+ description: 'The split-off order for any quantity not held, or null.',
+ children: fulfillmentOrderFields,
+ },
+ redactedFieldsField,
+ ],
+};
+
+export const releaseFulfillmentOrderHoldOutputSchema: OutputSchema = {
+ fields: [
+ ...fulfillmentOrderFields,
+ { key: 'released_hold_ids', label: 'Released Hold IDs' },
+ redactedFieldsField,
+ ],
+};
+
+export const listFulfillmentOrderMoveLocationsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'fulfillment_order_id', label: 'Fulfillment Order ID' },
+ {
+ key: 'items',
+ label: 'Locations',
+ labelKey: 'location_name',
+ listItems: [
+ { key: 'location_id', label: 'Location ID' },
+ { key: 'location_name', label: 'Location Name' },
+ { key: 'movable', label: 'Movable', format: 'boolean' },
+ {
+ key: 'message',
+ label: 'Message',
+ description: 'Why the order cannot move here, when not movable.',
+ },
+ {
+ key: 'available_line_items_count',
+ label: 'Available Line Items',
+ format: 'number',
+ },
+ {
+ key: 'unavailable_line_items_count',
+ label: 'Unavailable Line Items',
+ format: 'number',
+ },
+ ],
+ },
+ ...pageFields,
+ ],
+};
+
+export const moveFulfillmentOrderOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'moved_fulfillment_order',
+ label: 'Moved Fulfillment Order',
+ children: fulfillmentOrderFields,
+ },
+ {
+ key: 'original_fulfillment_order',
+ label: 'Original Fulfillment Order',
+ children: fulfillmentOrderFields,
+ },
+ {
+ key: 'remaining_fulfillment_order',
+ label: 'Remaining Fulfillment Order',
+ description: 'Quantity left at the old location, or null.',
+ children: fulfillmentOrderFields,
+ },
+ redactedFieldsField,
+ ],
+};
+
+export const setFulfillmentOrdersDeadlineOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'success', label: 'Success', format: 'boolean' },
+ { key: 'fulfillment_order_ids', label: 'Fulfillment Order IDs' },
+ { key: 'deadline', label: 'Deadline', format: 'datetime' },
+ redactedFieldsField,
+ ],
+};
+
+export const cancelFulfillmentOrderOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'fulfillment_order',
+ label: 'Fulfillment Order',
+ children: fulfillmentOrderFields,
+ },
+ {
+ key: 'replacement_fulfillment_order',
+ label: 'Replacement Fulfillment Order',
+ description: 'The new open order Shopify created for the cancelled quantity, or null.',
+ children: fulfillmentOrderFields,
+ },
+ redactedFieldsField,
+ ],
+};
+
+export const fulfillmentOutputSchema: OutputSchema = {
+ fields: [...fulfillmentFields, redactedFieldsField],
+};
+
+export const createFulfillmentOutputSchema: OutputSchema = {
+ fields: [
+ ...fulfillmentFields,
+ { key: 'fulfillment_order_id', label: 'Fulfillment Order ID' },
+ redactedFieldsField,
+ ],
+};
+
+export const fulfillmentSummaryOutputSchema: OutputSchema = {
+ fields: [...fulfillmentSummaryFields, redactedFieldsField],
+};
+
+export const listOrderFulfillmentsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'order_id', label: 'Order ID' },
+ {
+ key: 'items',
+ label: 'Fulfillments',
+ labelKey: 'name',
+ listItems: fulfillmentSummaryFields,
+ },
+ { key: 'count', label: 'Count', format: 'number' },
+ { key: 'total_count', label: 'Total Count', format: 'number' },
+ {
+ key: 'truncated',
+ label: 'Truncated',
+ format: 'boolean',
+ description: 'True when the order has more fulfillments than were returned.',
+ },
+ redactedFieldsField,
+ ],
+};
+
+export const createFulfillmentTrackingEventOutputSchema: OutputSchema = {
+ fields: [
+ ...fulfillmentEventFields,
+ { key: 'fulfillment_id', label: 'Fulfillment ID' },
+ redactedFieldsField,
+ ],
+};
+
+export const listFulfillmentEventsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'fulfillment_id', label: 'Fulfillment ID' },
+ {
+ key: 'items',
+ label: 'Fulfillment Events',
+ labelKey: 'status',
+ listItems: fulfillmentEventFields,
+ },
+ ...pageFields,
+ ],
+};
+
+export const giftCardOutputSchema: OutputSchema = {
+ fields: [...giftCardFields, redactedFieldsField],
+};
+
+export const createGiftCardOutputSchema: OutputSchema = {
+ fields: [
+ ...giftCardFields,
+ {
+ key: 'gift_card_code',
+ label: 'Gift Card Code',
+ description: 'The full code. Shopify shows it only once, so store it now.',
+ },
+ {
+ key: 'warning',
+ label: 'Warning',
+ description: 'Set when Shopify created the card but withheld its record (protected customer data); the other fields are then empty.',
+ },
+ redactedFieldsField,
+ ],
+};
+
+export const searchGiftCardsOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'items',
+ label: 'Gift Cards',
+ labelKey: 'masked_code',
+ listItems: giftCardFields,
+ },
+ ...pageFields,
+ ],
+};
+
+export const listDeliveryZonesOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'profile_id', label: 'Delivery Profile ID' },
+ { key: 'location_group_id', label: 'Location Group ID' },
+ {
+ key: 'items',
+ label: 'Zones',
+ labelKey: 'zone_name',
+ listItems: [
+ { key: 'zone_id', label: 'Zone ID' },
+ { key: 'zone_name', label: 'Zone Name' },
+ { key: 'countries', label: 'Countries' },
+ {
+ key: 'rates',
+ label: 'Rates',
+ labelKey: 'name',
+ listItems: [
+ { key: 'id', label: 'Rate ID' },
+ { key: 'name', label: 'Name' },
+ { key: 'active', label: 'Active', format: 'boolean' },
+ { key: 'description', label: 'Description' },
+ { key: 'price', label: 'Price', format: 'number' },
+ { key: 'currency_code', label: 'Currency Code' },
+ { key: 'carrier_service_id', label: 'Carrier Service ID' },
+ { key: 'carrier_service_name', label: 'Carrier Service Name' },
+ ],
+ },
+ { key: 'rates_truncated', label: 'Rates Truncated', format: 'boolean' },
+ { key: 'rates_end_cursor', label: 'Rates Cursor', description: 'Pass as rates_after, with zone_token, to read the next 50 rates.' },
+ { key: 'zone_token', label: 'Zone Token', description: 'Pass as zone_token to read more rates of this zone.' },
+ ],
+ },
+ ...pageFields,
+ ],
+};
diff --git a/packages/pieces/community/shopify/test/w3-fulfillment.test.ts b/packages/pieces/community/shopify/test/w3-fulfillment.test.ts
new file mode 100644
index 00000000000..1e302168080
--- /dev/null
+++ b/packages/pieces/community/shopify/test/w3-fulfillment.test.ts
@@ -0,0 +1,320 @@
+import { afterEach, describe, expect, it, vi } from 'vitest';
+import '../src';
+import { shopifyAiCreateGiftCard } from '../src/lib/actions/ai/create-gift-card';
+import { shopifyAiDeleteDiscountRedeemCodes } from '../src/lib/actions/ai/delete-discount-redeem-codes';
+import { shopifyAiGetFulfillmentOrder } from '../src/lib/actions/ai/get-fulfillment-order';
+import { shopifyAiListDeliveryZones } from '../src/lib/actions/ai/list-delivery-zones';
+import { shopifyAiListDiscountRedeemCodes } from '../src/lib/actions/ai/list-discount-redeem-codes';
+import { shopifyAiUpdateGiftCard } from '../src/lib/actions/ai/update-gift-card';
+import { mockShopify, runAction } from './helpers';
+
+const DISCOUNT = 'gid://shopify/DiscountCodeNode/42';
+const GIFT_CARD_CODE = 'GC7Q2M9X4K1P8Z3W';
+
+const GIFT_CARD_DENIAL = {
+ message: 'This app is not approved to access the GiftCard object. See https://shopify.dev/docs/apps/launch/protected-customer-data for more details.',
+ path: ['giftCardCreate', 'giftCard'],
+ extensions: { code: 'ACCESS_DENIED' },
+};
+
+afterEach(() => {
+ vi.restoreAllMocks();
+});
+
+describe('discount redeem code search', () => {
+ it('delete_discount_redeem_codes refuses a field filter before calling Shopify', async () => {
+ const sent = mockShopify({ replies: [] });
+
+ await expect(
+ runAction({ action: shopifyAiDeleteDiscountRedeemCodes, propsValue: { discount_id: DISCOUNT, search: 'code:X' } })
+ ).rejects.toThrow('Shopify ignores other filters such as "code:"');
+ expect(sent).toHaveLength(0);
+ });
+
+ it('list_discount_redeem_codes refuses a field filter before calling Shopify', async () => {
+ const sent = mockShopify({ replies: [] });
+
+ await expect(
+ runAction({ action: shopifyAiListDiscountRedeemCodes, propsValue: { discount_id: DISCOUNT, query: 'code:X' } })
+ ).rejects.toThrow('Shopify ignores other filters such as "code:"');
+ expect(sent).toHaveLength(0);
+ });
+
+ it('delete_discount_redeem_codes sends a supported times_used search', async () => {
+ const sent = mockShopify({
+ replies: [{ data: { discountCodeRedeemCodeBulkDelete: { job: { id: 'gid://shopify/Job/1', done: false }, userErrors: [] } } }],
+ });
+
+ const result = await runAction({
+ action: shopifyAiDeleteDiscountRedeemCodes,
+ propsValue: { discount_id: '42', search: 'times_used:0' },
+ });
+
+ expect(sent[0].variables).toEqual({ discountId: DISCOUNT, search: 'times_used:0' });
+ expect(result).toEqual({ discount_id: DISCOUNT, job_id: 'gid://shopify/Job/1', done: false, redacted_fields: [] });
+ });
+});
+
+describe('create_gift_card', () => {
+ it('returns the gift card code with a warning when Shopify withholds the gift card record', async () => {
+ const sent = mockShopify({
+ replies: [
+ {
+ data: { giftCardCreate: { giftCard: null, giftCardCode: GIFT_CARD_CODE, userErrors: [] } },
+ errors: [GIFT_CARD_DENIAL],
+ },
+ ],
+ });
+
+ const result = await runAction({ action: shopifyAiCreateGiftCard, propsValue: { amount: 25, currency: 'usd' } });
+
+ expect(sent[0].variables).toEqual({ input: { initialAmount: { amount: '25', currencyCode: 'USD' } } });
+ expect(result).toMatchObject({
+ id: null,
+ gift_card_code: GIFT_CARD_CODE,
+ redacted_fields: ['giftCardCreate.giftCard'],
+ });
+ expect(result).toHaveProperty('warning', expect.stringContaining('Shopify CREATED the gift card'));
+ });
+
+ it('does not put the gift card code into the error when Shopify rejects the request', async () => {
+ mockShopify({
+ replies: [
+ {
+ data: {
+ giftCardCreate: {
+ giftCard: null,
+ giftCardCode: GIFT_CARD_CODE,
+ userErrors: [{ field: ['input', 'customerId'], message: 'Customer does not exist', code: 'INVALID' }],
+ },
+ },
+ },
+ ],
+ });
+
+ const error = await runAction({ action: shopifyAiCreateGiftCard, propsValue: { amount: 25, currency: 'USD', customer_id: '9' } }).catch(
+ (e: Error) => e
+ );
+
+ expect(error).toBeInstanceOf(Error);
+ expect(String(error)).toContain('Customer does not exist');
+ expect(String(error)).not.toContain(GIFT_CARD_CODE);
+ });
+
+ it('does not put the gift card code into the error when neither the card nor the code is returned', async () => {
+ mockShopify({ replies: [{ data: { giftCardCreate: { giftCard: null, giftCardCode: null, userErrors: [] } }, errors: [GIFT_CARD_DENIAL] }] });
+
+ const error = await runAction({ action: shopifyAiCreateGiftCard, propsValue: { amount: 25, currency: 'USD', code: GIFT_CARD_CODE } }).catch(
+ (e: Error) => e
+ );
+
+ expect(String(error)).toContain('Shopify CREATED the gift card');
+ expect(String(error)).not.toContain(GIFT_CARD_CODE);
+ });
+});
+
+describe('get_fulfillment_order', () => {
+ it('pages line items with $lineItemsAfter and returns the next cursor', async () => {
+ const sent = mockShopify({
+ replies: [
+ {
+ data: {
+ fulfillmentOrder: {
+ id: 'gid://shopify/FulfillmentOrder/3',
+ status: 'OPEN',
+ lineItems: {
+ pageInfo: { hasNextPage: true, endCursor: 'cursor-2' },
+ nodes: [{ id: 'gid://shopify/FulfillmentOrderLineItem/1', totalQuantity: 1, remainingQuantity: 1 }],
+ },
+ },
+ },
+ },
+ ],
+ });
+
+ const result = await runAction({
+ action: shopifyAiGetFulfillmentOrder,
+ propsValue: { fulfillment_order_id: '3', line_items_after: 'cursor-1' },
+ });
+
+ expect(sent[0].query).toContain('lineItems(first: 50, after: $lineItemsAfter)');
+ expect(sent[0].variables).toEqual({ id: 'gid://shopify/FulfillmentOrder/3', lineItemsAfter: 'cursor-1' });
+ expect(result).toMatchObject({ id: 'gid://shopify/FulfillmentOrder/3', line_items_truncated: true, line_items_end_cursor: 'cursor-2' });
+ });
+});
+
+describe('date validation', () => {
+ it('update_gift_card refuses an impossible expires_on date before calling Shopify', async () => {
+ const sent = mockShopify({ replies: [] });
+
+ await expect(
+ runAction({ action: shopifyAiUpdateGiftCard, propsValue: { gift_card_id: '5', expires_on: '2026-02-31' } })
+ ).rejects.toThrow('"2026-02-31" is not a real date in the form YYYY-MM-DD');
+ expect(sent).toHaveLength(0);
+ });
+
+ it('update_gift_card sends a real expires_on date', async () => {
+ const sent = mockShopify({ replies: [{ data: { giftCardUpdate: { giftCard: { id: 'gid://shopify/GiftCard/5' }, userErrors: [] } } }] });
+
+ await runAction({ action: shopifyAiUpdateGiftCard, propsValue: { gift_card_id: '5', expires_on: '2028-02-29' } });
+
+ expect(sent[0].variables).toEqual({ id: 'gid://shopify/GiftCard/5', input: { expiresOn: '2028-02-29' } });
+ });
+});
+
+describe('list_delivery_zones', () => {
+ const PROPS = { profile_id: '1', location_group_id: '2' };
+
+ it('explains when the location group is not part of the profile', async () => {
+ mockShopify({ replies: [{ data: { deliveryProfile: { id: 'gid://shopify/DeliveryProfile/1', profileLocationGroups: [] } } }] });
+
+ await expect(runAction({ action: shopifyAiListDeliveryZones, propsValue: PROPS })).rejects.toThrow(
+ 'Location group gid://shopify/DeliveryLocationGroup/2 is not part of delivery profile gid://shopify/DeliveryProfile/1'
+ );
+ });
+
+ it('maps the zones of the location group', async () => {
+ const sent = mockShopify({
+ replies: [
+ {
+ data: {
+ deliveryProfile: {
+ id: 'gid://shopify/DeliveryProfile/1',
+ profileLocationGroups: [
+ {
+ locationGroupZones: {
+ pageInfo: { hasNextPage: false, endCursor: 'z1' },
+ edges: [
+ {
+ cursor: 'c7',
+ node: {
+ zone: {
+ id: 'gid://shopify/DeliveryZone/7',
+ name: 'Domestic',
+ countries: [{ name: 'Canada', code: { countryCode: 'CA', restOfWorld: false } }],
+ },
+ methodDefinitions: {
+ pageInfo: { hasNextPage: false },
+ nodes: [
+ {
+ id: 'gid://shopify/DeliveryMethodDefinition/8',
+ name: 'Standard',
+ active: true,
+ rateProvider: { __typename: 'DeliveryRateDefinition', price: { amount: '5.0', currencyCode: 'CAD' } },
+ },
+ ],
+ },
+ },
+ },
+ ],
+ },
+ },
+ ],
+ },
+ },
+ },
+ ],
+ });
+
+ const result = await runAction({ action: shopifyAiListDeliveryZones, propsValue: PROPS });
+
+ expect(sent[0].variables).toEqual({
+ id: 'gid://shopify/DeliveryProfile/1',
+ locationGroupId: 'gid://shopify/DeliveryLocationGroup/2',
+ first: 10,
+ });
+ expect(result).toEqual({
+ profile_id: 'gid://shopify/DeliveryProfile/1',
+ location_group_id: 'gid://shopify/DeliveryLocationGroup/2',
+ items: [
+ {
+ zone_id: 'gid://shopify/DeliveryZone/7',
+ zone_name: 'Domestic',
+ countries: ['CA'],
+ rates: [
+ {
+ id: 'gid://shopify/DeliveryMethodDefinition/8',
+ name: 'Standard',
+ active: true,
+ description: null,
+ price: '5.0',
+ currency_code: 'CAD',
+ carrier_service_id: null,
+ carrier_service_name: null,
+ },
+ ],
+ rates_truncated: false,
+ rates_end_cursor: null,
+ zone_token: 'first',
+ },
+ ],
+ count: 1,
+ has_next_page: false,
+ end_cursor: 'z1',
+ redacted_fields: [],
+ });
+ });
+
+ it('reads the next rates of one zone with zone_token and rates_after', async () => {
+ const sent = mockShopify({
+ replies: [
+ {
+ data: {
+ deliveryProfile: {
+ id: 'gid://shopify/DeliveryProfile/1',
+ profileLocationGroups: [
+ {
+ locationGroupZones: {
+ pageInfo: { hasNextPage: true, endCursor: 'c9' },
+ edges: [
+ {
+ cursor: 'c9',
+ node: {
+ zone: { id: 'gid://shopify/DeliveryZone/9', name: 'EU', countries: [] },
+ methodDefinitions: { pageInfo: { hasNextPage: false, endCursor: 'r2' }, nodes: [] },
+ },
+ },
+ ],
+ },
+ },
+ ],
+ },
+ },
+ },
+ ],
+ });
+
+ const result = await runAction({
+ action: shopifyAiListDeliveryZones,
+ propsValue: { ...PROPS, zone_token: 'c8', rates_after: 'r1' },
+ });
+
+ expect(sent[0].variables).toEqual({
+ id: 'gid://shopify/DeliveryProfile/1',
+ locationGroupId: 'gid://shopify/DeliveryLocationGroup/2',
+ first: 1,
+ after: 'c8',
+ ratesAfter: 'r1',
+ });
+ expect(result).toMatchObject({ count: 1, has_next_page: false, end_cursor: null, items: [{ zone_id: 'gid://shopify/DeliveryZone/9', zone_token: 'c8', rates_end_cursor: 'r2' }] });
+ });
+
+ it('accepts a page size up to 25 but fetches at most 10 zones per call', async () => {
+ const sent = mockShopify({
+ replies: [{ data: { deliveryProfile: { id: 'gid://shopify/DeliveryProfile/1', profileLocationGroups: [{ locationGroupZones: { edges: [], pageInfo: { hasNextPage: false, endCursor: null } } }] } } }],
+ });
+
+ await runAction({ action: shopifyAiListDeliveryZones, propsValue: { ...PROPS, first: 25 } });
+
+ expect(sent[0].variables).toMatchObject({ first: 10 });
+ });
+
+ it('refuses rates_after without zone_token before calling Shopify', async () => {
+ const sent = mockShopify({ replies: [] });
+
+ await expect(
+ runAction({ action: shopifyAiListDeliveryZones, propsValue: { ...PROPS, rates_after: 'r1' } })
+ ).rejects.toThrow('Set zone_token together with rates_after');
+ expect(sent).toHaveLength(0);
+ });
+});