Welcome to the January 2022 edition of our API features roundup, designed to help you understand how you can adopt all the latest changes to improve the quality of your apps and streamline your development experience.
这个版本包括改善产品过滤through the storefront API, the all-new product taxonomy API, and new metafield definitions on collections, customers, and orders. This version also includes an order invoice API, new error codes for bulk mutations, and simplified methods for getting translatable resources, featured images, and barcodes.
This release also coincides with the removal of version2021-01, so remember tocheck your API health reportto make sure you're compatible and review the changes coming. For a full list of API changes associated with this version, visit the2022-01 release notes.
Table of contents
Build apps for Shopify merchants
Whether you want to build apps for the Shopify App Store, offer custom app development services, or are looking for ways to grow your user base, the Shopify Partner Program will set you up for success. Join for free and access educational resources, developer preview environments, and recurring revenue share opportunities.
Sign up1. Product filtering in collections using the Storefront API
2022 - 01年的版本,现在可以filter products in a collection, allowing you to narrow down the search results displayed to customers. After retrieving products by the collection they belong to, you can filter products in a collection based on the vendor, product type, variant options, price, and whether or not the product is in stock.
These filters can even be combined, allowing you to retrieve products in a collection with a specific set of more complex characteristics.
For example, the following query shows how to fetch products that have all the following characteristics:
- Type: Shirts & Tops
- Vendor: Bestshop
- Color: Very Peri
Variables:
Filtering products in a collection is a great way to surface the most relevant products to customers. For more information on how to filter products in a collection using the Storefront API, you canvisit our docs.
2. Product Taxonomy API
The new Product Taxonomy API is the best way to keep products organized and discoverable by customers on merchant’s storefronts.StandardizedProductTypesare公关edefined categoriesof products that can improve discoverability on the storefront and make it easier for merchants to list products on channels like Facebook that require products to fit in a standard set of types.
For product types that don’t fit in one of the predefined categories, you can use thecustomProductType
field on the product object. Custom product types are a string, like the legacytype
field. These custom product types can also be paired with a parent StandardizedProductType if a parent category makes sense for the product.
Below is an example of a query to fetch the StandardizedProductType of a given product:
Response:
了解更多关于产品分类,访问我们developer docs.
3. Metafield definitions on Collections, Customers, and Orders
In the July version, we releasedupdates to Metafieldsthat allowed custom metafield types on Products. This version expands support for this feature to Collections, Customers, and Orders. Metafields on these new resources can also perform validations on18 different types of data, allowing you to store validated data for display on storefronts or within apps.
Below is an example of a request to create a Customer metafield definition that stores a reference to a product.
Variables:
For more information about metafield definitions and migration to the improvedtype
system, visit ourdeveloper docs.
4. Order Invoice API
A new mutation has been added to apps to send invoices for orders through Shopify's API. TheorderInvoiceSendmutation allows you to provide an order ID and email content, and directly email a customer to request payment for an order that still requires payment. This is a great opportunity to automate what has previously been a very manual process for merchants.
Below is an example mutation to send an invoice to the customer:
Variables:
Below is the email that this request will send to the customer:
This email will link directly to the checkout, allowing the customer to easily pay for the order.
Visit our reference documentationfor more information about sending invoices with the orderInvoiceSend mutation.
5. Bulk Mutation API error codes
Previously, the only error code BulkMutations could display was "BULK_MUTATION_USER_ERROR_CODE". In this version, we've replaced that general error code with five new, more granular error codes that will provide more insight into what exactly went wrong.
For a complete list of the new error codes, visit ourdeveloper docs.
As a reminder, if you need to do more than 10 seconds of continuous API requests, the BulkMutationAPI is thefastest and most efficient wayto sync data back to Shopify. To learn more about syncing data to Shopify with the BulkMutation API, visitour documentation.
6. Fetch multiple Translatable resources by ID
In the past, getting translatable resources for a specific set of IDs required you to make multiple requests, getting a single resource at a time. As of 2022-01, it's now possible to get a specific list of translatable resources using an array of IDs, rather than getting all of the resources that belong to a specific type or needing to make a separate request to get each resource by ID.
Below is an example of a request to get the translatable content from a specific product and two variants with a single request:
For more information about the translatableResourcesByIds query, visit ourreference documentation.
7. New Storefront API product fields
As of the 2022-01 version, the Storefront API supports two new fields on products. ThefeaturedImage
field allows you to quickly and efficiently fetch the featured image of any product, and the ProductVariantbarcode
allows you to fetch the barcode of any variant.
Below is an example query that fetches both new fields:
Response:
Stay on top of changes
For all Shopify platform changes, make sure to subscribe to thedeveloper changelog, the primary source of information for all new product launches. Stay up to date using the changelog, and stay ahead of the curve by adopting new features as soon as they’re shipped into the upcoming2022-04release candidate.
You can also subscribe to our monthly What’s New for Partners and Developers at Shopify newsletter, which will help keep you on top of all platform updates.
Stay in the know
Subscribe to receive What's New with Shopify, our monthly email featuring Shopify's latest product news.