trying to assign products to the new Shipping Profiles (which are call deliveryProfiles in the graphql-API).
Seems that product/variants are linked to the deliveryProfile via the ProfileItems Object.
If I understand correctly the ProfileItems Object is the one that captures which product-variant belongs to which delivery profile, so updating/adding/deleting for that object would move the product to a different (or general) shipping profile.
I'm not able to find which REST-API endpoint or which graphQL mutation will help me assign the product to a profile.
Am I looking at the right place or can this right now only be done in the admin screens?
tx.
Solved! Go to the solution
This is an accepted solution.
Hi @go4it ,
In order to assign Products and Product Variants (and thereby add ProfileItems) to your Shipping/Delivery Profiles programmatically via our GraphQL Admin API, you need to use the mutation of `deliveryProfileCreate` or `deliveryProfileUpdate`. When calling these mutations, you need to include the input of "profile" which will be an object of type "DeliveryProfileInput". In this "profile" object you can include the field of "variantsToAdd", which will then be populated by the product variant IDs of the products you would like to assign to your new Shipping Profiles.
Here is an example of the `deliveryProfileCreate` mutation being called to create a new Shipping Profile with a product added to it:
mutation { deliveryProfileCreate (profile: { name: "Name of your Shipping Profile", variantsToAssociate: [ "gid://shopify/ProductVariant/{Insert-Product-Variant-ID-Here}", ] }) { profile { id name profileItems (first: 10) { edges { node { product { id } variants (first:10) { edges { node { id displayName } } } } } } } userErrors { field message } } }
Hassain | Developer Support Specialist @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Click Accept as Solution
@hassain
Perfect. Thanks for pointing out that this goes via the deliveryProfileUpdate mutation. (with the input of mutation).
Your example is much appriciate as getting some of the GQL syntax is a bit confusing :-)
Is working now.
Sorry to the late reply, got sidetracked on other work.
Regards,
Yeah as I mentioned in my earlier comment there us `deliveryProfileUpdate` https://shopify.dev/docs/admin-api/graphql/reference/mutation/deliveryprofileupdate
In the input of this mutation you would want to use the variantsToDissociate field
Hassain | Developer Support Specialist @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Click Accept as Solution
Hi @danrichards ,
In the REST API you can use the resource of ShippingZones - https://shopify.dev/docs/admin-api/rest/reference/store-properties/shippingzone
After API version 2019-07 this endpoint returns 3 values related to delivery profiles:
profile_id
: The ID of the zone’s delivery profilelocation_group_id
: The ID of the zone’s location groupadmin_graphql_api_id
: The zone’s ID for use with the GraphQL Admin APAlso I would recommend reading this documentation that describes how you can update your app from using legacy API endpoints to making use of delivery profiles https://shopify.dev/tutorials/migrate-your-app-to-support-delivery-profiles#shippingzone
Hassain | Developer Support Specialist @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Click Accept as Solution
User | Count |
---|---|
12 | |
12 | |
10 | |
8 | |
7 |